Unverified Commit e0a44d98 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Skip GitHub actions tests for irrelevant changes (#20867)

* Skip GitHub actions tests for irrelevant changes

* add docs lint step

* Add lint-no-typescript

* Update docs lint

* Skip at the job level

* Update steps

* remove un-needed dep

* Update compare branch

* log remotes

* output to stderr

* fetch origin

* Update fetch

* update diffing

* Update command handling

* test output

* Update check

* Log output

* Update outputs

* Add id for build job

* Update output

* Update precompiled

* remove testing check
parent 1a1c7c98
...@@ -11,11 +11,17 @@ jobs: ...@@ -11,11 +11,17 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
NEXT_TELEMETRY_DISABLED: 1 NEXT_TELEMETRY_DISABLED: 1
outputs:
docsChange: ${{ steps.docs-change.outputs.DOCS_CHANGE }}
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- run: yarn install --frozen-lockfile --check-files - run: yarn install --frozen-lockfile --check-files
- run: node run-tests.js --timings --write-timings -g 1/1 - run: node run-tests.js --timings --write-timings -g 1/1
- name: Check docs only change
run: echo ::set-output name=DOCS_CHANGE::$(node skip-docs-change.js echo 'docs-only')
id: docs-change
- run: echo ${{steps.docs-change.outputs.DOCS_CHANGE}}
- uses: actions/cache@v2 - uses: actions/cache@v2
id: cache-build id: cache-build
with: with:
...@@ -41,11 +47,13 @@ jobs: ...@@ -41,11 +47,13 @@ jobs:
NEXT_TELEMETRY_DISABLED: 1 NEXT_TELEMETRY_DISABLED: 1
steps: steps:
- uses: actions/cache@v2 - uses: actions/cache@v2
if: ${{needs.build.outputs.docsChange != 'docs-only'}}
id: restore-build id: restore-build
with: with:
path: ./* path: ./*
key: ${{ github.sha }} key: ${{ github.sha }}
- run: ./check-pre-compiled.sh - run: ./check-pre-compiled.sh
if: ${{needs.build.outputs.docsChange != 'docs-only'}}
testUnit: testUnit:
name: Test Unit name: Test Unit
...@@ -57,12 +65,14 @@ jobs: ...@@ -57,12 +65,14 @@ jobs:
HEADLESS: true HEADLESS: true
steps: steps:
- uses: actions/cache@v2 - uses: actions/cache@v2
if: ${{needs.build.outputs.docsChange != 'docs-only'}}
id: restore-build id: restore-build
with: with:
path: ./* path: ./*
key: ${{ github.sha }} key: ${{ github.sha }}
- run: node run-tests.js --timings --type unit -g 1/1 - run: node run-tests.js --timings --type unit -g 1/1
if: ${{needs.build.outputs.docsChange != 'docs-only'}}
testIntegration: testIntegration:
name: Test Integration name: Test Integration
...@@ -77,7 +87,9 @@ jobs: ...@@ -77,7 +87,9 @@ jobs:
matrix: matrix:
group: [1, 2, 3, 4, 5, 6] group: [1, 2, 3, 4, 5, 6]
steps: steps:
- run: echo ${{needs.build.outputs.docsChange}}
- uses: actions/cache@v2 - uses: actions/cache@v2
if: ${{needs.build.outputs.docsChange != 'docs-only'}}
id: restore-build id: restore-build
with: with:
path: ./* path: ./*
...@@ -85,8 +97,10 @@ jobs: ...@@ -85,8 +97,10 @@ jobs:
# TODO: remove after we fix watchpack watching too much # TODO: remove after we fix watchpack watching too much
- run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p - run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
if: ${{needs.build.outputs.docsChange != 'docs-only'}}
- run: xvfb-run node run-tests.js --timings -g ${{ matrix.group }}/6 -c 3 - run: xvfb-run node run-tests.js --timings -g ${{ matrix.group }}/6 -c 3
if: ${{needs.build.outputs.docsChange != 'docs-only'}}
testElectron: testElectron:
name: Test Electron name: Test Electron
...@@ -99,6 +113,7 @@ jobs: ...@@ -99,6 +113,7 @@ jobs:
TEST_ELECTRON: 1 TEST_ELECTRON: 1
steps: steps:
- uses: actions/cache@v2 - uses: actions/cache@v2
if: ${{needs.build.outputs.docsChange != 'docs-only'}}
id: restore-build id: restore-build
with: with:
path: ./* path: ./*
...@@ -106,10 +121,13 @@ jobs: ...@@ -106,10 +121,13 @@ jobs:
# TODO: remove after we fix watchpack watching too much # TODO: remove after we fix watchpack watching too much
- run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p - run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
if: ${{needs.build.outputs.docsChange != 'docs-only'}}
- run: yarn add -W --dev spectron@7.0.0 electron@5.0.0 - run: yarn add -W --dev spectron@7.0.0 electron@5.0.0
if: ${{needs.build.outputs.docsChange != 'docs-only'}}
- run: xvfb-run node run-tests.js test/integration/with-electron/test/index.test.js - run: xvfb-run node run-tests.js test/integration/with-electron/test/index.test.js
if: ${{needs.build.outputs.docsChange != 'docs-only'}}
testYarnPnP: testYarnPnP:
runs-on: ubuntu-latest runs-on: ubuntu-latest
...@@ -119,9 +137,14 @@ jobs: ...@@ -119,9 +137,14 @@ jobs:
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- run: echo ::set-output name=DOCS_CHANGE::$(node skip-docs-change.js echo 'docs-only')
id: docs-change
- run: yarn install --frozen-lockfile --check-files - run: yarn install --frozen-lockfile --check-files
if: ${{steps.docs-change.outputs.DOCS_CHANGE != 'docs-only'}}
- run: bash ./test-pnp.sh - run: bash ./test-pnp.sh
if: ${{steps.docs-change.outputs.DOCS_CHANGE != 'docs-only'}}
testsPass: testsPass:
name: thank you, next name: thank you, next
...@@ -140,13 +163,30 @@ jobs: ...@@ -140,13 +163,30 @@ jobs:
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- run: echo ::set-output name=DOCS_CHANGE::$(node skip-docs-change.js echo 'docs-only')
id: docs-change
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs-only' }}
- run: cat package.json | jq '.resolutions.webpack = "^5.11.1"' > package.json.tmp && mv package.json.tmp package.json - run: cat package.json | jq '.resolutions.webpack = "^5.11.1"' > package.json.tmp && mv package.json.tmp package.json
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs-only' }}
- run: cat package.json | jq '.resolutions.react = "^17.0.1"' > package.json.tmp && mv package.json.tmp package.json - run: cat package.json | jq '.resolutions.react = "^17.0.1"' > package.json.tmp && mv package.json.tmp package.json
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs-only' }}
- run: cat package.json | jq '.resolutions."react-dom" = "^17.0.1"' > package.json.tmp && mv package.json.tmp package.json - run: cat package.json | jq '.resolutions."react-dom" = "^17.0.1"' > package.json.tmp && mv package.json.tmp package.json
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs-only' }}
- run: yarn install --check-files - run: yarn install --check-files
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs-only' }}
- run: yarn list webpack react react-dom - run: yarn list webpack react react-dom
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs-only' }}
- run: xvfb-run node run-tests.js test/integration/{link-ref,production,basic,async-modules,font-optimization,ssr-ctx}/test/index.test.js test/acceptance/*.test.js - run: xvfb-run node run-tests.js test/integration/{link-ref,production,basic,async-modules,font-optimization,ssr-ctx}/test/index.test.js test/acceptance/*.test.js
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs-only' }}
testFirefox: testFirefox:
name: Test Firefox (production) name: Test Firefox (production)
...@@ -158,11 +198,13 @@ jobs: ...@@ -158,11 +198,13 @@ jobs:
NEXT_TELEMETRY_DISABLED: 1 NEXT_TELEMETRY_DISABLED: 1
steps: steps:
- uses: actions/cache@v2 - uses: actions/cache@v2
if: ${{needs.build.outputs.docsChange != 'docs-only'}}
id: restore-build id: restore-build
with: with:
path: ./* path: ./*
key: ${{ github.sha }} key: ${{ github.sha }}
- run: node run-tests.js test/integration/production/test/index.test.js - run: node run-tests.js test/integration/production/test/index.test.js
if: ${{needs.build.outputs.docsChange != 'docs-only'}}
testSafari: testSafari:
name: Test Safari (production) name: Test Safari (production)
...@@ -177,11 +219,13 @@ jobs: ...@@ -177,11 +219,13 @@ jobs:
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
steps: steps:
- uses: actions/cache@v2 - uses: actions/cache@v2
if: ${{needs.build.outputs.docsChange != 'docs-only'}}
id: restore-build id: restore-build
with: with:
path: ./* path: ./*
key: ${{ github.sha }} key: ${{ github.sha }}
- run: '[[ -z "$BROWSERSTACK_ACCESS_KEY" ]] && echo "Skipping for PR" || node run-tests.js test/integration/production/test/index.test.js' - run: '[[ -z "$BROWSERSTACK_ACCESS_KEY" ]] && echo "Skipping for PR" || node run-tests.js test/integration/production/test/index.test.js'
if: ${{needs.build.outputs.docsChange != 'docs-only'}}
testSafariOld: testSafariOld:
name: Test Safari 10.1 (nav) name: Test Safari 10.1 (nav)
...@@ -197,11 +241,13 @@ jobs: ...@@ -197,11 +241,13 @@ jobs:
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
steps: steps:
- uses: actions/cache@v2 - uses: actions/cache@v2
if: ${{needs.build.outputs.docsChange != 'docs-only'}}
id: restore-build id: restore-build
with: with:
path: ./* path: ./*
key: ${{ github.sha }} key: ${{ github.sha }}
- run: '[[ -z "$BROWSERSTACK_ACCESS_KEY" ]] && echo "Skipping for PR" || node run-tests.js test/integration/production-nav/test/index.test.js' - run: '[[ -z "$BROWSERSTACK_ACCESS_KEY" ]] && echo "Skipping for PR" || node run-tests.js test/integration/production-nav/test/index.test.js'
if: ${{needs.build.outputs.docsChange != 'docs-only'}}
publishRelease: publishRelease:
name: Potentially publish release name: Potentially publish release
......
...@@ -10,4 +10,7 @@ jobs: ...@@ -10,4 +10,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- run: echo ::set-output name=DOCS_CHANGE::$(node skip-docs-change.js echo 'docs-only')
id: docs-change
- uses: ./.github/actions/next-stats-action - uses: ./.github/actions/next-stats-action
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs-only' }}
on: on:
push: push:
branches: [canary] branches: [canary]
paths-ignore:
- 'bench/**'
- 'docs/**'
- 'errors/**'
- 'examples/**'
name: Test macOS name: Test macOS
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
"test": "yarn run testall || yarn run test-take2", "test": "yarn run testall || yarn run test-take2",
"lint-typescript": "lerna run typescript", "lint-typescript": "lerna run typescript",
"lint-eslint": "eslint . --ext js,jsx,ts,tsx --max-warnings=0", "lint-eslint": "eslint . --ext js,jsx,ts,tsx --max-warnings=0",
"lint-no-typescript": "run-p prettier-check lint-eslint",
"lint": "run-p lint-typescript prettier-check lint-eslint", "lint": "run-p lint-typescript prettier-check lint-eslint",
"lint-fix": "yarn prettier-fix && eslint . --ext js,jsx,ts,tsx --fix --max-warnings=0", "lint-fix": "yarn prettier-fix && eslint . --ext js,jsx,ts,tsx --fix --max-warnings=0",
"prettier-check": "prettier --check .", "prettier-check": "prettier --check .",
......
const { promisify } = require('util')
const { exec: execOrig, spawn } = require('child_process')
const exec = promisify(execOrig)
const DOCS_FOLDERS = ['bench', 'docs', 'errors', 'examples']
async function main() {
await exec('git fetch origin canary')
const { stdout: changedFilesOutput } = await exec(
'git diff $(git merge-base --fork-point canary) --name-only'
)
const changedFiles = changedFilesOutput
.split('\n')
.map((file) => file && file.trim())
.filter(Boolean)
let hasNonDocsChange = changedFiles.some((file) => {
return !DOCS_FOLDERS.some((folder) => file.startsWith(folder + '/'))
})
const args = process.argv.slice(process.argv.indexOf(__filename) + 1)
if (args.length === 0) {
console.log(process.argv, args)
console.log('no script provided, exiting...')
}
if (hasNonDocsChange) {
const cmd = spawn(args[0], args.slice(1))
cmd.stdout.pipe(process.stdout)
cmd.stderr.pipe(process.stderr)
await new Promise((resolve, reject) => {
cmd.on('exit', (code) => {
if (code !== 0) {
return reject(new Error('command failed with code: ' + code))
}
resolve()
})
cmd.on('error', (err) => reject(err))
})
} else {
console.log('Only docs changes exiting...')
}
}
main().catch((err) => {
console.error('Failed to detect doc changes', err)
process.exit(1)
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment