From b5002d7367bbb3ac6f19726d002498d650894b47 Mon Sep 17 00:00:00 2001 From: Greg Walker Date: Mon, 20 May 2024 09:48:43 -0500 Subject: [PATCH 1/2] split into composite actions for fewer conditionals --- .../actions/accessibility-tests/action.yml | 7 + .../browser-tests-playwright/action.yml | 7 + .../javascript-component-tests/action.yml | 17 ++ .github/actions/javascript-lint/action.yml | 20 +++ .github/actions/php-lint/action.yml | 29 ++++ .github/actions/setup-playwright/action.yml | 12 ++ .github/actions/style-lint/action.yml | 18 +++ .github/workflows/code-standards.yaml | 150 ++---------------- 8 files changed, 122 insertions(+), 138 deletions(-) create mode 100644 .github/actions/accessibility-tests/action.yml create mode 100644 .github/actions/browser-tests-playwright/action.yml create mode 100644 .github/actions/javascript-component-tests/action.yml create mode 100644 .github/actions/javascript-lint/action.yml create mode 100644 .github/actions/php-lint/action.yml create mode 100644 .github/actions/setup-playwright/action.yml create mode 100644 .github/actions/style-lint/action.yml diff --git a/.github/actions/accessibility-tests/action.yml b/.github/actions/accessibility-tests/action.yml new file mode 100644 index 000000000..4bb88cede --- /dev/null +++ b/.github/actions/accessibility-tests/action.yml @@ -0,0 +1,7 @@ +runs: + using: composite + steps: + - name: prepare playwright + uses: ./.github/actions/setup-playwright + - name: run tests + run: npx playwright test a11y \ No newline at end of file diff --git a/.github/actions/browser-tests-playwright/action.yml b/.github/actions/browser-tests-playwright/action.yml new file mode 100644 index 000000000..e1bf232e5 --- /dev/null +++ b/.github/actions/browser-tests-playwright/action.yml @@ -0,0 +1,7 @@ +runs: + using: composite + steps: + - name: prepare playwright + uses: ./.github/actions/setup-playwright + - name: run tests + run: npx playwright test e2e/* \ No newline at end of file diff --git a/.github/actions/javascript-component-tests/action.yml b/.github/actions/javascript-component-tests/action.yml new file mode 100644 index 000000000..50cf8945d --- /dev/null +++ b/.github/actions/javascript-component-tests/action.yml @@ -0,0 +1,17 @@ +runs: + using: composite + steps: + - name: setup node + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + + - name: install dependencies + run: npm ci + + - name: install proxy dependencies + run: cd tests/api && npm ci + + - name: run js-component-tests + run: npm run js-component-tests \ No newline at end of file diff --git a/.github/actions/javascript-lint/action.yml b/.github/actions/javascript-lint/action.yml new file mode 100644 index 000000000..7165201c2 --- /dev/null +++ b/.github/actions/javascript-lint/action.yml @@ -0,0 +1,20 @@ +runs: + using: composite + steps: + - name: setup node + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + + - name: install dependencies + run: npm ci + + - name: install proxy dependencies + run: cd tests/api && npm ci + + - name: add problem matcher + run: echo "::add-matcher::${{ github.workspace }}/.github/workflows/problem-matcher-eslint.json" + + - name: run eslint + run: npm run js-lint \ No newline at end of file diff --git a/.github/actions/php-lint/action.yml b/.github/actions/php-lint/action.yml new file mode 100644 index 000000000..9065ccd51 --- /dev/null +++ b/.github/actions/php-lint/action.yml @@ -0,0 +1,29 @@ +runs: + using: composite + steps: + - name: setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: "8.2" + + - name: get composer paths + id: composer-paths + run: | + echo "cache-dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + echo "bin-dir=${{ github.workspace }}/$(composer config bin-dir)" >> $GITHUB_OUTPUT + + - name: cache composer caches + uses: actions/cache@v4 + with: + path: ${{ steps.composer-paths.outputs.cache-dir }} + key: composer-cache-${{ hashFiles('composer.lock') }} + + - name: install dependencies + env: + COMPOSER_NO_DEV: 0 + run: composer install + + - name: run phpcs + run: | + echo "::add-matcher::${{ github.workspace }}/.github/workflows/problem-matcher-phpcs.json" + vendor/bin/phpcs --report=checkstyle \ No newline at end of file diff --git a/.github/actions/setup-playwright/action.yml b/.github/actions/setup-playwright/action.yml new file mode 100644 index 000000000..a00dac2a4 --- /dev/null +++ b/.github/actions/setup-playwright/action.yml @@ -0,0 +1,12 @@ +runs: + using: composite + steps: + - uses: browser-actions/setup-chrome@v1 + - uses: browser-actions/setup-edge@v1 + - uses: actions/setup-node@v4 + with: + node-version: 18 + - name: install dependencies + run: npm ci + - name: install browsers + run: npx playwright install --with-deps diff --git a/.github/actions/style-lint/action.yml b/.github/actions/style-lint/action.yml new file mode 100644 index 000000000..7808da537 --- /dev/null +++ b/.github/actions/style-lint/action.yml @@ -0,0 +1,18 @@ +runs: + using: composite + steps: + - name: setup node + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + + - name: install dependencies + run: npm ci + + # Stylelint has a GitHub workflow commands output available by default, + # so we can use that instead of needing a problem matcher. + # https://stylelint.io/user-guide/options#formatter + # https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions + - name: run stylelint + run: npm run style-lint -- -f github \ No newline at end of file diff --git a/.github/workflows/code-standards.yaml b/.github/workflows/code-standards.yaml index c9f9b1d85..184bd8d5d 100644 --- a/.github/workflows/code-standards.yaml +++ b/.github/workflows/code-standards.yaml @@ -10,7 +10,6 @@ jobs: outputs: "no": ${{ steps.skip-tests.outputs.no }} "yes": ${{ steps.skip-tests.outputs.yes }} - steps: - name: checkout uses: actions/checkout@v4 @@ -58,140 +57,54 @@ jobs: name: PHP lint runs-on: ubuntu-latest needs: [should-test] - steps: - name: checkout if: needs.should-test.outputs.yes == 'true' uses: actions/checkout@v4 - - - name: setup PHP + - name: lint PHP if: needs.should-test.outputs.yes == 'true' - uses: shivammathur/setup-php@v2 - with: - php-version: "8.2" - - - name: get composer paths - if: needs.should-test.outputs.yes == 'true' - id: composer-paths - run: | - echo "cache-dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - echo "bin-dir=${{ github.workspace }}/$(composer config bin-dir)" >> $GITHUB_OUTPUT - - - name: cache composer caches - if: needs.should-test.outputs.yes == 'true' - uses: actions/cache@v4 - with: - path: ${{ steps.composer-paths.outputs.cache-dir }} - key: composer-cache-${{ hashFiles('composer.lock') }} - - - name: install dependencies - if: needs.should-test.outputs.yes == 'true' - env: - COMPOSER_NO_DEV: 0 - run: composer install - - - name: run phpcs - if: needs.should-test.outputs.yes == 'true' - run: | - echo "::add-matcher::${{ github.workspace }}/.github/workflows/problem-matcher-phpcs.json" - vendor/bin/phpcs --report=checkstyle + uses: ./.github/actions/php-lint js-lint: name: JS lint runs-on: ubuntu-latest needs: [should-test] - steps: - name: checkout if: needs.should-test.outputs.yes == 'true' uses: actions/checkout@v4 - - - name: setup node + - name: lint Javascript if: needs.should-test.outputs.yes == 'true' - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: npm - - - name: install dependencies - if: needs.should-test.outputs.yes == 'true' - run: npm ci - - - name: install proxy dependencies - if: needs.should-test.outputs.yes == 'true' - run: cd tests/api && npm ci - - - name: add problem matcher - if: needs.should-test.outputs.yes == 'true' - run: echo "::add-matcher::${{ github.workspace }}/.github/workflows/problem-matcher-eslint.json" - - - name: run eslint - if: needs.should-test.outputs.yes == 'true' - run: npm run js-lint + uses: ./.github/actions/javascript-lint js-component-tests: name: JS Component Tests runs-on: ubuntu-latest needs: [should-test] - steps: - name: checkout if: needs.should-test.outputs.yes == 'true' uses: actions/checkout@v4 - - - name: setup node - if: needs.should-test.outputs.yes == 'true' - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: npm - - - name: install dependencies - if: needs.should-test.outputs.yes == 'true' - run: npm ci - - - name: install proxy dependencies + - name: run Javascript component tests if: needs.should-test.outputs.yes == 'true' - run: cd tests/api && npm ci - - - name: run js-component-tests - if: needs.should-test.outputs.yes == 'true' - run: npm run js-component-tests + uses: ./.github/actions/javascript-component-tests style-lint: name: SCSS lint runs-on: ubuntu-latest needs: [should-test] - steps: - name: checkout if: needs.should-test.outputs.yes == 'true' uses: actions/checkout@v4 - - - name: setup node - if: needs.should-test.outputs.yes == 'true' - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: npm - - - name: install dependencies - if: needs.should-test.outputs.yes == 'true' - run: npm ci - - # Stylelint has a GitHub workflow commands output available by default, - # so we can use that instead of needing a problem matcher. - # https://stylelint.io/user-guide/options#formatter - # https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions - - name: run stylelint + - name: lint styles if: needs.should-test.outputs.yes == 'true' - run: npm run style-lint -- -f github + uses: ./.github/actions/style-lint build-drupal-image: name: build Drupal image runs-on: ubuntu-latest needs: [should-test] - steps: - name: checkout if: needs.should-test.outputs.yes == 'true' @@ -205,12 +118,10 @@ jobs: name: populate database runs-on: ubuntu-latest needs: [build-drupal-image, should-test] - steps: - name: checkout if: needs.should-test.outputs.yes == 'true' uses: actions/checkout@v4 - - name: populate database if: needs.should-test.outputs.yes == 'true' uses: ./.github/actions/populate-database @@ -219,7 +130,6 @@ jobs: name: PHP tests runs-on: ubuntu-latest needs: [populate-database, should-test] - steps: - name: checkout if: needs.should-test.outputs.yes == 'true' @@ -271,33 +181,15 @@ jobs: needs: [populate-database, should-test] steps: - - uses: browser-actions/setup-chrome@v1 - - uses: browser-actions/setup-edge@v1 - - name: checkout if: needs.should-test.outputs.yes == 'true' uses: actions/checkout@v4 - - name: setup site if: needs.should-test.outputs.yes == 'true' uses: ./.github/actions/setup-site - - - uses: actions/setup-node@v4 + - name: run automated accessibility tests if: needs.should-test.outputs.yes == 'true' - with: - node-version: 18 - - - name: install dependencies - if: needs.should-test.outputs.yes == 'true' - run: npm ci - - - name: install browsers - if: needs.should-test.outputs.yes == 'true' - run: npx playwright install --with-deps - - - name: run tests - if: needs.should-test.outputs.yes == 'true' - run: npx playwright test a11y + uses: ./.github/actions/accessibility-tests new-end-to-end-tests: name: playwright end to end tests @@ -305,33 +197,15 @@ jobs: needs: [populate-database, should-test] steps: - - uses: browser-actions/setup-chrome@v1 - - uses: browser-actions/setup-edge@v1 - - name: checkout if: needs.should-test.outputs.yes == 'true' uses: actions/checkout@v4 - - name: setup site if: needs.should-test.outputs.yes == 'true' uses: ./.github/actions/setup-site - - - uses: actions/setup-node@v4 - if: needs.should-test.outputs.yes == 'true' - with: - node-version: 18 - - - name: install dependencies - if: needs.should-test.outputs.yes == 'true' - run: npm ci - - - name: install browsers - if: needs.should-test.outputs.yes == 'true' - run: npx playwright install --with-deps - - - name: run tests + - name: run browser tests (Playwright) if: needs.should-test.outputs.yes == 'true' - run: npx playwright test e2e/* + uses: ./.github/actions/browser-tests-playwright end-to-end-tests: name: end-to-end tests From 8a8d045af6e24bc4a6cdb1552fd25847f1909c8a Mon Sep 17 00:00:00 2001 From: Greg Walker Date: Mon, 20 May 2024 09:58:41 -0500 Subject: [PATCH 2/2] add shell --- .github/actions/accessibility-tests/action.yml | 1 + .github/actions/browser-tests-playwright/action.yml | 1 + .github/actions/javascript-component-tests/action.yml | 3 +++ .github/actions/javascript-lint/action.yml | 4 ++++ .github/actions/php-lint/action.yml | 3 +++ .github/actions/setup-playwright/action.yml | 2 ++ .github/actions/style-lint/action.yml | 2 ++ 7 files changed, 16 insertions(+) diff --git a/.github/actions/accessibility-tests/action.yml b/.github/actions/accessibility-tests/action.yml index 4bb88cede..325545510 100644 --- a/.github/actions/accessibility-tests/action.yml +++ b/.github/actions/accessibility-tests/action.yml @@ -4,4 +4,5 @@ runs: - name: prepare playwright uses: ./.github/actions/setup-playwright - name: run tests + shell: bash run: npx playwright test a11y \ No newline at end of file diff --git a/.github/actions/browser-tests-playwright/action.yml b/.github/actions/browser-tests-playwright/action.yml index e1bf232e5..beb7b881f 100644 --- a/.github/actions/browser-tests-playwright/action.yml +++ b/.github/actions/browser-tests-playwright/action.yml @@ -4,4 +4,5 @@ runs: - name: prepare playwright uses: ./.github/actions/setup-playwright - name: run tests + shell: bash run: npx playwright test e2e/* \ No newline at end of file diff --git a/.github/actions/javascript-component-tests/action.yml b/.github/actions/javascript-component-tests/action.yml index 50cf8945d..bf612f140 100644 --- a/.github/actions/javascript-component-tests/action.yml +++ b/.github/actions/javascript-component-tests/action.yml @@ -8,10 +8,13 @@ runs: cache: npm - name: install dependencies + shell: bash run: npm ci - name: install proxy dependencies + shell: bash run: cd tests/api && npm ci - name: run js-component-tests + shell: bash run: npm run js-component-tests \ No newline at end of file diff --git a/.github/actions/javascript-lint/action.yml b/.github/actions/javascript-lint/action.yml index 7165201c2..fa1407ea4 100644 --- a/.github/actions/javascript-lint/action.yml +++ b/.github/actions/javascript-lint/action.yml @@ -8,13 +8,17 @@ runs: cache: npm - name: install dependencies + shell: bash run: npm ci - name: install proxy dependencies + shell: bash run: cd tests/api && npm ci - name: add problem matcher + shell: bash run: echo "::add-matcher::${{ github.workspace }}/.github/workflows/problem-matcher-eslint.json" - name: run eslint + shell: bash run: npm run js-lint \ No newline at end of file diff --git a/.github/actions/php-lint/action.yml b/.github/actions/php-lint/action.yml index 9065ccd51..96106bf30 100644 --- a/.github/actions/php-lint/action.yml +++ b/.github/actions/php-lint/action.yml @@ -8,6 +8,7 @@ runs: - name: get composer paths id: composer-paths + shell: bash run: | echo "cache-dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT echo "bin-dir=${{ github.workspace }}/$(composer config bin-dir)" >> $GITHUB_OUTPUT @@ -21,9 +22,11 @@ runs: - name: install dependencies env: COMPOSER_NO_DEV: 0 + shell: bash run: composer install - name: run phpcs + shell: bash run: | echo "::add-matcher::${{ github.workspace }}/.github/workflows/problem-matcher-phpcs.json" vendor/bin/phpcs --report=checkstyle \ No newline at end of file diff --git a/.github/actions/setup-playwright/action.yml b/.github/actions/setup-playwright/action.yml index a00dac2a4..0dedc7024 100644 --- a/.github/actions/setup-playwright/action.yml +++ b/.github/actions/setup-playwright/action.yml @@ -7,6 +7,8 @@ runs: with: node-version: 18 - name: install dependencies + shell: bash run: npm ci - name: install browsers + shell: bash run: npx playwright install --with-deps diff --git a/.github/actions/style-lint/action.yml b/.github/actions/style-lint/action.yml index 7808da537..74f0784ce 100644 --- a/.github/actions/style-lint/action.yml +++ b/.github/actions/style-lint/action.yml @@ -8,6 +8,7 @@ runs: cache: npm - name: install dependencies + shell: bash run: npm ci # Stylelint has a GitHub workflow commands output available by default, @@ -15,4 +16,5 @@ runs: # https://stylelint.io/user-guide/options#formatter # https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions - name: run stylelint + shell: bash run: npm run style-lint -- -f github \ No newline at end of file