diff --git a/.github/actions/accessibility-tests/action.yml b/.github/actions/accessibility-tests/action.yml new file mode 100644 index 000000000..325545510 --- /dev/null +++ b/.github/actions/accessibility-tests/action.yml @@ -0,0 +1,8 @@ +runs: + using: composite + steps: + - 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 new file mode 100644 index 000000000..beb7b881f --- /dev/null +++ b/.github/actions/browser-tests-playwright/action.yml @@ -0,0 +1,8 @@ +runs: + using: composite + steps: + - 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 new file mode 100644 index 000000000..bf612f140 --- /dev/null +++ b/.github/actions/javascript-component-tests/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 + 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 new file mode 100644 index 000000000..fa1407ea4 --- /dev/null +++ b/.github/actions/javascript-lint/action.yml @@ -0,0 +1,24 @@ +runs: + using: composite + steps: + - name: setup node + uses: actions/setup-node@v4 + with: + node-version: 20 + 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 new file mode 100644 index 000000000..96106bf30 --- /dev/null +++ b/.github/actions/php-lint/action.yml @@ -0,0 +1,32 @@ +runs: + using: composite + steps: + - name: setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: "8.2" + + - 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 + + - 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 + 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 new file mode 100644 index 000000000..0dedc7024 --- /dev/null +++ b/.github/actions/setup-playwright/action.yml @@ -0,0 +1,14 @@ +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 + 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 new file mode 100644 index 000000000..74f0784ce --- /dev/null +++ b/.github/actions/style-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 + shell: bash + 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 + shell: bash + 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