From e097e8835dd8fdeeb01f37ecb94907239c45ff72 Mon Sep 17 00:00:00 2001 From: Chiedo John <2156688+chiedo@users.noreply.github.com> Date: Wed, 14 Oct 2020 10:43:31 -0400 Subject: [PATCH 1/2] Support manual workflow runs for tests and browser tests (#16031) Co-authored-by: Chiedo --- .github/workflows/browser-test.yml | 6 ++++-- .github/workflows/test.yml | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/browser-test.yml b/.github/workflows/browser-test.yml index d4dca92239a8..3e90da57c61f 100644 --- a/.github/workflows/browser-test.yml +++ b/.github/workflows/browser-test.yml @@ -1,6 +1,8 @@ name: Browser Tests -on: [push] +on: + workflow_dispatch: + push: jobs: build: @@ -15,4 +17,4 @@ jobs: - name: Test uses: ianwalter/puppeteer@3.0.0 with: - args: npm run browser-test \ No newline at end of file + args: npm run browser-test diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ddfde7bbed7d..92feeb1b215d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,6 +3,7 @@ name: Node.js Tests on: + workflow_dispatch: push: branches: - main @@ -89,4 +90,4 @@ jobs: if: failure() && github.ref == 'early-access' env: SLACK_WEBHOOK: ${{ secrets.DOCS_ALERTS_SLACK_WEBHOOK }} - SLACK_MESSAGE: "Tests are failing on the `early-access` branch. https://github.com/github/docs-internal/tree/early-access" \ No newline at end of file + SLACK_MESSAGE: "Tests are failing on the `early-access` branch. https://github.com/github/docs-internal/tree/early-access" From c76bf47ea566f47e62e50abe454e078acb8c7a3c Mon Sep 17 00:00:00 2001 From: Chiedo John <2156688+chiedo@users.noreply.github.com> Date: Wed, 14 Oct 2020 12:57:45 -0400 Subject: [PATCH 2/2] Attempt to reduce uneeded test runs (#16015) * 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 Co-authored-by: Jason Etcovitch --- .github/allowed-actions.js | 1 + .github/workflows/browser-test.yml | 26 +++++++++++-- .github/workflows/pa11y.yml | 5 ++- .github/workflows/test.yml | 61 ++++++++++++++++++++++-------- 4 files changed, 74 insertions(+), 19 deletions(-) diff --git a/.github/allowed-actions.js b/.github/allowed-actions.js index 4d60d0feb677..bc4f94974250 100644 --- a/.github/allowed-actions.js +++ b/.github/allowed-actions.js @@ -18,6 +18,7 @@ module.exports = [ 'crowdin/github-action@1.0.10', '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/puppeteer@3.0.0', diff --git a/.github/workflows/browser-test.yml b/.github/workflows/browser-test.yml index 3e90da57c61f..91a7905d73c5 100644 --- a/.github/workflows/browser-test.yml +++ b/.github/workflows/browser-test.yml @@ -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/puppeteer@3.0.0 with: args: npm ci - - name: Test + + - if: ${{ needs.see_if_should_skip.outputs.should_skip == 'false' }} + name: Test uses: ianwalter/puppeteer@3.0.0 with: args: npm run browser-test diff --git a/.github/workflows/pa11y.yml b/.github/workflows/pa11y.yml index 68b3d6542124..8f2ed17b0481 100644 --- a/.github/workflows/pa11y.yml +++ b/.github/workflows/pa11y.yml @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 92feeb1b215d..4b0e9cec9932 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,23 +15,42 @@ 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 }} @@ -39,36 +58,45 @@ jobs: 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 }} @@ -76,13 +104,16 @@ jobs: 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