From 754d53f97340c132e395d6c73033535bd790f8e8 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Mon, 25 Jan 2021 13:17:26 -0600 Subject: [PATCH 1/6] Fix docs only check for CI --- .github/workflows/build_test_deploy.yml | 64 ++++++++++++------------ .github/workflows/pull_request_stats.yml | 4 +- skip-docs-change.js | 2 +- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/.github/workflows/build_test_deploy.yml b/.github/workflows/build_test_deploy.yml index 8c9cbae0f0e9f..1c963d45345d8 100644 --- a/.github/workflows/build_test_deploy.yml +++ b/.github/workflows/build_test_deploy.yml @@ -19,7 +19,7 @@ jobs: - run: yarn install --frozen-lockfile --check-files - 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') + run: echo ::set-output name=DOCS_CHANGE::$(node skip-docs-change.js echo 'not-docs-only-change') id: docs-change - run: echo ${{steps.docs-change.outputs.DOCS_CHANGE}} - uses: actions/cache@v2 @@ -47,13 +47,13 @@ jobs: NEXT_TELEMETRY_DISABLED: 1 steps: - uses: actions/cache@v2 - if: ${{needs.build.outputs.docsChange != 'docs-only'}} + if: ${{needs.build.outputs.docsChange != 'docs only change'}} id: restore-build with: path: ./* key: ${{ github.sha }} - run: ./check-pre-compiled.sh - if: ${{needs.build.outputs.docsChange != 'docs-only'}} + if: ${{needs.build.outputs.docsChange != 'docs only change'}} testUnit: name: Test Unit @@ -65,14 +65,14 @@ jobs: HEADLESS: true steps: - uses: actions/cache@v2 - if: ${{needs.build.outputs.docsChange != 'docs-only'}} + if: ${{needs.build.outputs.docsChange != 'docs only change'}} id: restore-build with: path: ./* key: ${{ github.sha }} - run: node run-tests.js --timings --type unit -g 1/1 - if: ${{needs.build.outputs.docsChange != 'docs-only'}} + if: ${{needs.build.outputs.docsChange != 'docs only change'}} testIntegration: name: Test Integration @@ -89,7 +89,7 @@ jobs: steps: - run: echo ${{needs.build.outputs.docsChange}} - uses: actions/cache@v2 - if: ${{needs.build.outputs.docsChange != 'docs-only'}} + if: ${{needs.build.outputs.docsChange != 'docs only change'}} id: restore-build with: path: ./* @@ -97,10 +97,10 @@ jobs: # 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 - if: ${{needs.build.outputs.docsChange != 'docs-only'}} + if: ${{needs.build.outputs.docsChange != 'docs only change'}} - run: xvfb-run node run-tests.js --timings -g ${{ matrix.group }}/6 -c 3 - if: ${{needs.build.outputs.docsChange != 'docs-only'}} + if: ${{needs.build.outputs.docsChange != 'docs only change'}} testElectron: name: Test Electron @@ -113,7 +113,7 @@ jobs: TEST_ELECTRON: 1 steps: - uses: actions/cache@v2 - if: ${{needs.build.outputs.docsChange != 'docs-only'}} + if: ${{needs.build.outputs.docsChange != 'docs only change'}} id: restore-build with: path: ./* @@ -121,13 +121,13 @@ jobs: # 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 - if: ${{needs.build.outputs.docsChange != 'docs-only'}} + if: ${{needs.build.outputs.docsChange != 'docs only change'}} - run: yarn add -W --dev spectron@7.0.0 electron@5.0.0 - if: ${{needs.build.outputs.docsChange != 'docs-only'}} + if: ${{needs.build.outputs.docsChange != 'docs only change'}} - run: xvfb-run node run-tests.js test/integration/with-electron/test/index.test.js - if: ${{needs.build.outputs.docsChange != 'docs-only'}} + if: ${{needs.build.outputs.docsChange != 'docs only change'}} testYarnPnP: runs-on: ubuntu-latest @@ -137,14 +137,14 @@ jobs: steps: - uses: actions/checkout@v2 - - run: echo ::set-output name=DOCS_CHANGE::$(node skip-docs-change.js echo 'docs-only') + - run: echo ::set-output name=DOCS_CHANGE::$(node skip-docs-change.js echo 'not-docs-only-change') id: docs-change - run: yarn install --frozen-lockfile --check-files - if: ${{steps.docs-change.outputs.DOCS_CHANGE != 'docs-only'}} + if: ${{steps.docs-change.outputs.DOCS_CHANGE != 'docs only change'}} - run: bash ./test-pnp.sh - if: ${{steps.docs-change.outputs.DOCS_CHANGE != 'docs-only'}} + if: ${{steps.docs-change.outputs.DOCS_CHANGE != 'docs only change'}} testsPass: name: thank you, next @@ -165,17 +165,17 @@ jobs: steps: - uses: actions/checkout@v2 - - run: echo ::set-output name=DOCS_CHANGE::$(node skip-docs-change.js echo 'docs-only') + - run: echo ::set-output name=DOCS_CHANGE::$(node skip-docs-change.js echo 'not-docs-only-change') id: docs-change - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* - if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs-only' }} + if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }} - run: yarn install --check-files - if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs-only' }} + if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }} - 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' }} + if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }} testLegacyReact: name: React 16 + Webpack 4 (Basic, Production, Acceptance) @@ -188,26 +188,26 @@ jobs: steps: - uses: actions/checkout@v2 - - run: echo ::set-output name=DOCS_CHANGE::$(node skip-docs-change.js echo 'docs-only') + - run: echo ::set-output name=DOCS_CHANGE::$(node skip-docs-change.js echo 'not-docs-only-change') id: docs-change - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* - if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs-only' }} + if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }} - run: cat package.json | jq '.resolutions.react = "^16.14.0"' > package.json.tmp && mv package.json.tmp package.json - if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs-only' }} + if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }} - run: cat package.json | jq '.resolutions."react-dom" = "^16.14.0"' > package.json.tmp && mv package.json.tmp package.json - if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs-only' }} + if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }} - run: yarn install --check-files - if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs-only' }} + if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }} - run: yarn list react react-dom - if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs-only' }} + if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }} - run: xvfb-run node run-tests.js test/integration/{link-ref,production,basic,async-modules,font-optimization,ssr-ctx,worker-loader}/test/index.test.js test/acceptance/*.test.js - if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs-only' }} + if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }} testFirefox: name: Test Firefox (production) @@ -219,13 +219,13 @@ jobs: NEXT_TELEMETRY_DISABLED: 1 steps: - uses: actions/cache@v2 - if: ${{needs.build.outputs.docsChange != 'docs-only'}} + if: ${{needs.build.outputs.docsChange != 'docs only change'}} id: restore-build with: path: ./* key: ${{ github.sha }} - run: node run-tests.js test/integration/production/test/index.test.js - if: ${{needs.build.outputs.docsChange != 'docs-only'}} + if: ${{needs.build.outputs.docsChange != 'docs only change'}} testSafari: name: Test Safari (production) @@ -240,13 +240,13 @@ jobs: BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} steps: - uses: actions/cache@v2 - if: ${{needs.build.outputs.docsChange != 'docs-only'}} + if: ${{needs.build.outputs.docsChange != 'docs only change'}} id: restore-build with: path: ./* key: ${{ github.sha }} - 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'}} + if: ${{needs.build.outputs.docsChange != 'docs only change'}} testSafariOld: name: Test Safari 10.1 (nav) @@ -262,13 +262,13 @@ jobs: BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} steps: - uses: actions/cache@v2 - if: ${{needs.build.outputs.docsChange != 'docs-only'}} + if: ${{needs.build.outputs.docsChange != 'docs only change'}} id: restore-build with: path: ./* key: ${{ github.sha }} - 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'}} + if: ${{needs.build.outputs.docsChange != 'docs only change'}} publishRelease: name: Potentially publish release diff --git a/.github/workflows/pull_request_stats.yml b/.github/workflows/pull_request_stats.yml index 243138f438bea..93a7651faf7f6 100644 --- a/.github/workflows/pull_request_stats.yml +++ b/.github/workflows/pull_request_stats.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - run: echo ::set-output name=DOCS_CHANGE::$(node skip-docs-change.js echo 'docs-only') + - run: echo ::set-output name=DOCS_CHANGE::$(node skip-docs-change.js echo 'not-docs-only-change') id: docs-change - uses: ./.github/actions/next-stats-action - if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs-only' }} + if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }} diff --git a/skip-docs-change.js b/skip-docs-change.js index acc5285a09f9e..a7785c17add8f 100644 --- a/skip-docs-change.js +++ b/skip-docs-change.js @@ -41,7 +41,7 @@ async function main() { cmd.on('error', (err) => reject(err)) }) } else { - console.log('Only docs changes exiting...') + console.log('docs only change') } } From 36d7becdbf0003fd9507c29a85530133a6c34b75 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Mon, 25 Jan 2021 13:34:08 -0600 Subject: [PATCH 2/6] log changed files --- skip-docs-change.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/skip-docs-change.js b/skip-docs-change.js index a7785c17add8f..388f945ca3a90 100644 --- a/skip-docs-change.js +++ b/skip-docs-change.js @@ -15,6 +15,8 @@ async function main() { .map((file) => file && file.trim()) .filter(Boolean) + console.log(changedFiles) + let hasNonDocsChange = changedFiles.some((file) => { return !DOCS_FOLDERS.some((folder) => file.startsWith(folder + '/')) }) From 5a3e95d9bd72459ff0e13be505c2d0a97713fcf6 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Mon, 25 Jan 2021 13:41:39 -0600 Subject: [PATCH 3/6] update diff check --- skip-docs-change.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skip-docs-change.js b/skip-docs-change.js index 388f945ca3a90..f5d411f2a54ba 100644 --- a/skip-docs-change.js +++ b/skip-docs-change.js @@ -8,7 +8,7 @@ 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' + 'git diff origin/canary --name-only' ) const changedFiles = changedFilesOutput .split('\n') From 4996289690505a66b3bdf0288547097e4131c29c Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Mon, 25 Jan 2021 13:48:37 -0600 Subject: [PATCH 4/6] add more logs --- skip-docs-change.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/skip-docs-change.js b/skip-docs-change.js index f5d411f2a54ba..c2c698cfda72b 100644 --- a/skip-docs-change.js +++ b/skip-docs-change.js @@ -7,6 +7,10 @@ const DOCS_FOLDERS = ['bench', 'docs', 'errors', 'examples'] async function main() { await exec('git fetch origin canary') + + console.log(await exec('git branch')) + console.log(await exec('git remote -v')) + const { stdout: changedFilesOutput } = await exec( 'git diff origin/canary --name-only' ) From 6c65e56b60a4da3000bb0f262360b52ba5888339 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Mon, 25 Jan 2021 13:53:33 -0600 Subject: [PATCH 5/6] remove logs --- skip-docs-change.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/skip-docs-change.js b/skip-docs-change.js index c2c698cfda72b..4bfeddaf2b920 100644 --- a/skip-docs-change.js +++ b/skip-docs-change.js @@ -8,9 +8,6 @@ const DOCS_FOLDERS = ['bench', 'docs', 'errors', 'examples'] async function main() { await exec('git fetch origin canary') - console.log(await exec('git branch')) - console.log(await exec('git remote -v')) - const { stdout: changedFilesOutput } = await exec( 'git diff origin/canary --name-only' ) @@ -19,8 +16,6 @@ async function main() { .map((file) => file && file.trim()) .filter(Boolean) - console.log(changedFiles) - let hasNonDocsChange = changedFiles.some((file) => { return !DOCS_FOLDERS.some((folder) => file.startsWith(folder + '/')) }) From 36b77583488f0d5a464d80f3dcda54f8ef297085 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Mon, 25 Jan 2021 13:58:05 -0600 Subject: [PATCH 6/6] Don't treat as docs only change when diff returns no changes --- skip-docs-change.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/skip-docs-change.js b/skip-docs-change.js index 4bfeddaf2b920..76f50745e24b1 100644 --- a/skip-docs-change.js +++ b/skip-docs-change.js @@ -16,9 +16,11 @@ async function main() { .map((file) => file && file.trim()) .filter(Boolean) - let hasNonDocsChange = changedFiles.some((file) => { - return !DOCS_FOLDERS.some((folder) => file.startsWith(folder + '/')) - }) + let hasNonDocsChange = + !changedFiles.length || + changedFiles.some((file) => { + return !DOCS_FOLDERS.some((folder) => file.startsWith(folder + '/')) + }) const args = process.argv.slice(process.argv.indexOf(__filename) + 1)