Skip to content

Commit

Permalink
Merge pull request #1225 from weather-gov/mgwalker/composite-actions
Browse files Browse the repository at this point in the history
Split tests into composite actions
  • Loading branch information
greg-does-weather committed May 20, 2024
2 parents a6a1ae7 + 5dc2764 commit f60427f
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 138 deletions.
8 changes: 8 additions & 0 deletions .github/actions/accessibility-tests/action.yml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions .github/actions/browser-tests-playwright/action.yml
Original file line number Diff line number Diff line change
@@ -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/*
20 changes: 20 additions & 0 deletions .github/actions/javascript-component-tests/action.yml
Original file line number Diff line number Diff line change
@@ -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
24 changes: 24 additions & 0 deletions .github/actions/javascript-lint/action.yml
Original file line number Diff line number Diff line change
@@ -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
32 changes: 32 additions & 0 deletions .github/actions/php-lint/action.yml
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions .github/actions/setup-playwright/action.yml
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions .github/actions/style-lint/action.yml
Original file line number Diff line number Diff line change
@@ -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
150 changes: 12 additions & 138 deletions .github/workflows/code-standards.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand All @@ -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
Expand All @@ -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'
Expand Down Expand Up @@ -271,67 +181,31 @@ 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
runs-on: ubuntu-latest
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
Expand Down

0 comments on commit f60427f

Please sign in to comment.