Skip to content

Commit

Permalink
Attempt to reduce uneeded test runs (github#16015)
Browse files Browse the repository at this point in the history
* Reduce unneeded test runs

- Attempt to make the skip logic work w/ required checks
- Move pa11y to cron schedule
- Make browser test conditional

Co-authored-by: Zeke Sikelianos <[email protected]>
Co-authored-by: Jason Etcovitch <[email protected]>
  • Loading branch information
3 people authored Oct 14, 2020
1 parent e097e88 commit c76bf47
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 19 deletions.
1 change: 1 addition & 0 deletions .github/allowed-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module.exports = [
'crowdin/[email protected]',
'dawidd6/action-delete-branch@v3',
'docker://chinthakagodawita/autoupdate-action:v1',
'fkirc/skip-duplicate-actions@a12175f6209d4805b5a163d723270be2a0dc7b36',
'github/codeql-action/analyze@v1',
'github/codeql-action/init@v1',
'ianwalter/[email protected]',
Expand Down
26 changes: 23 additions & 3 deletions .github/workflows/browser-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,36 @@ on:
push:

jobs:
see_if_should_skip:
runs-on: ubuntu-latest
# Map a step output to a job output
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@a12175f6209d4805b5a163d723270be2a0dc7b36
with:
cancel_others: 'false'
github_token: ${{ github.token }}
paths: '["assets/**", "content/**", "data/**", "includes/**", "javascripts/**", "jest-puppeteer.config.js", "jest.config.js", "layouts/**", "lib/**", "middleware/**", "package-lock.json", "package.json", "server.js", "translations/**", "webpack.config.js"]'
build:
needs: see_if_should_skip
runs-on: ubuntu-latest
steps:
- name: Checkout
# Each of these ifs needs to be repeated at each step to make sure the required check still runs
# Even if if doesn't do anything
- if: ${{ needs.see_if_should_skip.outputs.should_skip == 'false' }}
name: Checkout
uses: actions/checkout@v2
- name: Install

- if: ${{ needs.see_if_should_skip.outputs.should_skip == 'false' }}
name: Install
uses: ianwalter/[email protected]
with:
args: npm ci
- name: Test

- if: ${{ needs.see_if_should_skip.outputs.should_skip == 'false' }}
name: Test
uses: ianwalter/[email protected]
with:
args: npm run browser-test
5 changes: 4 additions & 1 deletion .github/workflows/pa11y.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: "Pa11y"
on: [push]
on:
workflow_dispatch:
schedule:
- cron: "25 17 * * *" # once a day at 17:25 UTC / 11:50 PST
jobs:
test:
runs-on: ubuntu-latest
Expand Down
61 changes: 46 additions & 15 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,74 +15,105 @@ env:
CI: true

jobs:
see_if_should_skip:
runs-on: ubuntu-latest
# Map a step output to a job output
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@a12175f6209d4805b5a163d723270be2a0dc7b36
with:
cancel_others: 'false'
github_token: ${{ github.token }}
paths_ignore: '[".all-contributorsrc", ".env.example", ".gitattributes", ".vscode/**", "app.json", "assets/**", "CODE_OF_CONDUCT.md", "CONTRIBUTING.md", "contributing/**", "crowdin-actions-config.yml", "crowdin.yml", "docs", "javascripts/**", "jest-puppeteer.config.js", "LICENSE-CODE", "LICENSE", "nodemon.json", "ownership.yaml", "README.md", "script/**", "stylesheets/**"]'
lint:
needs: see_if_should_skip
runs-on: ubuntu-latest
steps:
- name: Check out repo
# Each of these ifs needs to be repeated at each step to make sure the required check still runs
# Even if if doesn't do anything
- if: ${{ needs.see_if_should_skip.outputs.should_skip == 'false' }}
name: Check out repo
uses: actions/checkout@v2

- name: Setup node
- if: ${{ needs.see_if_should_skip.outputs.should_skip == 'false' }}
name: Setup node
uses: actions/setup-node@v1
with:
node-version: 14.x

- name: Get npm cache directory
- if: ${{ needs.see_if_should_skip.outputs.should_skip == 'false' }}
name: Get npm cache directory
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"
- name: Cache node modules
- if: ${{ needs.see_if_should_skip.outputs.should_skip == 'false' }}
name: Cache node modules
uses: actions/cache@v2
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
- if: ${{ needs.see_if_should_skip.outputs.should_skip == 'false' }}
name: Install dependencies
run: npm ci

- name: Run linter
- if: ${{ needs.see_if_should_skip.outputs.should_skip == 'false' }}
name: Run linter
run: npx standard

- name: Check dependencies
- if: ${{ needs.see_if_should_skip.outputs.should_skip == 'false' }}
name: Check dependencies
run: npm run check-deps

test:
needs: see_if_should_skip
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
test-group: [content, meta, rendering, routing, unit, links-and-images]
steps:
- name: Check out repo
# Each of these ifs needs to be repeated at each step to make sure the required check still runs
# Even if if doesn't do anything
- if: ${{ needs.see_if_should_skip.outputs.should_skip == 'false' }}
name: Check out repo
uses: actions/checkout@v2

- name: Setup node
- if: ${{ needs.see_if_should_skip.outputs.should_skip == 'false' }}
name: Setup node
uses: actions/setup-node@v1
with:
node-version: 14.x

- name: Get npm cache directory
- if: ${{ needs.see_if_should_skip.outputs.should_skip == 'false' }}
name: Get npm cache directory
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"
- name: Cache node modules
- if: ${{ needs.see_if_should_skip.outputs.should_skip == 'false' }}
name: Cache node modules
uses: actions/cache@v2
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
- if: ${{ needs.see_if_should_skip.outputs.should_skip == 'false' }}
name: Install dependencies
run: npm ci

- name: Run build script
- if: ${{ needs.see_if_should_skip.outputs.should_skip == 'false' }}
name: Run build script
run: npm run build

- name: Run tests
- if: ${{ needs.see_if_should_skip.outputs.should_skip == 'false' }}
name: Run tests
run: npx jest tests/${{ matrix.test-group }}/

- name: Send Slack notification if workflow fails
Expand Down

0 comments on commit c76bf47

Please sign in to comment.