Ensure test-unit includes package unit tests (#46707) #48044
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
push: | |
branches: [canary] | |
pull_request: | |
types: [opened, synchronize] | |
name: Build, test, and deploy | |
env: | |
NAPI_CLI_VERSION: 2.14.7 | |
TURBO_VERSION: 1.6.3 | |
RUST_TOOLCHAIN: nightly-2022-11-04 | |
PNPM_VERSION: 7.24.3 | |
NODE_MAINTENANCE_VERSION: 16 | |
NODE_LTS_VERSION: 18 | |
jobs: | |
check-examples: | |
name: Check examples | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install moreutils | |
run: sudo apt install moreutils | |
- name: Check examples | |
run: ./scripts/check-examples.sh | |
build: | |
runs-on: ubuntu-latest | |
env: | |
NEXT_TELEMETRY_DISABLED: 1 | |
# we build a dev binary for use in CI so skip downloading | |
# canary next-swc binaries in the monorepo | |
NEXT_SKIP_NATIVE_POSTINSTALL: 1 | |
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} | |
outputs: | |
docsChange: ${{ steps.docs-change.outputs.DOCS_CHANGE }} | |
isRelease: ${{ steps.check-release.outputs.IS_RELEASE }} | |
swcChange: ${{ steps.swc-change.outputs.SWC_CHANGE }} | |
turboToken: ${{ steps.turbo-token.outputs.TURBO_TOKEN }} | |
weekNum: ${{ steps.get-week.outputs.WEEK }} | |
steps: | |
- name: Setup node | |
uses: actions/setup-node@v3 | |
if: ${{ steps.docs-change.outputs.docsChange == 'nope' }} | |
with: | |
node-version: 16 | |
check-latest: true | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 25 | |
# https://github.com/actions/virtual-environments/issues/1187 | |
- name: tune linux network | |
run: sudo ethtool -K eth0 tx off rx off | |
- name: Check non-docs only change | |
run: echo "DOCS_CHANGE<<EOF" >> $GITHUB_OUTPUT; echo "$(node scripts/run-for-change.js --not --type docs --exec echo 'nope')" >> $GITHUB_OUTPUT; echo 'EOF' >> $GITHUB_OUTPUT | |
id: docs-change | |
- run: echo "${{steps.docs-change.outputs.DOCS_CHANGE}}" | |
- run: echo "SWC_CHANGE<<EOF" >> $GITHUB_OUTPUT; echo "$(node scripts/run-for-change.js --type next-swc --exec echo 'yup')" >> $GITHUB_OUTPUT; echo 'EOF' >> $GITHUB_OUTPUT | |
id: swc-change | |
- run: echo "TURBO_TOKEN=$(echo ${TURBO_TOKEN:-empty})" >> $GITHUB_OUTPUT | |
id: turbo-token | |
- run: echo "${{steps.swc-change.outputs.SWC_CHANGE}}" | |
- run: npm i -g pnpm@${PNPM_VERSION} | |
- id: get-store-path | |
run: echo STORE_PATH=$(pnpm store path) >> $GITHUB_OUTPUT | |
- uses: actions/cache@v3 | |
timeout-minutes: 5 | |
id: cache-pnpm-store | |
with: | |
path: ${{ steps.get-store-path.outputs.STORE_PATH }} | |
key: pnpm-store-${{ hashFiles('pnpm-lock.yaml') }} | |
restore-keys: | | |
pnpm-store- | |
pnpm-store-${{ hashFiles('pnpm-lock.yaml') }} | |
- run: pnpm install | |
- run: TEST_TIMINGS_TOKEN=${{ secrets.TEST_TIMINGS_TOKEN }} node run-tests.js --timings --write-timings -g 1/1 | |
if: ${{ steps.docs-change.outputs.DOCS_CHANGE == 'nope' }} | |
- run: pnpm run build | |
- id: check-release | |
run: | | |
if [[ $(node ./scripts/check-is-release.js 2> /dev/null || :) = v* ]]; | |
then | |
echo "IS_RELEASE=true" >> $GITHUB_OUTPUT | |
else | |
echo "IS_RELEASE=false" >> $GITHUB_OUTPUT | |
fi | |
# We use week in the turbo cache key to keep the cache from infinitely growing | |
- id: get-week | |
run: echo "WEEK=$(date +%U)" >> $GITHUB_OUTPUT | |
- uses: actions/cache@v3 | |
timeout-minutes: 5 | |
id: cache-build | |
with: | |
path: ./* | |
key: ${{ github.sha }}-${{ github.run_number }} | |
lint: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Setup node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
check-latest: true | |
- run: npm i -g pnpm@${PNPM_VERSION} | |
- uses: actions/cache@v3 | |
timeout-minutes: 5 | |
id: restore-build | |
with: | |
path: ./* | |
key: ${{ github.sha }}-${{ github.run_number }} | |
- run: ./scripts/check-manifests.js | |
- run: pnpm lint | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
- run: pnpm lint-no-typescript | |
if: ${{needs.build.outputs.docsChange != 'nope'}} | |
rust-check: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: actions/cache@v3 | |
timeout-minutes: 5 | |
id: restore-build | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
with: | |
path: ./* | |
key: ${{ github.sha }}-${{ github.run_number }} | |
- run: echo "SWC_CHANGE<<EOF" >> $GITHUB_OUTPUT; echo "$(node scripts/run-for-change.js --type next-swc --exec echo 'yup')" >> $GITHUB_OUTPUT; echo 'EOF' >> $GITHUB_OUTPUT | |
id: swc-change | |
- run: echo "${{ steps.swc-change.outputs.SWC_CHANGE }}" | |
- name: Install | |
uses: actions-rs/toolchain@v1 | |
if: ${{ steps.swc-change.outputs.SWC_CHANGE == 'yup' }} | |
with: | |
profile: minimal | |
toolchain: ${{ env.RUST_TOOLCHAIN }} | |
components: rustfmt, clippy | |
- name: Cache cargo registry | |
uses: actions/cache@v3 | |
timeout-minutes: 5 | |
if: ${{ steps.swc-change.outputs.SWC_CHANGE == 'yup' }} | |
with: | |
path: ~/.cargo/registry | |
key: stable-ubuntu-clippy-cargo-registry | |
- name: Cache cargo index | |
uses: actions/cache@v3 | |
timeout-minutes: 5 | |
if: ${{ steps.swc-change.outputs.SWC_CHANGE == 'yup' }} | |
with: | |
path: ~/.cargo/git | |
key: stable-ubuntu-clippy-cargo-index | |
- name: Check | |
if: ${{ steps.swc-change.outputs.SWC_CHANGE == 'yup' }} | |
run: | | |
cargo fmt -- --check | |
cargo clippy --all -- -D warnings | |
working-directory: packages/next-swc | |
checkPrecompiled: | |
name: Check Pre-compiled | |
runs-on: ubuntu-latest | |
needs: build | |
env: | |
NEXT_TELEMETRY_DISABLED: 1 | |
steps: | |
- name: Setup node | |
uses: actions/setup-node@v3 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
with: | |
node-version: 16 | |
check-latest: true | |
# https://github.com/actions/virtual-environments/issues/1187 | |
- name: tune linux network | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
run: sudo ethtool -K eth0 tx off rx off | |
- uses: actions/checkout@v3 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
- run: mv .git .git-bak | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
- uses: actions/cache@v3 | |
timeout-minutes: 5 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
id: restore-build | |
with: | |
path: ./* | |
key: ${{ github.sha }}-${{ github.run_number }} | |
- run: npm i -g pnpm@${PNPM_VERSION} | |
- run: rm -rf .git && mv .git-bak .git | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
- run: ./scripts/check-pre-compiled.sh | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
- uses: EndBug/add-and-commit@v7 | |
if: ${{ failure() }} | |
with: | |
add: 'packages/next/compiled packages/next/bundles --force' | |
message: '⚙ Update compiled files' | |
testUnit: | |
name: Test Unit | |
runs-on: ubuntu-latest | |
needs: [build, build-native-test] | |
timeout-minutes: 10 | |
env: | |
NEXT_TELEMETRY_DISABLED: 1 | |
steps: | |
- name: Setup node | |
uses: actions/setup-node@v3 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
with: | |
node-version: 16 | |
check-latest: true | |
- uses: actions/cache@v3 | |
timeout-minutes: 5 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
id: restore-build | |
with: | |
path: ./* | |
key: ${{ github.sha }}-${{ github.run_number }} | |
- uses: actions/download-artifact@v3 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
with: | |
name: next-swc-test-binary | |
path: packages/next-swc/native | |
- run: npm i -g pnpm@${PNPM_VERSION} | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
- run: node run-tests.js --type unit | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
# run LTS matrix always and maintenance tests during a release | |
testDevLTS: | |
name: Test Development Node.js LTS | |
runs-on: ubuntu-latest | |
needs: [build, build-native-test] | |
timeout-minutes: 35 | |
env: | |
NEXT_TELEMETRY_DISABLED: 1 | |
TEST_TIMINGS_TOKEN: ${{ secrets.TEST_TIMINGS_TOKEN }} | |
strategy: | |
fail-fast: false | |
matrix: | |
node: [18] | |
group: [1, 2, 3, 4, 5] | |
steps: | |
- run: echo "${{needs.build.outputs.docsChange}}" | |
# https://github.com/actions/virtual-environments/issues/1187 | |
- name: tune linux network | |
run: sudo ethtool -K eth0 tx off rx off | |
- uses: actions/cache@v3 | |
timeout-minutes: 5 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
id: restore-build | |
with: | |
path: ./* | |
key: ${{ github.sha }}-${{ github.run_number }} | |
- uses: actions/download-artifact@v3 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
with: | |
name: next-swc-test-binary | |
path: packages/next-swc/native | |
- run: docker run --rm -v $(pwd):/work mcr.microsoft.com/playwright:v1.28.1-focal /bin/bash -c "cd /work && curl -s https://install-node.vercel.app/v${{ matrix.node }} | FORCE=1 bash && node -v && npm i -g pnpm@${PNPM_VERSION} > /dev/null && NEXT_TEST_JOB=1 NEXT_TEST_MODE=dev TEST_TIMINGS_TOKEN=${{ secrets.TEST_TIMINGS_TOKEN }} xvfb-run node run-tests.js --type development --timings -g ${{ matrix.group }}/5 >> /proc/1/fd/1" | |
name: Run test/development | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
- name: Upload test trace | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: test-trace | |
if-no-files-found: ignore | |
retention-days: 2 | |
path: | | |
test/traces | |
testDevMaintenance: | |
name: Test Development Node.js Maintenance | |
runs-on: ubuntu-latest | |
needs: [build, build-native-test] | |
timeout-minutes: 35 | |
env: | |
NEXT_TELEMETRY_DISABLED: 1 | |
TEST_TIMINGS_TOKEN: ${{ secrets.TEST_TIMINGS_TOKEN }} | |
strategy: | |
fail-fast: false | |
matrix: | |
node: [16] | |
group: [1, 2, 3, 4, 5] | |
# we can't use "matrix" context in job level "if" so we have | |
# to create a separate job which can skip | |
if: ${{ needs.build.outputs.isRelease == 'true' }} | |
steps: | |
- run: echo "${{needs.build.outputs.docsChange}}" | |
# https://github.com/actions/virtual-environments/issues/1187 | |
- name: tune linux network | |
run: sudo ethtool -K eth0 tx off rx off | |
- uses: actions/cache@v3 | |
timeout-minutes: 5 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
id: restore-build | |
with: | |
path: ./* | |
key: ${{ github.sha }}-${{ github.run_number }} | |
- uses: actions/download-artifact@v3 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
with: | |
name: next-swc-test-binary | |
path: packages/next-swc/native | |
- run: docker run --rm -v $(pwd):/work mcr.microsoft.com/playwright:v1.28.1-focal /bin/bash -c "cd /work && curl -s https://install-node.vercel.app/v${{ matrix.node }} | FORCE=1 bash && node -v && npm i -g pnpm@${PNPM_VERSION} > /dev/null && NEXT_TEST_JOB=1 NEXT_TEST_MODE=dev TEST_TIMINGS_TOKEN=${{ secrets.TEST_TIMINGS_TOKEN }} xvfb-run node run-tests.js --type development --timings -g ${{ matrix.group }}/5 >> /proc/1/fd/1" | |
name: Run test/development | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
- name: Upload test trace | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: test-trace | |
if-no-files-found: ignore | |
retention-days: 2 | |
path: | | |
test/traces | |
testDevE2ELTS: | |
name: Test Development (E2E) Node.js LTS | |
runs-on: ubuntu-latest | |
needs: [build, build-native-test] | |
timeout-minutes: 35 | |
env: | |
NEXT_TELEMETRY_DISABLED: 1 | |
TEST_TIMINGS_TOKEN: ${{ secrets.TEST_TIMINGS_TOKEN }} | |
strategy: | |
fail-fast: false | |
matrix: | |
node: [18] | |
group: [1, 2, 3, 4, 5, 6, 7, 8] | |
steps: | |
- run: echo "${{needs.build.outputs.docsChange}}" | |
# https://github.com/actions/virtual-environments/issues/1187 | |
- name: tune linux network | |
run: sudo ethtool -K eth0 tx off rx off | |
- uses: actions/cache@v3 | |
timeout-minutes: 5 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
id: restore-build | |
with: | |
path: ./* | |
key: ${{ github.sha }}-${{ github.run_number }} | |
- uses: actions/download-artifact@v3 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
with: | |
name: next-swc-test-binary | |
path: packages/next-swc/native | |
- run: docker run --rm -v $(pwd):/work mcr.microsoft.com/playwright:v1.28.1-focal /bin/bash -c "cd /work && curl -s https://install-node.vercel.app/v${{ matrix.node }} | FORCE=1 bash && node -v && npm i -g pnpm@${PNPM_VERSION} > /dev/null && NEXT_TEST_JOB=1 NEXT_TEST_MODE=dev TEST_TIMINGS_TOKEN=${{ secrets.TEST_TIMINGS_TOKEN }} xvfb-run node run-tests.js --type e2e --timings -g ${{ matrix.group }}/8 >> /proc/1/fd/1" | |
name: Run test/e2e (dev) | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
- name: Upload test trace | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: test-trace | |
if-no-files-found: ignore | |
retention-days: 2 | |
path: | | |
test/traces | |
testDevE2EMaintenance: | |
name: Test Development (E2E) Node.js Maintenance | |
runs-on: ubuntu-latest | |
needs: [build, build-native-test] | |
timeout-minutes: 35 | |
env: | |
NEXT_TELEMETRY_DISABLED: 1 | |
TEST_TIMINGS_TOKEN: ${{ secrets.TEST_TIMINGS_TOKEN }} | |
strategy: | |
fail-fast: false | |
matrix: | |
node: [16] | |
group: [1, 2, 3, 4, 5, 6, 7, 8] | |
if: ${{ needs.build.outputs.isRelease == 'true' }} | |
steps: | |
- run: echo "${{needs.build.outputs.docsChange}}" | |
# https://github.com/actions/virtual-environments/issues/1187 | |
- name: tune linux network | |
run: sudo ethtool -K eth0 tx off rx off | |
- uses: actions/cache@v3 | |
timeout-minutes: 5 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
id: restore-build | |
with: | |
path: ./* | |
key: ${{ github.sha }}-${{ github.run_number }} | |
- uses: actions/download-artifact@v3 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
with: | |
name: next-swc-test-binary | |
path: packages/next-swc/native | |
- run: docker run --rm -v $(pwd):/work mcr.microsoft.com/playwright:v1.28.1-focal /bin/bash -c "cd /work && curl -s https://install-node.vercel.app/v${{ matrix.node }} | FORCE=1 bash && node -v && npm i -g pnpm@${PNPM_VERSION} > /dev/null && NEXT_TEST_JOB=1 NEXT_TEST_MODE=dev TEST_TIMINGS_TOKEN=${{ secrets.TEST_TIMINGS_TOKEN }} xvfb-run node run-tests.js --type e2e --timings -g ${{ matrix.group }}/8 >> /proc/1/fd/1" | |
name: Run test/e2e (dev) | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
- name: Upload test trace | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: test-trace | |
if-no-files-found: ignore | |
retention-days: 2 | |
path: | | |
test/traces | |
testProdLTS: | |
name: Test Production Node.js LTS | |
runs-on: ubuntu-latest | |
needs: [build, build-native-test] | |
timeout-minutes: 15 | |
env: | |
NEXT_TELEMETRY_DISABLED: 1 | |
TEST_TIMINGS_TOKEN: ${{ secrets.TEST_TIMINGS_TOKEN }} | |
strategy: | |
fail-fast: false | |
matrix: | |
node: [18] | |
group: [1, 2, 3, 4, 5] | |
steps: | |
- run: echo "${{needs.build.outputs.docsChange}}" | |
# https://github.com/actions/virtual-environments/issues/1187 | |
- name: tune linux network | |
run: sudo ethtool -K eth0 tx off rx off | |
- uses: actions/cache@v3 | |
timeout-minutes: 5 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
id: restore-build | |
with: | |
path: ./* | |
key: ${{ github.sha }}-${{ github.run_number }} | |
- uses: actions/download-artifact@v3 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
with: | |
name: next-swc-test-binary | |
path: packages/next-swc/native | |
- run: docker run --rm -v $(pwd):/work mcr.microsoft.com/playwright:v1.28.1-focal /bin/bash -c "cd /work && curl -s https://install-node.vercel.app/v${{ matrix.node }} | FORCE=1 bash && node -v && npm i -g pnpm@${PNPM_VERSION} > /dev/null && NEXT_TEST_JOB=1 NEXT_TEST_MODE=start TEST_TIMINGS_TOKEN=${{ secrets.TEST_TIMINGS_TOKEN }} xvfb-run node run-tests.js --type production --timings -g ${{ matrix.group }}/5 >> /proc/1/fd/1" | |
name: Run test/production | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
testProdMaintenance: | |
name: Test Production Node.js Maintenance | |
runs-on: ubuntu-latest | |
needs: [build, build-native-test] | |
timeout-minutes: 15 | |
env: | |
NEXT_TELEMETRY_DISABLED: 1 | |
TEST_TIMINGS_TOKEN: ${{ secrets.TEST_TIMINGS_TOKEN }} | |
strategy: | |
fail-fast: false | |
matrix: | |
node: [16] | |
group: [1, 2, 3, 4, 5] | |
if: ${{ needs.build.outputs.isRelease == 'true' }} | |
steps: | |
- run: echo "${{needs.build.outputs.docsChange}}" | |
# https://github.com/actions/virtual-environments/issues/1187 | |
- name: tune linux network | |
run: sudo ethtool -K eth0 tx off rx off | |
- uses: actions/cache@v3 | |
timeout-minutes: 5 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
id: restore-build | |
with: | |
path: ./* | |
key: ${{ github.sha }}-${{ github.run_number }} | |
- uses: actions/download-artifact@v3 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
with: | |
name: next-swc-test-binary | |
path: packages/next-swc/native | |
- run: docker run --rm -v $(pwd):/work mcr.microsoft.com/playwright:v1.28.1-focal /bin/bash -c "cd /work && curl -s https://install-node.vercel.app/v${{ matrix.node }} | FORCE=1 bash && node -v && npm i -g pnpm@${PNPM_VERSION} > /dev/null && NEXT_TEST_JOB=1 NEXT_TEST_MODE=start TEST_TIMINGS_TOKEN=${{ secrets.TEST_TIMINGS_TOKEN }} xvfb-run node run-tests.js --type production --timings -g ${{ matrix.group }}/5 >> /proc/1/fd/1" | |
name: Run test/production | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
testProdE2ELTS: | |
name: Test Production (E2E) Node.js LTS | |
runs-on: ubuntu-latest | |
needs: [build, build-native-test] | |
timeout-minutes: 35 | |
env: | |
NEXT_TELEMETRY_DISABLED: 1 | |
TEST_TIMINGS_TOKEN: ${{ secrets.TEST_TIMINGS_TOKEN }} | |
strategy: | |
fail-fast: false | |
matrix: | |
node: [18] | |
group: [1, 2, 3, 4, 5, 6, 7, 8] | |
steps: | |
- run: echo "${{needs.build.outputs.docsChange}}" | |
# https://github.com/actions/virtual-environments/issues/1187 | |
- name: tune linux network | |
run: sudo ethtool -K eth0 tx off rx off | |
- uses: actions/cache@v3 | |
timeout-minutes: 5 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
id: restore-build | |
with: | |
path: ./* | |
key: ${{ github.sha }}-${{ github.run_number }} | |
- uses: actions/download-artifact@v3 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
with: | |
name: next-swc-test-binary | |
path: packages/next-swc/native | |
- run: docker run --rm -v $(pwd):/work mcr.microsoft.com/playwright:v1.28.1-focal /bin/bash -c "cd /work && curl -s https://install-node.vercel.app/v${{ matrix.node }} | FORCE=1 bash && node -v && npm i -g pnpm@${PNPM_VERSION} > /dev/null && NEXT_TEST_JOB=1 NEXT_TEST_MODE=start TEST_TIMINGS_TOKEN=${{ secrets.TEST_TIMINGS_TOKEN }} xvfb-run node run-tests.js --type e2e --timings -g ${{ matrix.group }}/8 >> /proc/1/fd/1" | |
name: Run test/e2e (production) | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
testProdE2EMaintenance: | |
name: Test Production (E2E) Node.js Maintenance | |
runs-on: ubuntu-latest | |
needs: [build, build-native-test] | |
timeout-minutes: 35 | |
env: | |
NEXT_TELEMETRY_DISABLED: 1 | |
TEST_TIMINGS_TOKEN: ${{ secrets.TEST_TIMINGS_TOKEN }} | |
strategy: | |
fail-fast: false | |
matrix: | |
node: [16] | |
group: [1, 2, 3, 4, 5, 6, 7, 8] | |
# run LTS matrix always and maintenance tests during a release | |
if: ${{ needs.build.outputs.isRelease == 'true' }} | |
steps: | |
- run: echo "${{needs.build.outputs.docsChange}}" | |
# https://github.com/actions/virtual-environments/issues/1187 | |
- name: tune linux network | |
run: sudo ethtool -K eth0 tx off rx off | |
- uses: actions/cache@v3 | |
timeout-minutes: 5 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
id: restore-build | |
with: | |
path: ./* | |
key: ${{ github.sha }}-${{ github.run_number }} | |
- uses: actions/download-artifact@v3 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
with: | |
name: next-swc-test-binary | |
path: packages/next-swc/native | |
- run: docker run --rm -v $(pwd):/work mcr.microsoft.com/playwright:v1.28.1-focal /bin/bash -c "cd /work && curl -s https://install-node.vercel.app/v${{ matrix.node }} | FORCE=1 bash && node -v && npm i -g pnpm@${PNPM_VERSION} > /dev/null && NEXT_TEST_JOB=1 NEXT_TEST_MODE=start TEST_TIMINGS_TOKEN=${{ secrets.TEST_TIMINGS_TOKEN }} xvfb-run node run-tests.js --type e2e --timings -g ${{ matrix.group }}/8 >> /proc/1/fd/1" | |
name: Run test/e2e (production) | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
testCNA: | |
name: Test Create Next App | |
runs-on: ubuntu-latest | |
needs: [build, build-native-test] | |
timeout-minutes: 35 | |
env: | |
NEXT_TELEMETRY_DISABLED: 1 | |
TEST_TIMINGS_TOKEN: ${{ secrets.TEST_TIMINGS_TOKEN }} | |
steps: | |
- run: echo "${{needs.build.outputs.docsChange}}" | |
# https://github.com/actions/virtual-environments/issues/1187 | |
- name: tune linux network | |
run: sudo ethtool -K eth0 tx off rx off | |
- uses: actions/cache@v3 | |
timeout-minutes: 5 | |
if: ${{ needs.build.outputs.docsChange == 'nope' }} | |
id: restore-build | |
with: | |
path: ./* | |
key: ${{ github.sha }}-${{ github.run_number }} | |
- uses: actions/download-artifact@v3 | |
if: ${{ needs.build.outputs.docsChange == 'nope' }} | |
with: | |
name: next-swc-test-binary | |
path: packages/next-swc/native | |
- run: echo "CNA_CHANGE<<EOF" >> $GITHUB_OUTPUT; echo "$(node scripts/run-for-change.js --type cna --always-canary --exec echo 'yup')" >> $GITHUB_OUTPUT; echo "EOF" >> $GITHUB_OUTPUT | |
id: cna-change | |
- run: docker run --rm -v $(pwd):/work mcr.microsoft.com/playwright:v1.28.1-focal /bin/bash -c "cd /work && curl -s https://install-node.vercel.app/v${{ env.NODE_LTS_VERSION }} | FORCE=1 bash && npm i -g pnpm@${PNPM_VERSION} > /dev/null && NEXT_TEST_JOB=1 NEXT_TEST_CNA=1 xvfb-run node run-tests.js test/integration/create-next-app/index.test.ts test/integration/create-next-app/templates.test.ts >> /proc/1/fd/1" | |
if: ${{ needs.build.outputs.docsChange == 'nope' && steps.cna-change.outputs.CNA_CHANGE == 'yup' }} | |
- name: Upload test trace | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: test-trace | |
if-no-files-found: ignore | |
retention-days: 2 | |
path: | | |
test/traces | |
testCodemods: | |
name: Test Codemods | |
runs-on: ubuntu-latest | |
needs: [build] | |
timeout-minutes: 5 | |
env: | |
NEXT_TELEMETRY_DISABLED: 1 | |
TEST_TIMINGS_TOKEN: ${{ secrets.TEST_TIMINGS_TOKEN }} | |
steps: | |
- run: echo "${{needs.build.outputs.docsChange}}" | |
# https://github.com/actions/virtual-environments/issues/1187 | |
- name: tune linux network | |
run: sudo ethtool -K eth0 tx off rx off | |
- uses: actions/cache@v3 | |
timeout-minutes: 5 | |
if: ${{ needs.build.outputs.docsChange == 'nope' }} | |
id: restore-build | |
with: | |
path: ./* | |
key: ${{ github.sha }}-${{ github.run_number }} | |
- run: echo "CODEMOD_CHANGE<<EOF" >> $GITHUB_OUTPUT; echo "$(node scripts/run-for-change.js --type next-codemod --always-canary --exec echo 'yup')" >> $GITHUB_OUTPUT; echo "EOF" >> $GITHUB_OUTPUT | |
id: codemodChange | |
- run: docker run --rm -v $(pwd):/work mcr.microsoft.com/playwright:v1.28.1-focal /bin/bash -c "cd /work && curl -s https://install-node.vercel.app/v${{ env.NODE_LTS_VERSION }} | FORCE=1 bash && npm i -g pnpm@${PNPM_VERSION} > /dev/null && cd ./packages/next-codemod && pnpm build && pnpm test >> /proc/1/fd/1" | |
if: ${{ needs.build.outputs.docsChange == 'nope' && steps.codemodChange.outputs.CODEMOD_CHANGE == 'yup' }} | |
testIntegration: | |
name: Test Integration | |
runs-on: ubuntu-latest | |
needs: [build, build-native-test] | |
timeout-minutes: 35 | |
env: | |
NEXT_TELEMETRY_DISABLED: 1 | |
TEST_TIMINGS_TOKEN: ${{ secrets.TEST_TIMINGS_TOKEN }} | |
strategy: | |
fail-fast: false | |
matrix: | |
group: | |
[ | |
1, | |
2, | |
3, | |
4, | |
5, | |
6, | |
7, | |
8, | |
9, | |
10, | |
11, | |
12, | |
13, | |
14, | |
15, | |
16, | |
17, | |
18, | |
19, | |
20, | |
21, | |
22, | |
23, | |
24, | |
25, | |
26, | |
27, | |
28, | |
] | |
steps: | |
- run: echo "${{needs.build.outputs.docsChange}}" | |
# https://github.com/actions/virtual-environments/issues/1187 | |
- name: tune linux network | |
run: sudo ethtool -K eth0 tx off rx off | |
- uses: actions/cache@v3 | |
timeout-minutes: 5 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
id: restore-build | |
with: | |
path: ./* | |
key: ${{ github.sha }}-${{ github.run_number }} | |
- uses: actions/download-artifact@v3 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
with: | |
name: next-swc-test-binary | |
path: packages/next-swc/native | |
- run: docker run --rm -v $(pwd):/work mcr.microsoft.com/playwright:v1.28.1-focal /bin/bash -c "cd /work && curl -s https://install-node.vercel.app/v${{ env.NODE_LTS_VERSION }} | FORCE=1 bash && npm i -g pnpm@${PNPM_VERSION} > /dev/null && NEXT_TEST_JOB=1 TEST_TIMINGS_TOKEN=${{ secrets.TEST_TIMINGS_TOKEN }} xvfb-run node run-tests.js --timings -g ${{ matrix.group }}/28 >> /proc/1/fd/1" | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
- name: Upload test trace | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: test-trace | |
if-no-files-found: ignore | |
retention-days: 2 | |
path: | | |
test/traces | |
testElectron: | |
name: Test Electron | |
runs-on: ubuntu-latest | |
needs: [build, build-native-test] | |
timeout-minutes: 10 | |
env: | |
NEXT_TELEMETRY_DISABLED: 1 | |
TEST_ELECTRON: 1 | |
steps: | |
- name: Setup node | |
uses: actions/setup-node@v3 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
with: | |
node-version: 16 | |
check-latest: true | |
- uses: actions/cache@v3 | |
timeout-minutes: 5 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
id: restore-build | |
with: | |
path: ./* | |
key: ${{ github.sha }}-${{ github.run_number }} | |
- uses: actions/download-artifact@v3 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
with: | |
name: next-swc-test-binary | |
path: packages/next-swc/native | |
- run: npm i -g pnpm@${PNPM_VERSION} | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
- run: cd test/integration/with-electron/app && yarn install | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
- run: xvfb-run node run-tests.js test/integration/with-electron/test/index.test.js | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
testsPass: | |
name: thank you, next | |
runs-on: ubuntu-latest | |
needs: | |
[ | |
lint, | |
check-examples, | |
test-native, | |
checkPrecompiled, | |
testIntegration, | |
testUnit, | |
testDevLTS, | |
testProdLTS, | |
testDevE2ELTS, | |
testProdE2ELTS, | |
] | |
steps: | |
- run: exit 0 | |
testFirefox: | |
name: Test Firefox (production) | |
runs-on: ubuntu-latest | |
needs: [build, build-native-test] | |
timeout-minutes: 10 | |
env: | |
NEXT_TELEMETRY_DISABLED: 1 | |
steps: | |
- uses: actions/cache@v3 | |
timeout-minutes: 5 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
id: restore-build | |
with: | |
path: ./* | |
key: ${{ github.sha }}-${{ github.run_number }} | |
- uses: actions/download-artifact@v3 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
with: | |
name: next-swc-test-binary | |
path: packages/next-swc/native | |
- run: docker run --rm -v $(pwd):/work mcr.microsoft.com/playwright:v1.28.1-focal /bin/bash -c "cd /work && curl -s https://install-node.vercel.app/v${{ env.NODE_MAINTENANCE_VERSION }} | FORCE=1 bash && npm i -g pnpm@${PNPM_VERSION} > /dev/null && BROWSERNAME=firefox NEXT_TEST_JOB=1 TEST_TIMINGS_TOKEN=${{ secrets.TEST_TIMINGS_TOKEN }} xvfb-run node run-tests.js test/integration/production/test/index.test.js >> /proc/1/fd/1" | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
testSafari: | |
name: Test Safari (production) | |
runs-on: ubuntu-latest | |
needs: [build, build-native-test] | |
timeout-minutes: 15 | |
env: | |
NEXT_TELEMETRY_DISABLED: 1 | |
steps: | |
# https://github.com/actions/virtual-environments/issues/1187 | |
- name: tune linux network | |
run: sudo ethtool -K eth0 tx off rx off | |
- uses: actions/cache@v3 | |
timeout-minutes: 5 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
id: restore-build | |
with: | |
path: ./* | |
key: ${{ github.sha }}-${{ github.run_number }} | |
- uses: actions/download-artifact@v3 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
with: | |
name: next-swc-test-binary | |
path: packages/next-swc/native | |
- run: docker run --rm -v $(pwd):/work mcr.microsoft.com/playwright:v1.28.1-focal /bin/bash -c "cd /work && curl -s https://install-node.vercel.app/v{{ env.NODE_LTS_VERSION }} | FORCE=1 bash && npm i -g pnpm@${PNPM_VERSION} > /dev/null && NEXT_TEST_JOB=1 NEXT_TEST_MODE=start BROWSER_NAME=safari node run-tests.js -c 1 test/integration/production/test/index.test.js test/e2e/basepath.test.ts && DEVICE_NAME='iPhone XR' node run-tests.js -c 1 test/production/prerender-prefetch/index.test.ts >> /proc/1/fd/1" | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
testFirefoxNodeLTS: | |
name: Test Firefox Node.js LTS | |
runs-on: ubuntu-latest | |
needs: [build, testFirefox, build-native-test] | |
timeout-minutes: 10 | |
env: | |
NEXT_TELEMETRY_DISABLED: 1 | |
steps: | |
- uses: actions/cache@v3 | |
timeout-minutes: 5 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
id: restore-build | |
with: | |
path: ./* | |
key: ${{ github.sha }}-${{ github.run_number }} | |
- uses: actions/download-artifact@v3 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
with: | |
name: next-swc-test-binary | |
path: packages/next-swc/native | |
- run: docker run --rm -v $(pwd):/work mcr.microsoft.com/playwright:v1.28.1-focal /bin/bash -c "cd /work && curl -s https://install-node.vercel.app/v${{ env.NODE_LTS_VERSION }} | FORCE=1 bash && node -v && npm i -g pnpm@${PNPM_VERSION} > /dev/null && BROWSER_NAME=firefox NEXT_TEST_JOB=1 TEST_TIMINGS_TOKEN=${{ secrets.TEST_TIMINGS_TOKEN }} xvfb-run node run-tests.js test/integration/production/test/index.test.js >> /proc/1/fd/1" | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
publishRelease: | |
if: ${{ needs.build.outputs.isRelease == 'true' }} | |
name: Potentially publish release | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
- build-wasm | |
- build-native | |
- build-native-freebsd | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN_ELEVATED }} | |
steps: | |
- name: Setup node | |
uses: actions/setup-node@v3 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
with: | |
node-version: 16 | |
check-latest: true | |
# https://github.com/actions/virtual-environments/issues/1187 | |
- name: tune linux network | |
run: sudo ethtool -K eth0 tx off rx off | |
- uses: actions/cache@v3 | |
timeout-minutes: 5 | |
id: restore-build | |
with: | |
path: ./* | |
key: ${{ github.sha }}-${{ github.run_number }} | |
- uses: actions/download-artifact@v3 | |
with: | |
name: next-swc-binaries | |
path: packages/next-swc/native | |
- uses: actions/download-artifact@v3 | |
with: | |
name: wasm-binaries | |
path: packages/next-swc/crates/wasm | |
- run: npm i -g pnpm@${PNPM_VERSION} | |
- run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc | |
- run: ./scripts/publish-native.js | |
- run: ./scripts/publish-release.js | |
testDeployE2E: | |
name: E2E (deploy) | |
runs-on: ubuntu-latest | |
needs: [publishRelease, build, build-native-test] | |
env: | |
NEXT_TELEMETRY_DISABLED: 1 | |
VERCEL_TEST_TOKEN: ${{ secrets.VERCEL_TEST_TOKEN }} | |
VERCEL_TEST_TEAM: vtest314-next-e2e-tests | |
steps: | |
- uses: actions/cache@v3 | |
timeout-minutes: 5 | |
id: restore-build | |
with: | |
path: ./* | |
key: ${{ github.sha }}-${{ github.run_number }} | |
- uses: actions/download-artifact@v3 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
with: | |
name: next-swc-test-binary | |
path: packages/next-swc/native | |
- run: RESET_VC_PROJECT=true node scripts/reset-vercel-project.mjs | |
name: Reset test project | |
- run: docker run --rm -v $(pwd):/work mcr.microsoft.com/playwright:v1.28.1-focal /bin/bash -c "cd /work && curl -s https://install-node.vercel.app/v${{ env.NODE_LTS_VERSION }} | FORCE=1 bash && npm i -g pnpm@${PNPM_VERSION} > /dev/null && VERCEL_TEST_TOKEN=${{ secrets.VERCEL_TEST_TOKEN }} VERCEL_TEST_TEAM=vtest314-next-e2e-tests NEXT_TEST_JOB=1 NEXT_TEST_MODE=deploy TEST_TIMINGS_TOKEN=${{ secrets.TEST_TIMINGS_TOKEN }} xvfb-run node run-tests.js --type e2e >> /proc/1/fd/1" | |
name: Run test/e2e (deploy) | |
- name: Upload test trace | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: test-trace | |
if-no-files-found: ignore | |
retention-days: 2 | |
path: | | |
test/traces | |
releaseStats: | |
name: Release Stats | |
runs-on: ubuntu-latest | |
needs: [publishRelease, build-native-test] | |
steps: | |
- name: Setup node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
check-latest: true | |
- uses: actions/cache@v3 | |
timeout-minutes: 5 | |
id: restore-build | |
with: | |
path: ./* | |
key: ${{ github.sha }}-${{ github.run_number }} | |
- uses: actions/download-artifact@v3 | |
with: | |
name: next-swc-test-binary | |
path: packages/next-swc/native | |
- run: cp -r packages/next-swc/native .github/actions/next-stats-action/native | |
- run: ./scripts/release-stats.sh | |
- uses: ./.github/actions/next-stats-action | |
env: | |
PR_STATS_COMMENT_TOKEN: ${{ secrets.PR_STATS_COMMENT_TOKEN }} | |
build-native-test: | |
name: Build native binary for tests and metrics | |
runs-on: ubuntu-latest | |
steps: | |
# https://github.com/actions/virtual-environments/issues/1187 | |
- name: tune linux network | |
run: sudo ethtool -K eth0 tx off rx off | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 25 | |
- run: echo "DOCS_CHANGE<<EOF" >> $GITHUB_OUTPUT; echo "$(node scripts/run-for-change.js --not --type docs --exec echo 'nope')" >> $GITHUB_OUTPUT; echo 'EOF' >> $GITHUB_OUTPUT | |
id: docs-change | |
- name: Cache cargo registry | |
uses: actions/cache@v3 | |
timeout-minutes: 5 | |
if: ${{ steps.docs-change.outputs.DOCS_CHANGE == 'nope' }} | |
with: | |
path: ~/.cargo/registry | |
key: stable-ubuntu-latest-cargo-registry | |
- name: Cache cargo index | |
uses: actions/cache@v3 | |
timeout-minutes: 5 | |
if: ${{ steps.docs-change.outputs.DOCS_CHANGE == 'nope' }} | |
with: | |
path: ~/.cargo/git | |
key: stable-ubuntu-latest-cargo-index | |
# We use week in the turbo cache key to keep the cache from infinitely growing | |
- id: get-week | |
run: echo "WEEK=$(date +%U)" >> $GITHUB_OUTPUT | |
- name: Turbo Cache | |
id: turbo-cache | |
uses: actions/cache@v3 | |
timeout-minutes: 5 | |
if: ${{ steps.docs-change.outputs.DOCS_CHANGE == 'nope' }} | |
with: | |
path: .turbo | |
key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ steps.get-week.outputs.WEEK }}-${{ github.sha }} | |
restore-keys: | | |
turbo-${{ github.job }}- | |
turbo-${{ github.job }}-${{ github.ref_name }}-${{ steps.get-week.outputs.WEEK }}- | |
turbo-${{ github.job }}-canary-${{ steps.get-week.outputs.WEEK }}- | |
- name: normalize versions | |
if: ${{ steps.docs-change.outputs.DOCS_CHANGE == 'nope' }} | |
run: node scripts/normalize-version-bump.js | |
- name: Build in docker | |
uses: addnab/docker-run-action@v3 | |
if: ${{ steps.docs-change.outputs.DOCS_CHANGE == 'nope' }} | |
with: | |
image: ghcr.io/napi-rs/napi-rs/nodejs-rust:stable-2022-10-24-x64 | |
options: -e RUST_TOOLCHAIN=${{ env.RUST_TOOLCHAIN }} -e NAPI_CLI_VERSION=${{ env.NAPI_CLI_VERSION }} -e TURBO_VERSION=${{ env.TURBO_VERSION }} -v ${{ env.HOME }}/.cargo/git:/root/.cargo/git -v ${{ env.HOME }}/.cargo/registry:/root/.cargo/registry -v ${{ github.workspace }}:/build -w /build | |
# turn on some optimization while building Rust codes to prevent tests timeout | |
run: | | |
set -e && | |
export CARGO_PROFILE_DEV_OPT_LEVEL=1 && | |
rustup toolchain install "${RUST_TOOLCHAIN}" && | |
rustup default "${RUST_TOOLCHAIN}" && | |
rustup target add x86_64-unknown-linux-gnu && | |
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" && if [ ! -f $(dirname $(which yarn))/pnpm ]; then ln -s $(which yarn) $(dirname $(which yarn))/pnpm;fi && | |
unset CC_x86_64_unknown_linux_gnu && unset CC && | |
turbo run build-native --cache-dir=".turbo" -- --target x86_64-unknown-linux-gnu && | |
strip packages/next-swc/native/next-swc.*.node | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
if: ${{ steps.docs-change.outputs.DOCS_CHANGE == 'nope' }} | |
with: | |
name: next-swc-test-binary | |
path: packages/next-swc/native/next-swc.linux-x64-gnu.node | |
- name: Clear the cargo caches | |
if: ${{ steps.docs-change.outputs.DOCS_CHANGE == 'nope' }} | |
run: | | |
cargo install cargo-cache --no-default-features --features ci-autoclean | |
cargo-cache | |
test-native: | |
name: Unit Test Native Code | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 25 | |
- run: echo "SWC_CHANGE<<EOF" >> $GITHUB_OUTPUT; echo "$(node scripts/run-for-change.js --type next-swc --exec echo 'yup')" >> $GITHUB_OUTPUT; echo 'EOF' >> $GITHUB_OUTPUT | |
id: swc-change | |
- run: echo "${{ steps.swc-change.outputs.SWC_CHANGE }}" | |
- name: Install | |
if: ${{ steps.swc-change.outputs.SWC_CHANGE == 'yup' }} | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: ${{ env.RUST_TOOLCHAIN }} | |
profile: minimal | |
- run: cd packages/next-swc && cargo test | |
if: ${{ steps.swc-change.outputs.SWC_CHANGE == 'yup' }} | |
test-wasm: | |
name: Test the wasm build | |
runs-on: ubuntu-latest | |
timeout-minutes: 15 | |
needs: [build, build-native-test, build-wasm-dev] | |
steps: | |
- uses: actions/cache@v3 | |
timeout-minutes: 5 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
id: restore-build | |
with: | |
path: ./* | |
key: ${{ github.sha }} | |
- uses: actions/download-artifact@v3 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
with: | |
name: wasm-dev-binary | |
path: packages/next-swc/crates/wasm/pkg-nodejs | |
- run: ls packages/next-swc/crates/wasm | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
- uses: actions/download-artifact@v3 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
with: | |
name: next-swc-test-binary | |
path: packages/next-swc/native | |
- run: docker run --rm -v $(pwd):/work mcr.microsoft.com/playwright:v1.28.1-focal /bin/bash -c "cd /work && curl -s https://install-node.vercel.app/v${{ env.NODE_LTS_VERSION }} | FORCE=1 bash && node -v && node ./scripts/setup-wasm.mjs && npm i -g pnpm@${PNPM_VERSION} > /dev/null && TEST_WASM=true xvfb-run node run-tests.js test/integration/production/test/index.test.js test/e2e/streaming-ssr/index.test.ts >> /proc/1/fd/1" | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
# Build binaries for publishing | |
build-native: | |
strategy: | |
fail-fast: false | |
matrix: | |
settings: | |
# pnpm is aliased here temporarily until the build docker | |
# image is updated past Node.js v14.19 (current 14.18.1) | |
- host: macos-latest | |
target: 'x86_64-apple-darwin' | |
build: | | |
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" && if [ ! -f $(dirname $(which yarn))/pnpm ]; then ln -s $(which yarn) $(dirname $(which yarn))/pnpm;fi | |
turbo run build-native -- --release --target x86_64-apple-darwin | |
strip -x packages/next-swc/native/next-swc.*.node | |
- host: windows-latest | |
build: | | |
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" "pnpm@${PNPM_VERSION}" | |
turbo run build-native -- --release --target x86_64-pc-windows-msvc | |
target: 'x86_64-pc-windows-msvc' | |
- host: windows-latest | |
build: | | |
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" "pnpm@${PNPM_VERSION}" | |
turbo run build-native-no-plugin -- --release --target i686-pc-windows-msvc | |
target: 'i686-pc-windows-msvc' | |
- host: ubuntu-latest | |
target: 'x86_64-unknown-linux-gnu' | |
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:stable-2022-10-24-x64 | |
build: >- | |
set -e && | |
rustup toolchain install "${RUST_TOOLCHAIN}" && | |
rustup default "${RUST_TOOLCHAIN}" && | |
rustup target add x86_64-unknown-linux-gnu && | |
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" && if [ ! -f $(dirname $(which yarn))/pnpm ]; then ln -s $(which yarn) $(dirname $(which yarn))/pnpm;fi && | |
unset CC_x86_64_unknown_linux_gnu && unset CC && | |
turbo run build-native -- --release --target x86_64-unknown-linux-gnu && | |
strip packages/next-swc/native/next-swc.*.node | |
- host: ubuntu-latest | |
target: 'x86_64-unknown-linux-musl' | |
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:stable-2022-10-24-alpine | |
build: >- | |
set -e && | |
apk add --no-cache libc6-compat && | |
rustup toolchain install "${RUST_TOOLCHAIN}" && | |
rustup default "${RUST_TOOLCHAIN}" && | |
rustup target add x86_64-unknown-linux-musl && | |
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" && if [ ! -f $(dirname $(which yarn))/pnpm ]; then ln -s $(which yarn) $(dirname $(which yarn))/pnpm;fi && | |
turbo run build-native -- --release --target x86_64-unknown-linux-musl && | |
strip packages/next-swc/native/next-swc.*.node | |
- host: macos-latest | |
target: 'aarch64-apple-darwin' | |
build: | | |
sudo rm -Rf /Library/Developer/CommandLineTools/SDKs/*; | |
export CC=$(xcrun -f clang); | |
export CXX=$(xcrun -f clang++); | |
SYSROOT=$(xcrun --sdk macosx --show-sdk-path); | |
export CFLAGS="-isysroot $SYSROOT -isystem $SYSROOT"; | |
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" && if [ ! -f $(dirname $(which yarn))/pnpm ]; then ln -s $(which yarn) $(dirname $(which yarn))/pnpm;fi | |
turbo run build-native -- --release --target aarch64-apple-darwin | |
strip -x packages/next-swc/native/next-swc.*.node | |
- host: ubuntu-latest | |
target: 'aarch64-unknown-linux-gnu' | |
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:stable-2022-10-24-aarch64 | |
build: >- | |
set -e && | |
export JEMALLOC_SYS_WITH_LG_PAGE=16 && | |
rustup toolchain install "${RUST_TOOLCHAIN}" && | |
rustup default "${RUST_TOOLCHAIN}" && | |
rustup target add aarch64-unknown-linux-gnu && | |
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" && if [ ! -f $(dirname $(which yarn))/pnpm ]; then ln -s $(which yarn) $(dirname $(which yarn))/pnpm;fi && | |
export CC_aarch64_unknown_linux_gnu=/usr/aarch64-unknown-linux-gnu/bin/aarch64-unknown-linux-gnu-gcc && | |
turbo run build-native -- --release --target aarch64-unknown-linux-gnu && | |
llvm-strip -x packages/next-swc/native/next-swc.*.node | |
- host: ubuntu-latest | |
target: 'armv7-unknown-linux-gnueabihf' | |
setup: | | |
sudo apt-get update | |
sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf -y | |
build: | | |
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" && if [ ! -f $(dirname $(which yarn))/pnpm ]; then ln -s $(which yarn) $(dirname $(which yarn))/pnpm;fi | |
turbo run build-native-no-plugin -- --release --target armv7-unknown-linux-gnueabihf | |
arm-linux-gnueabihf-strip packages/next-swc/native/next-swc.*.node | |
- host: ubuntu-latest | |
target: aarch64-linux-android | |
build: | | |
export CLANG_VERSION=`ls ${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang | sed 's/ *$//g'` | |
export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android24-clang" | |
export CC="${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android24-clang" | |
export CXX="${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android24-clang++" | |
export AR="${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" | |
export PATH="${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin:${PATH}" | |
touch "${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/${CLANG_VERSION}/lib/linux/aarch64/libgcc.a" | |
chmod 777 "${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/${CLANG_VERSION}/lib/linux/aarch64/libgcc.a" | |
echo "INPUT(-lunwind)" > "${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/${CLANG_VERSION}/lib/linux/aarch64/libgcc.a" | |
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" && if [ ! -f $(dirname $(which yarn))/pnpm ]; then ln -s $(which yarn) $(dirname $(which yarn))/pnpm;fi | |
turbo run build-native -- --release --target aarch64-linux-android | |
${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip packages/next-swc/native/next-swc.*.node | |
- host: ubuntu-latest | |
target: armv7-linux-androideabi | |
build: | | |
export CLANG_VERSION=`ls ${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang | sed 's/ *$//g'` | |
export CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER="${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi24-clang" | |
export CC="${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi24-clang" | |
export CXX="${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi24-clang++" | |
export AR="${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" | |
export PATH="${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin:${PATH}" | |
touch "${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/${CLANG_VERSION}/lib/linux/arm/libgcc.a" | |
chmod 777 "${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/${CLANG_VERSION}/lib/linux/arm/libgcc.a" | |
echo "INPUT(-lunwind)" > "${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/${CLANG_VERSION}/lib/linux/arm/libgcc.a" | |
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" "pnpm@${PNPM_VERSION}" | |
turbo run build-native-no-plugin -- --release --target armv7-linux-androideabi | |
${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip packages/next-swc/native/next-swc.*.node | |
- host: ubuntu-latest | |
target: 'aarch64-unknown-linux-musl' | |
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:stable-2022-10-24-alpine | |
build: >- | |
set -e && | |
apk add --no-cache libc6-compat && | |
export JEMALLOC_SYS_WITH_LG_PAGE=16 && | |
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" && if [ ! -f $(dirname $(which yarn))/pnpm ]; then ln -s $(which yarn) $(dirname $(which yarn))/pnpm;fi && | |
rustup toolchain install "${RUST_TOOLCHAIN}" && | |
rustup default "${RUST_TOOLCHAIN}" && | |
rustup target add aarch64-unknown-linux-musl && | |
turbo run build-native -- --release --target aarch64-unknown-linux-musl && | |
llvm-strip -x packages/next-swc/native/next-swc.*.node | |
- host: windows-latest | |
target: 'aarch64-pc-windows-msvc' | |
build: | | |
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" "pnpm@${PNPM_VERSION}" | |
turbo run build-native-no-plugin-woa -- --release --target aarch64-pc-windows-msvc --cargo-flags=--no-default-features | |
if: ${{ needs.build.outputs.isRelease == 'true' || (needs.build.outputs.turboToken != 'empty') }} | |
needs: build | |
name: stable - ${{ matrix.settings.target }} - node@16 | |
runs-on: ${{ matrix.settings.host }} | |
env: | |
TURBO_TEAM: 'vercel' | |
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} | |
TURBO_REMOTE_ONLY: 'true' | |
steps: | |
# https://github.com/actions/virtual-environments/issues/1187 | |
- name: tune linux network | |
run: sudo ethtool -K eth0 tx off rx off | |
if: ${{ matrix.settings.host == 'ubuntu-latest' }} | |
- name: tune linux network | |
run: sudo ethtool -K eth0 tx off rx off | |
if: ${{ matrix.settings.host == 'ubuntu-latest' }} | |
- name: tune windows network | |
run: Disable-NetAdapterChecksumOffload -Name * -TcpIPv4 -UdpIPv4 -TcpIPv6 -UdpIPv6 | |
if: ${{ matrix.settings.host == 'windows-latest' }} | |
- name: tune mac network | |
run: sudo sysctl -w net.link.generic.system.hwcksum_tx=0 && sudo sysctl -w net.link.generic.system.hwcksum_rx=0 | |
if: ${{ matrix.settings.host == 'macos-latest' }} | |
# we use checkout here instead of the build cache since | |
# it can fail to restore in different OS' | |
- uses: actions/checkout@v3 | |
- name: Setup node | |
uses: actions/setup-node@v3 | |
if: ${{ !matrix.settings.docker }} | |
with: | |
node-version: 16 | |
check-latest: true | |
- name: Install | |
uses: actions-rs/toolchain@v1 | |
if: ${{ !matrix.settings.docker }} | |
with: | |
profile: minimal | |
override: true | |
toolchain: ${{ env.RUST_TOOLCHAIN }} | |
target: ${{ matrix.settings.target }} | |
- name: Cache cargo registry | |
uses: actions/cache@v3 | |
timeout-minutes: 5 | |
with: | |
path: ~/.cargo/registry | |
key: ${{ matrix.settings.target }}-cargo-registry | |
- name: Cache cargo index | |
uses: actions/cache@v3 | |
timeout-minutes: 5 | |
with: | |
path: ~/.cargo/git | |
key: ${{ matrix.settings.target }}-cargo-index | |
- name: normalize versions | |
run: node scripts/normalize-version-bump.js | |
- name: Setup toolchain | |
run: ${{ matrix.settings.setup }} | |
if: ${{ matrix.settings.setup }} | |
shell: bash | |
- name: Build in docker | |
uses: addnab/docker-run-action@v3 | |
if: ${{ matrix.settings.docker }} | |
with: | |
image: ${{ matrix.settings.docker }} | |
options: -e RUST_TOOLCHAIN=${{ env.RUST_TOOLCHAIN }} -e NAPI_CLI_VERSION=${{ env.NAPI_CLI_VERSION }} -e TURBO_VERSION=${{ env.TURBO_VERSION }} -e TURBO_TEAM=vercel -e TURBO_TOKEN=${{ secrets.TURBO_TOKEN }} -e TURBO_REMOTE_ONLY=true -v ${{ env.HOME }}/.cargo/git:/root/.cargo/git -v ${{ env.HOME }}/.cargo/registry:/root/.cargo/registry -v ${{ github.workspace }}:/build -w /build | |
run: ${{ matrix.settings.build }} | |
- name: 'Build' | |
run: ${{ matrix.settings.build }} | |
if: ${{ !matrix.settings.docker }} | |
shell: bash | |
- name: Upload artifact | |
if: ${{ needs.build.outputs.isRelease == 'true' }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: next-swc-binaries | |
path: packages/next-swc/native/next-swc.*.node | |
build-native-freebsd: | |
if: ${{ needs.build.outputs.isRelease == 'true' || (needs.build.outputs.turboToken != 'empty') }} | |
needs: build | |
name: stable - x86_64-unknown-freebsd - node@16 | |
runs-on: macos-12 | |
env: | |
TURBO_TEAM: 'vercel' | |
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} | |
TURBO_REMOTE_ONLY: 'true' | |
steps: | |
- name: tune mac network | |
run: sudo sysctl -w net.link.generic.system.hwcksum_tx=0 && sudo sysctl -w net.link.generic.system.hwcksum_rx=0 | |
- uses: actions/checkout@v3 | |
- name: Setup node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
check-latest: true | |
- run: npm i -g turbo@${{ env.TURBO_VERSION }} pnpm@${PNPM_VERSION} | |
- name: Delete useless files | |
run: | | |
rm -rf bench | |
rm -rf docs | |
rm -rf errors | |
rm -rf examples | |
rm -rf test | |
- run: node scripts/normalize-version-bump.js | |
# attempt pulling existing turbo cache, this must be done | |
# outside of the freeBSD vm as there isn't a turbo build | |
# for freeBSD currently | |
- run: node ./scripts/pull-freebsd-cache.js | |
- name: check build exists | |
run: if [ -f packages/next-swc/native/next-swc.freebsd-x64.node ]; then echo "BUILD_EXISTS=yes" >> $GITHUB_OUTPUT; else echo "BUILD_EXISTS=no" >> $GITHUB_OUTPUT; fi | |
id: build-exists | |
- run: echo "${{steps.build-exists.outputs.BUILD_EXISTS}}" | |
- name: Build | |
id: build | |
uses: vmactions/freebsd-vm@v0 | |
if: ${{ steps.build-exists.outputs.BUILD_EXISTS == 'no' }} | |
env: | |
DEBUG: napi:* | |
RUSTUP_HOME: /usr/local/rustup | |
CARGO_HOME: /usr/local/cargo | |
RUSTUP_IO_THREADS: 1 | |
# Disable LTO, or the lld may crash with OOM | |
CARGO_PROFILE_RELEASE_LTO: false | |
with: | |
envs: DEBUG RUSTUP_HOME CARGO_HOME RUSTUP_IO_THREADS CARGO_PROFILE_RELEASE_LTO NAPI_CLI_VERSION RUST_TOOLCHAIN PNPM_VERSION VM_RELEASE | |
usesh: true | |
mem: 6000 | |
prepare: | | |
pkg install -y -f curl node libnghttp2 | |
curl -qL https://www.npmjs.com/install.sh | sh | |
npm i -g pnpm@${PNPM_VERSION} "@napi-rs/cli@${NAPI_CLI_VERSION}" | |
curl https://sh.rustup.rs -sSf --output rustup.sh | |
sh rustup.sh -y --profile minimal --default-toolchain stable | |
export PATH="/usr/local/cargo/bin:$PATH" | |
echo "~~~~ rustc --version ~~~~" | |
rustc --version | |
echo "~~~~ node -v ~~~~" | |
node -v | |
run: | | |
export PATH="/usr/local/cargo/bin:$PATH" | |
pwd | |
ls -lah | |
whoami | |
env | |
freebsd-version | |
GITHUB_EVENT_PATH='' pnpm --filter=@next/swc run build-native-no-plugin --platform --release --target x86_64-unknown-freebsd | |
rm -rf node_modules | |
rm -rf packages/next-swc/target | |
- name: cache build | |
if: ${{ steps.build-exists.outputs.BUILD_EXISTS == 'no' }} | |
run: pnpm turbo run --force cache-build-native -- --platform --release --target x86_64-unknown-freebsd | |
- name: Upload artifact | |
if: ${{ needs.build.outputs.isRelease == 'true' }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: next-swc-binaries | |
path: packages/next-swc/native/next-swc.*.node | |
if-no-files-found: error | |
build-wasm: | |
needs: build | |
if: ${{ needs.build.outputs.isRelease == 'true' || (needs.build.outputs.turboToken != 'empty') }} | |
strategy: | |
matrix: | |
target: [web, nodejs] | |
runs-on: macos-latest | |
env: | |
TURBO_TEAM: 'vercel' | |
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} | |
TURBO_REMOTE_ONLY: 'true' | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
check-latest: true | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: ${{ env.RUST_TOOLCHAIN }} | |
override: true | |
target: wasm32-unknown-unknown | |
- run: npm i -g turbo@${{ env.TURBO_VERSION }} pnpm@${PNPM_VERSION} | |
- name: Install wasm-pack | |
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh | |
- name: normalize versions | |
run: node scripts/normalize-version-bump.js | |
- name: Build | |
run: turbo run build-wasm -- --target ${{ matrix.target }} | |
- name: Add target to folder name | |
run: '[[ -d "packages/next-swc/crates/wasm/pkg" ]] && mv packages/next-swc/crates/wasm/pkg packages/next-swc/crates/wasm/pkg-${{ matrix.target }} || ls packages/next-swc/crates/wasm' | |
- name: Upload artifact | |
if: ${{ needs.build.outputs.isRelease == 'true' }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: wasm-binaries | |
path: packages/next-swc/crates/wasm/pkg-* | |
build-wasm-dev: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/cache@v3 | |
timeout-minutes: 5 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
id: restore-build | |
with: | |
path: ./* | |
key: ${{ github.sha }}-${{ github.run_number }} | |
- name: Setup node | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
check-latest: true | |
- run: npm i -g turbo@${{ env.TURBO_VERSION }} pnpm@${PNPM_VERSION} | |
- name: Install Rust | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: ${{ env.RUST_TOOLCHAIN }} | |
override: true | |
target: wasm32-unknown-unknown | |
- name: Turbo Cache | |
id: turbo-cache | |
uses: actions/cache@v3 | |
timeout-minutes: 5 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
with: | |
path: .turbo | |
key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ steps.get-week.outputs.WEEK }}-${{ github.sha }} | |
restore-keys: | | |
turbo-${{ github.job }}- | |
turbo-${{ github.job }}-${{ github.ref_name }}-${{ steps.get-week.outputs.WEEK }}- | |
turbo-${{ github.job }}-canary-${{ steps.get-week.outputs.WEEK }}- | |
- name: Install wasm-pack | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh | |
- name: normalize versions | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
run: node scripts/normalize-version-bump.js | |
- name: Build | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
run: turbo run build-wasm --cache-dir=".turbo" -- --target nodejs --dev | |
- name: Add target to folder name | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
run: '[[ -d "packages/next-swc/crates/wasm/pkg" ]] && mv packages/next-swc/crates/wasm/pkg packages/next-swc/crates/wasm/pkg-nodejs || ls packages/next-swc/crates/wasm' | |
- name: Upload artifact | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: wasm-dev-binary | |
path: packages/next-swc/crates/wasm/pkg-nodejs | |
check-trace-secrests: | |
runs-on: ubuntu-latest | |
outputs: | |
trace-api-key: ${{ steps.trace-api-key.outputs.defined }} | |
steps: | |
- id: trace-api-key | |
env: | |
TRACE_API_KEY: ${{ secrets.DATA_DOG_API_KEY }} | |
if: "${{ env.TRACE_API_KEY != '' }}" | |
run: echo "defined=true" >> $GITHUB_OUTPUT | |
build-performance-metrics: | |
name: Performance Metrics for Release Build | |
runs-on: ubuntu-latest | |
needs: [build, build-native-test, check-trace-secrests] | |
if: needs.check-trace-secrests.outputs.trace-api-key == 'true' | |
env: | |
NEXT_TELEMETRY_DISABLED: 1 | |
steps: | |
- name: Setup node | |
uses: actions/setup-node@v3 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
with: | |
node-version: 16 | |
check-latest: true | |
- uses: actions/cache@v3 | |
timeout-minutes: 5 | |
id: restore-build | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
with: | |
path: ./* | |
key: ${{ github.sha }}-${{ github.run_number }} | |
- name: Set Git Short sha Env | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
run: echo "GIT_SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV | |
- name: Check Git Short sha Env | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
run: echo ${GIT_SHORT_SHA} | |
- uses: actions/download-artifact@v3 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
with: | |
name: next-swc-test-binary | |
path: packages/next-swc/native | |
- name: Generate metrics data | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
run: | | |
yarn --cwd bench/nested-deps install | |
node bench/nested-deps/bench.mjs build | |
- uses: datadog/agent-github-action@v1 | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
with: | |
api_key: ${{ secrets.DATA_DOG_API_KEY }} | |
- name: Sending metrics data to Datadog | |
if: ${{needs.build.outputs.docsChange == 'nope'}} | |
run: | | |
node scripts/trace-dd.mjs bench/nested-deps/.next/trace build ${GIT_SHORT_SHA} ./bench/nested-deps/next.config.js | |
env: | |
DATA_DOG_API_KEY: ${{ secrets.DATA_DOG_API_KEY }} | |
DD_TRACE_PARTIAL_FLUSH_MIN_SPANS: 10 | |
DD_ENV: canary | |
DD_SERVICE: nextjs-dev-build | |
DD_TRACE_DEBUG: true |