From 15401ef00c6795246d6fbd069b5d6b9a60c1ebce Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Mon, 13 Jan 2025 20:37:21 -0800 Subject: [PATCH] Update CI config for Windows runner --- .github/workflows/build_and_test.yml | 98 +++++++++++++- .github/workflows/build_reusable.yml | 21 +-- azure-pipelines.yml | 184 --------------------------- 3 files changed, 109 insertions(+), 194 deletions(-) delete mode 100644 azure-pipelines.yml diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 75042104433bc..f750f6c673c65 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -72,6 +72,17 @@ jobs: stepName: 'build-native' secrets: inherit + build-native-windows: + name: build-native-windows + uses: ./.github/workflows/build_reusable.yml + with: + skipInstallBuild: 'yes' + stepName: 'build-native-windows' + runs_on_labels: '["windows","self-hosted","x64"]' + buildNativeTarget: 'x86_64-pc-windows-msvc' + + secrets: inherit + build-next: name: build-next uses: ./.github/workflows/build_reusable.yml @@ -201,8 +212,6 @@ jobs: name: test devlow package needs: ['optimize-ci', 'changes'] if: ${{ needs.optimize-ci.outputs.skip == 'false' && needs.changes.outputs.docs-only == 'false' }} - strategy: - fail-fast: false uses: ./.github/workflows/build_reusable.yml with: stepName: 'test-devlow' @@ -336,6 +345,26 @@ jobs: secrets: inherit + test-unit-windows: + name: test unit windows + needs: ['changes', 'build-native', 'build-native-windows'] + if: ${{ needs.changes.outputs.docs-only == 'false' }} + + strategy: + fail-fast: false + matrix: + node: [18, 20] # TODO: use env var like [env.NODE_MAINTENANCE_VERSION, env.NODE_LTS_VERSION] + + uses: ./.github/workflows/build_reusable.yml + with: + nodeVersion: ${{ matrix.node }} + afterBuild: node run-tests.js -c ${TEST_CONCURRENCY} --type unit + stepName: 'test-unit-windows-${{ matrix.node }}' + runs_on_labels: '["windows","self-hosted","x64"]' + buildNativeTarget: 'x86_64-pc-windows-msvc' + + secrets: inherit + test-new-tests-dev: name: Test new tests for flakes (dev) needs: ['optimize-ci', 'changes', 'build-native', 'build-next'] @@ -408,6 +437,67 @@ jobs: stepName: 'test-dev-react-${{ matrix.react }}-${{ matrix.group }}' secrets: inherit + test-dev-windows: + name: test dev windows + needs: + [ + 'optimize-ci', + 'changes', + 'build-native-windows', + 'build-native', + 'build-next', + ] + if: ${{ needs.optimize-ci.outputs.skip == 'false' && needs.changes.outputs.docs-only == 'false' }} + + uses: ./.github/workflows/build_reusable.yml + with: + afterBuild: NEXT_TEST_MODE=dev node run-tests.js -c ${TEST_CONCURRENCY} test/e2e/app-dir/app/index.test.ts test/e2e/app-dir/app-edge/app-edge.test.ts + stepName: 'test-dev-windows' + runs_on_labels: '["windows","self-hosted","x64"]' + buildNativeTarget: 'x86_64-pc-windows-msvc' + secrets: inherit + + test-integration-windows: + name: test integration windows + needs: + [ + 'optimize-ci', + 'changes', + 'build-native-windows', + 'build-native', + 'build-next', + ] + if: ${{ needs.optimize-ci.outputs.skip == 'false' && needs.changes.outputs.docs-only == 'false' }} + + uses: ./.github/workflows/build_reusable.yml + with: + nodeVersion: 18.18.2 + afterBuild: node run-tests.js -c 4 test/production/pages-dir/production/test/index.test.ts test/integration/css-client-nav/test/index.test.js test/integration/rewrites-has-condition/test/index.test.js test/integration/create-next-app/index.test.ts test/integration/create-next-app/package-manager/pnpm.test.ts + stepName: 'test-integration-windows' + runs_on_labels: '["windows","self-hosted","x64"]' + buildNativeTarget: 'x86_64-pc-windows-msvc' + secrets: inherit + + test-prod-windows: + name: test prod windows + needs: + [ + 'optimize-ci', + 'changes', + 'build-native-windows', + 'build-native', + 'build-next', + ] + if: ${{ needs.optimize-ci.outputs.skip == 'false' && needs.changes.outputs.docs-only == 'false' }} + + uses: ./.github/workflows/build_reusable.yml + with: + afterBuild: NEXT_TEST_MODE=start node run-tests.js test/e2e/app-dir/app/index.test.ts test/e2e/app-dir/app-edge/app-edge.test.ts + stepName: 'test-prod-windows' + runs_on_labels: '["windows","self-hosted","x64"]' + buildNativeTarget: 'x86_64-pc-windows-msvc' + secrets: inherit + test-prod: name: test prod needs: ['optimize-ci', 'changes', 'build-native', 'build-next'] @@ -589,6 +679,10 @@ jobs: 'test-new-tests-deploy', 'test-turbopack-production', 'test-turbopack-production-integration', + 'test-unit-windows', + 'test-dev-windows', + 'test-integration-windows', + 'test-prod-windows', ] if: always() diff --git a/.github/workflows/build_reusable.yml b/.github/workflows/build_reusable.yml index 67cc37549c303..00ab4078627cb 100644 --- a/.github/workflows/build_reusable.yml +++ b/.github/workflows/build_reusable.yml @@ -64,6 +64,11 @@ on: required: false type: string default: '["self-hosted", "linux", "x64", "metal"]' + buildNativeTarget: + description: 'Target for build-native step' + required: false + type: string + default: 'x86_64-unknown-linux-gnu' env: NAPI_CLI_VERSION: 2.14.7 @@ -92,6 +97,10 @@ jobs: timeout-minutes: ${{ inputs.timeout_minutes }} runs-on: ${{ fromJson(inputs.runs_on_labels) }} + defaults: + run: + shell: bash -leo pipefail {0} + outputs: input_step_key: ${{ steps.var.outputs.input_step_key }} @@ -103,12 +112,8 @@ jobs: script: | core.setOutput('input_step_key', '${{ inputs.stepName }}'.toLowerCase().replaceAll(/[/.]/g, '-').trim('-')); - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: ${{ inputs.nodeVersion || env.NODE_LTS_VERSION }} - check-latest: true - + - run: fnm use --install-if-missing ${{ inputs.nodeVersion || env.NODE_LTS_VERSION }} + - run: fnm default ${{ inputs.nodeVersion || env.NODE_LTS_VERSION }} - run: node -v - run: corepack enable - run: pwd @@ -146,7 +151,7 @@ jobs: with: cache-provider: 'turbo' save-if: ${{ github.ref_name == 'canary' }} - shared-key: ${{ inputs.rustCacheKey }}-x86_64-unknown-linux-gnu-build-${{ hashFiles('.cargo/config.toml') }} + shared-key: ${{ inputs.rustCacheKey }}-${{ inputs.buildNativeTarget }}-build-${{ hashFiles('.cargo/config.toml') }} # clean up any previous artifacts to avoid hitting disk space limits - run: git clean -xdf && rm -rf /tmp/next-repo-*; rm -rf /tmp/next-install-* /tmp/yarn-* /tmp/ncc-cache target @@ -164,7 +169,7 @@ jobs: - run: node scripts/normalize-version-bump.js name: normalize versions - - run: turbo run build-native-release -vvv --env-mode loose --remote-cache-timeout 90 --summarize -- --target x86_64-unknown-linux-gnu + - run: turbo run build-native-release -v --env-mode loose --remote-cache-timeout 90 --summarize -- --target ${{ inputs.buildNativeTarget }} if: ${{ inputs.skipNativeBuild != 'yes' }} - name: Upload next-swc artifact diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index 7c5cdd004b7af..0000000000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,184 +0,0 @@ -trigger: - # Only run latest commit for branches: - batch: true - # Do not run Azure CI for docs-only/example-only changes: - paths: - include: - - '*' - exclude: - - bench - - docs - - errors - - examples - # Do not run Azure on release tags. This unnecessarily increases the backlog. - branches: - include: - - '*' - exclude: - - refs/tags/* - -pr: - # Do not run Azure CI for docs-only/example-only changes: - paths: - include: - - '*' - exclude: - - bench - - docs - - errors - - examples - -variables: - PNPM_CACHE_FOLDER: $(Pipeline.Workspace)/.pnpm-store - NEXT_TELEMETRY_DISABLED: '1' - node_version: ^18.18.2 - -stages: - - stage: Test - jobs: - - job: test_integration - pool: - vmImage: 'windows-2019' - steps: - - task: NodeTool@0 - inputs: - versionSpec: $(node_version) - displayName: 'Install Node.js' - - - bash: | - node scripts/run-for-change.js --not --type docs --exec echo "##vso[task.setvariable variable=isDocsOnly]No" - displayName: 'Check Docs Only Change' - - - script: corepack enable - condition: eq(variables['isDocsOnly'], 'No') - displayName: 'Enable Corepack' - - - script: pnpm config set store-dir $(PNPM_CACHE_FOLDER) - condition: eq(variables['isDocsOnly'], 'No') - - - script: pnpm store path - condition: eq(variables['isDocsOnly'], 'No') - - - script: pnpm install && pnpm run build - condition: eq(variables['isDocsOnly'], 'No') - displayName: 'Install and build' - - - script: npx playwright@1.35.1 install chromium - condition: eq(variables['isDocsOnly'], 'No') - - # Test critical app router and CNA tests to cover basic usage cases with windows - - script: | - node run-tests.js -c 1 test/production/pages-dir/production/test/index.test.ts test/integration/css-client-nav/test/index.test.js test/integration/rewrites-has-condition/test/index.test.js test/integration/create-next-app/examples.test.ts test/integration/create-next-app/index.test.ts test/integration/create-next-app/package-manager/pnpm.test.ts - condition: eq(variables['isDocsOnly'], 'No') - displayName: 'Run tests' - - - job: test_unit - pool: - vmImage: 'windows-2019' - steps: - - script: | - wmic datafile where name="C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe" get Version /value - displayName: 'List Chrome version' - - - task: NodeTool@0 - inputs: - versionSpec: $(node_version) - displayName: 'Install Node.js' - - - bash: | - node scripts/run-for-change.js --not --type docs --exec echo "##vso[task.setvariable variable=isDocsOnly]No" - displayName: 'Check Docs Only Change' - - - script: corepack enable - condition: eq(variables['isDocsOnly'], 'No') - displayName: 'Enable Corepack' - - - script: pnpm config set store-dir $(PNPM_CACHE_FOLDER) - condition: eq(variables['isDocsOnly'], 'No') - - - script: pnpm store path - condition: eq(variables['isDocsOnly'], 'No') - - - script: pnpm install && pnpm run build - condition: eq(variables['isDocsOnly'], 'No') - displayName: 'Install and build' - - - script: node run-tests.js --type unit - condition: eq(variables['isDocsOnly'], 'No') - displayName: 'Run tests' - env: - NEXT_TEST_MODE: 'dev' - - - job: test_e2e_dev - pool: - vmImage: 'windows-2019' - steps: - - task: NodeTool@0 - inputs: - versionSpec: $(node_version) - displayName: 'Install Node.js' - - - bash: | - node scripts/run-for-change.js --not --type docs --exec echo "##vso[task.setvariable variable=isDocsOnly]No" - displayName: 'Check Docs Only Change' - - - script: corepack enable - condition: eq(variables['isDocsOnly'], 'No') - displayName: 'Enable Corepack' - - - script: pnpm config set store-dir $(PNPM_CACHE_FOLDER) - condition: eq(variables['isDocsOnly'], 'No') - - - script: pnpm store path - condition: eq(variables['isDocsOnly'], 'No') - - - script: pnpm install && pnpm run build - condition: eq(variables['isDocsOnly'], 'No') - displayName: 'Install and build' - - - script: npx playwright@1.35.1 install chromium - condition: eq(variables['isDocsOnly'], 'No') - - - script: | - node run-tests.js -c 1 --debug test/e2e/app-dir/app/index.test.ts test/e2e/app-dir/app-edge/app-edge.test.ts - condition: eq(variables['isDocsOnly'], 'No') - displayName: 'Run tests (E2E Development)' - env: - NEXT_TEST_MODE: 'dev' - - - job: test_e2e_prod - pool: - vmImage: 'windows-2019' - steps: - - task: NodeTool@0 - inputs: - versionSpec: $(node_version) - displayName: 'Install Node.js' - - - bash: | - node scripts/run-for-change.js --not --type docs --exec echo "##vso[task.setvariable variable=isDocsOnly]No" - displayName: 'Check Docs Only Change' - - - script: corepack enable - condition: eq(variables['isDocsOnly'], 'No') - displayName: 'Enable Corepack' - - - script: pnpm config set store-dir $(PNPM_CACHE_FOLDER) - condition: eq(variables['isDocsOnly'], 'No') - - - script: pnpm store path - condition: eq(variables['isDocsOnly'], 'No') - - - script: pnpm install && pnpm run build - condition: eq(variables['isDocsOnly'], 'No') - displayName: 'Install and build' - - - script: npx playwright@1.35.1 install chromium - condition: eq(variables['isDocsOnly'], 'No') - - - script: | - node run-tests.js -c 1 --debug test/e2e/app-dir/app/index.test.ts test/e2e/app-dir/app-edge/app-edge.test.ts - condition: eq(variables['isDocsOnly'], 'No') - displayName: 'Run tests (E2E Production)' - env: - NEXT_TEST_MODE: 'start'