Chore/rust workflow (#30577)
* Remove prebuilt binaries from repo * Prefer locally built binary * Add binary packages as optionalDependencies * Remove build-native workflow for prebuilt binaries * Remove binaries from checkCompiled job * Change build-native command to default to dev * Add build-native-dev and have tests depend on it * Update contributing * Run ls to make inspect artifact download * Use correct artifact download path * Try using reusable workflows * Resort to duplication for now * Inspect artifact download * Ensure native is copied for PR stats * Copy after ref checkout and log binaries for PR stats * fix typo * copy right before linking/packing * Use fs.copy * fix test for now Co-authored-by: jj@jjsweb.site <jj@jjsweb.site>
This commit is contained in:
parent
c03e28425b
commit
b5a89160f7
16 changed files with 392 additions and 186 deletions
|
@ -118,6 +118,10 @@ if (!allowedActions.has(actionInfo.actionName) && !actionInfo.isRelease) {
|
|||
// in case of noisy environment slowing down initial repo build
|
||||
await exec(buildCommand, false, { timeout: 5 * 60 * 1000 })
|
||||
}
|
||||
await fs.copy(
|
||||
path.join(__dirname, '../native'),
|
||||
path.join(dir, 'packages/next/native')
|
||||
)
|
||||
|
||||
logger(`Linking packages in ${dir}`)
|
||||
const pkgPaths = await linkPackages(dir)
|
||||
|
|
|
@ -100,6 +100,10 @@ module.exports = (actionInfo) => {
|
|||
// make sure native binaries are included in local linking
|
||||
if (pkg === 'next') {
|
||||
pkgData.files.push('native')
|
||||
console.log(
|
||||
'using swc binaries: ',
|
||||
await exec(`ls ${path.join(path.dirname(pkgDataPath), 'native')}`)
|
||||
)
|
||||
}
|
||||
await fs.writeFile(
|
||||
pkgDataPath,
|
||||
|
|
107
.github/workflows/build_native.yml
vendored
107
.github/workflows/build_native.yml
vendored
|
@ -1,107 +0,0 @@
|
|||
on: workflow_dispatch
|
||||
|
||||
name: Build next-swc native binaries
|
||||
|
||||
jobs:
|
||||
build-native:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-18.04, macos-latest, windows-latest]
|
||||
description: [default]
|
||||
include:
|
||||
- os: ubuntu-18.04
|
||||
target: x86_64-unknown-linux-gnu
|
||||
name: linux-x64-gnu
|
||||
- os: windows-latest
|
||||
target: x86_64-pc-windows-msvc
|
||||
name: win32-x64-msvc
|
||||
- os: macos-latest
|
||||
target: x86_64-apple-darwin
|
||||
name: darwin-x64
|
||||
- os: macos-latest
|
||||
target: aarch64-apple-darwin
|
||||
name: darwin-arm64
|
||||
description: m1
|
||||
|
||||
name: next-swc - ${{ matrix.os }} - ${{ matrix.target }} - node@14
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 14
|
||||
check-latest: true
|
||||
- name: Install
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: nightly-2021-08-12
|
||||
target: ${{ matrix.target }}
|
||||
- name: Cache cargo registry
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ~/.cargo/registry
|
||||
key: stable-${{ matrix.os }}-node@14-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
|
||||
- name: Cache cargo index
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ~/.cargo/git
|
||||
key: stable-${{ matrix.os }}-node@14-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
|
||||
- name: Cache native binary
|
||||
id: binary-cache
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: packages/next/native/next-swc.${{ matrix.name }}.node
|
||||
key: next-swc-nightly-2021-08-12-${{ matrix.target }}-${{ hashFiles('.github/workflows/build_native.yml', 'packages/next/build/swc/**') }}
|
||||
- name: Cross build aarch64 setup
|
||||
if: ${{ matrix.target == 'aarch64-apple-darwin' && steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
|
||||
run: |
|
||||
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";
|
||||
# We use restore-key to pick latest cache.
|
||||
# We will not get exact match, but doc says
|
||||
# "If there are multiple partial matches for a restore key, the action returns the most recently created cache."
|
||||
# So we get latest cache
|
||||
- name: Cache built files
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ./packages/next/build/swc/target
|
||||
key: next-swc-cargo-cache-${{ matrix.os }}--${{ hashFiles('**/Cargo.lock') }}
|
||||
restore-keys: |
|
||||
next-swc-cargo-cache-${{ matrix.os }}-${{ matrix.target }}
|
||||
- name: 'Build'
|
||||
if: steps.binary-cache.outputs.cache-hit != true
|
||||
run: yarn build-native --target ${{ matrix.target }}
|
||||
env:
|
||||
MACOSX_DEPLOYMENT_TARGET: '10.13'
|
||||
working-directory: packages/next
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v2.2.4
|
||||
with:
|
||||
name: next-swc-binaries
|
||||
path: packages/next/native/next-swc.${{ matrix.name }}.node
|
||||
- name: Clear the cargo caches
|
||||
run: |
|
||||
cargo install cargo-cache --no-default-features --features ci-autoclean
|
||||
cargo-cache
|
||||
|
||||
commit:
|
||||
needs:
|
||||
- build-native
|
||||
runs-on: ubuntu-18.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/download-artifact@v2.0.10
|
||||
with:
|
||||
name: next-swc-binaries
|
||||
path: packages/next/native
|
||||
- uses: EndBug/add-and-commit@v7
|
||||
with:
|
||||
add: 'packages/next/native --force'
|
||||
message: 'Build next-swc binaries'
|
213
.github/workflows/build_test_deploy.yml
vendored
213
.github/workflows/build_test_deploy.yml
vendored
|
@ -96,18 +96,6 @@ jobs:
|
|||
- run: rm -rf .git && mv .git-bak .git
|
||||
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
|
||||
|
||||
- uses: actions/download-artifact@v2
|
||||
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
|
||||
with:
|
||||
name: next-swc-binaries
|
||||
path: packages/next/build/swc/dist
|
||||
|
||||
# Only check linux build for now, mac builds can sometimes be different even with the same code
|
||||
- run: |
|
||||
mv ./packages/next/build/swc/dist/next-swc.linux-x64-gnu.node \
|
||||
./packages/next/native/next-swc.linux-x64-gnu.node
|
||||
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
|
||||
|
||||
- run: ./scripts/check-pre-compiled.sh
|
||||
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
|
||||
|
||||
|
@ -120,7 +108,7 @@ jobs:
|
|||
testUnit:
|
||||
name: Test Unit
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
needs: [build, build-native-dev]
|
||||
env:
|
||||
NEXT_TELEMETRY_DISABLED: 1
|
||||
NEXT_TEST_JOB: 1
|
||||
|
@ -132,13 +120,18 @@ jobs:
|
|||
path: ./*
|
||||
key: ${{ github.sha }}
|
||||
|
||||
- uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: next-swc-dev-binary
|
||||
path: packages/next/native
|
||||
|
||||
- run: node run-tests.js --type unit
|
||||
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
|
||||
|
||||
testDev:
|
||||
name: Test Development
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
needs: [build, build-native-dev]
|
||||
env:
|
||||
NEXT_TELEMETRY_DISABLED: 1
|
||||
NEXT_TEST_JOB: 1
|
||||
|
@ -156,6 +149,11 @@ jobs:
|
|||
path: ./*
|
||||
key: ${{ github.sha }}
|
||||
|
||||
- uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: next-swc-dev-binary
|
||||
path: packages/next/native
|
||||
|
||||
- run: npm i -g playwright-chromium@1.14.1 && npx playwright install-deps
|
||||
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
|
||||
|
||||
|
@ -184,7 +182,7 @@ jobs:
|
|||
testProd:
|
||||
name: Test Production
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
needs: [build, build-native-dev]
|
||||
env:
|
||||
NEXT_TELEMETRY_DISABLED: 1
|
||||
NEXT_TEST_JOB: 1
|
||||
|
@ -202,6 +200,11 @@ jobs:
|
|||
path: ./*
|
||||
key: ${{ github.sha }}
|
||||
|
||||
- uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: next-swc-dev-binary
|
||||
path: packages/next/native
|
||||
|
||||
- run: npm i -g playwright-chromium@1.14.1 && npx playwright install-deps
|
||||
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
|
||||
|
||||
|
@ -220,7 +223,7 @@ jobs:
|
|||
testIntegration:
|
||||
name: Test Integration
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
needs: [build, build-native-dev]
|
||||
env:
|
||||
NEXT_TELEMETRY_DISABLED: 1
|
||||
NEXT_TEST_JOB: 1
|
||||
|
@ -243,6 +246,11 @@ jobs:
|
|||
path: ./*
|
||||
key: ${{ github.sha }}
|
||||
|
||||
- uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: next-swc-dev-binary
|
||||
path: packages/next/native
|
||||
|
||||
- run: npm i -g playwright-chromium@1.14.1 && npx playwright install-deps
|
||||
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
|
||||
|
||||
|
@ -266,7 +274,7 @@ jobs:
|
|||
testElectron:
|
||||
name: Test Electron
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
needs: [build, build-native-dev]
|
||||
env:
|
||||
NEXT_TELEMETRY_DISABLED: 1
|
||||
NEXT_TEST_JOB: 1
|
||||
|
@ -279,6 +287,11 @@ jobs:
|
|||
path: ./*
|
||||
key: ${{ github.sha }}
|
||||
|
||||
- uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: next-swc-dev-binary
|
||||
path: packages/next/native
|
||||
|
||||
# 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 change'}}
|
||||
|
@ -291,7 +304,7 @@ jobs:
|
|||
|
||||
testYarnPnP:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
needs: [build, build-native-dev]
|
||||
env:
|
||||
NODE_OPTIONS: '--unhandled-rejections=strict'
|
||||
YARN_COMPRESSION_LEVEL: '0'
|
||||
|
@ -303,6 +316,11 @@ jobs:
|
|||
path: ./*
|
||||
key: ${{ github.sha }}
|
||||
|
||||
- uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: next-swc-dev-binary
|
||||
path: packages/next/native
|
||||
|
||||
- run: bash ./scripts/test-pnp.sh
|
||||
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
|
||||
|
||||
|
@ -327,7 +345,7 @@ jobs:
|
|||
testFirefox:
|
||||
name: Test Firefox (production)
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
needs: [build, build-native-dev]
|
||||
env:
|
||||
BROWSER_NAME: 'firefox'
|
||||
NEXT_TELEMETRY_DISABLED: 1
|
||||
|
@ -338,6 +356,10 @@ jobs:
|
|||
with:
|
||||
path: ./*
|
||||
key: ${{ github.sha }}
|
||||
- uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: next-swc-dev-binary
|
||||
path: packages/next/native
|
||||
- run: npx playwright install-deps && npx playwright install firefox
|
||||
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
|
||||
- run: node run-tests.js test/integration/production/test/index.test.js
|
||||
|
@ -346,7 +368,7 @@ jobs:
|
|||
testSafari:
|
||||
name: Test Safari (production)
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
needs: [build, build-native-dev]
|
||||
env:
|
||||
BROWSERSTACK: true
|
||||
BROWSER_NAME: 'safari'
|
||||
|
@ -366,6 +388,11 @@ jobs:
|
|||
path: ./*
|
||||
key: ${{ github.sha }}
|
||||
|
||||
- uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: next-swc-dev-binary
|
||||
path: packages/next/native
|
||||
|
||||
# TODO: use macos runner so that we can use playwright to test against
|
||||
# PRs instead of only running on canary?
|
||||
- run: '[[ -z "$BROWSERSTACK_ACCESS_KEY" ]] && echo "Skipping for PR" || npm i -g browserstack-local@1.4.0'
|
||||
|
@ -377,7 +404,7 @@ jobs:
|
|||
testSafariOld:
|
||||
name: Test Safari 10.1 (nav)
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build, testSafari]
|
||||
needs: [build, testSafari, build-native-dev]
|
||||
env:
|
||||
BROWSERSTACK: true
|
||||
LEGACY_SAFARI: true
|
||||
|
@ -398,6 +425,11 @@ jobs:
|
|||
path: ./*
|
||||
key: ${{ github.sha }}
|
||||
|
||||
- uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: next-swc-dev-binary
|
||||
path: packages/next/native
|
||||
|
||||
- run: '[[ -z "$BROWSERSTACK_ACCESS_KEY" ]] && echo "Skipping for PR" || npm i -g browserstack-local@1.4.0'
|
||||
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
|
||||
|
||||
|
@ -454,7 +486,111 @@ jobs:
|
|||
env:
|
||||
PR_STATS_COMMENT_TOKEN: ${{ secrets.PR_STATS_COMMENT_TOKEN }}
|
||||
|
||||
build-native-dev:
|
||||
name: Build dev binary for tests
|
||||
runs-on: ubuntu-18.04
|
||||
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@v2
|
||||
with:
|
||||
fetch-depth: 25
|
||||
|
||||
- run: echo ::set-output name=DOCS_CHANGE::$(node skip-docs-change.js echo 'not-docs-only-change')
|
||||
id: docs-change
|
||||
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v2
|
||||
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
|
||||
with:
|
||||
node-version: 14
|
||||
check-latest: true
|
||||
|
||||
- name: Install
|
||||
uses: actions-rs/toolchain@v1
|
||||
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: nightly-2021-08-12
|
||||
|
||||
- name: Cache cargo registry
|
||||
uses: actions/cache@v1
|
||||
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
|
||||
with:
|
||||
path: ~/.cargo/registry
|
||||
key: stable-ubuntu-18.04-node@14-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
- name: Cache cargo index
|
||||
uses: actions/cache@v1
|
||||
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
|
||||
with:
|
||||
path: ~/.cargo/git
|
||||
key: stable-ubuntu-18.04-node@14-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
- name: Cache native binary
|
||||
id: binary-cache
|
||||
uses: actions/cache@v2
|
||||
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
|
||||
with:
|
||||
path: packages/next/native/next-swc.linux-x64-gnu.node
|
||||
key: dev-next-swc-nightly-2021-08-12-linux-x64-gnu-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next/build/swc/**') }}
|
||||
|
||||
# We use restore-key to pick latest cache.
|
||||
# We will not get exact match, but doc says
|
||||
# "If there are multiple partial matches for a restore key, the action returns the most recently created cache."
|
||||
# So we get latest cache
|
||||
- name: Cache built files
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ./packages/next/build/swc/target
|
||||
key: next-swc-cargo-cache-ubuntu-18.04--${{ hashFiles('**/Cargo.lock') }}
|
||||
restore-keys: |
|
||||
next-swc-cargo-cache-ubuntu-18.04
|
||||
|
||||
- name: Build
|
||||
if: ${{ steps.binary-cache.outputs.cache-hit != 'true' && steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
|
||||
run: yarn build-native
|
||||
env:
|
||||
MACOSX_DEPLOYMENT_TARGET: '10.13'
|
||||
working-directory: packages/next
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v2.2.4
|
||||
with:
|
||||
name: next-swc-dev-binary
|
||||
path: packages/next/native/next-swc.linux-x64-gnu.node
|
||||
|
||||
- name: Clear the cargo caches
|
||||
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
|
||||
run: |
|
||||
cargo install cargo-cache --no-default-features --features ci-autoclean
|
||||
cargo-cache
|
||||
|
||||
test-native:
|
||||
name: Unit Test Native Code
|
||||
runs-on: ubuntu-18.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 25
|
||||
- run: echo ::set-output name=DOCS_CHANGE::$(node skip-docs-change.js echo 'not-docs-only-change')
|
||||
id: docs-change
|
||||
- name: Install
|
||||
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: nightly-2021-08-12
|
||||
profile: minimal
|
||||
- run: cd packages/next/build/swc && cargo test
|
||||
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
|
||||
|
||||
# Build binaries for publishing
|
||||
build-native:
|
||||
needs: build
|
||||
if: ${{ needs.build.outputs.isRelease == 'true' }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-18.04, macos-latest, windows-latest]
|
||||
|
@ -547,7 +683,7 @@ jobs:
|
|||
next-swc-cargo-cache-${{ matrix.os }}
|
||||
- name: 'Build'
|
||||
if: ${{ steps.binary-cache.outputs.cache-hit != 'true' && steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
|
||||
run: yarn build-native --target ${{ matrix.target }}
|
||||
run: yarn build-native --release --target ${{ matrix.target }}
|
||||
env:
|
||||
MACOSX_DEPLOYMENT_TARGET: '10.13'
|
||||
working-directory: packages/next
|
||||
|
@ -562,25 +698,6 @@ jobs:
|
|||
cargo install cargo-cache --no-default-features --features ci-autoclean
|
||||
cargo-cache
|
||||
|
||||
test-native:
|
||||
name: Unit Test Native Code
|
||||
runs-on: ubuntu-18.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 25
|
||||
- run: echo ::set-output name=DOCS_CHANGE::$(node skip-docs-change.js echo 'not-docs-only-change')
|
||||
id: docs-change
|
||||
- name: Install
|
||||
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: nightly-2021-08-12
|
||||
profile: minimal
|
||||
- run: cd packages/next/build/swc && cargo test
|
||||
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
|
||||
|
||||
build-windows-i686:
|
||||
needs: build
|
||||
if: ${{ needs.build.outputs.isRelease == 'true' }}
|
||||
|
@ -630,7 +747,7 @@ jobs:
|
|||
- name: Build
|
||||
if: ${{ steps.binary-cache.outputs.cache-hit != 'true' && steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
|
||||
shell: bash
|
||||
run: yarn build-native --target i686-pc-windows-msvc
|
||||
run: yarn build-native --release --target i686-pc-windows-msvc
|
||||
working-directory: packages/next
|
||||
|
||||
- name: Upload artifact
|
||||
|
@ -677,7 +794,7 @@ jobs:
|
|||
- name: Build
|
||||
if: ${{ steps.binary-cache.outputs.cache-hit != 'true' && steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
|
||||
shell: bash
|
||||
run: yarn build-native --target aarch64-pc-windows-msvc
|
||||
run: yarn build-native --release --target aarch64-pc-windows-msvc
|
||||
working-directory: packages/next
|
||||
|
||||
- name: Upload artifact
|
||||
|
@ -733,7 +850,7 @@ jobs:
|
|||
# - name: 'Build'
|
||||
# if: ${{ steps.binary-cache.outputs.cache-hit != 'true' && steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
|
||||
# run: |
|
||||
# docker run --rm -v $(pwd)/packages/next:/swc -w /swc builder sh -c "yarn build-native"
|
||||
# docker run --rm -v $(pwd)/packages/next:/swc -w /swc builder sh -c "yarn build-native --release"
|
||||
|
||||
# - name: Upload artifact
|
||||
# if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
|
||||
|
@ -794,7 +911,7 @@ jobs:
|
|||
|
||||
- name: Cross build aarch64
|
||||
if: ${{ steps.binary-cache.outputs.cache-hit != 'true' && steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
|
||||
run: yarn build-native --target aarch64-unknown-linux-gnu
|
||||
run: yarn build-native --release --target aarch64-unknown-linux-gnu
|
||||
working-directory: packages/next
|
||||
|
||||
- name: Upload artifact
|
||||
|
@ -854,7 +971,7 @@ jobs:
|
|||
|
||||
- name: Cross build aarch64
|
||||
if: ${{ steps.binary-cache.outputs.cache-hit != 'true' && steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
|
||||
run: yarn build-native --target aarch64-unknown-linux-musl
|
||||
run: yarn build-native --release --target aarch64-unknown-linux-musl
|
||||
working-directory: packages/next
|
||||
|
||||
- name: Upload artifact
|
||||
|
@ -916,7 +1033,7 @@ jobs:
|
|||
|
||||
- name: Cross build aarch64
|
||||
if: ${{ steps.binary-cache.outputs.cache-hit != 'true' && steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
|
||||
run: yarn build-native --target armv7-unknown-linux-gnueabihf
|
||||
run: yarn build-native --release --target armv7-unknown-linux-gnueabihf
|
||||
working-directory: packages/next
|
||||
|
||||
- name: Upload artifact
|
||||
|
@ -965,7 +1082,7 @@ jobs:
|
|||
shell: bash
|
||||
run: |
|
||||
export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android24-clang"
|
||||
yarn build-native --target aarch64-linux-android
|
||||
yarn build-native --release --target aarch64-linux-android
|
||||
working-directory: packages/next
|
||||
|
||||
- name: Upload artifact
|
||||
|
|
96
.github/workflows/pull_request_stats.yml
vendored
96
.github/workflows/pull_request_stats.yml
vendored
|
@ -5,14 +5,104 @@ on:
|
|||
name: Generate Pull Request Stats
|
||||
|
||||
jobs:
|
||||
stats:
|
||||
name: PR Stats
|
||||
runs-on: ubuntu-latest
|
||||
build-native-dev:
|
||||
name: Build dev binary for tests
|
||||
runs-on: ubuntu-18.04
|
||||
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@v2
|
||||
with:
|
||||
fetch-depth: 25
|
||||
|
||||
- run: echo ::set-output name=DOCS_CHANGE::$(node skip-docs-change.js echo 'not-docs-only-change')
|
||||
id: docs-change
|
||||
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v2
|
||||
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
|
||||
with:
|
||||
node-version: 14
|
||||
check-latest: true
|
||||
|
||||
- name: Install
|
||||
uses: actions-rs/toolchain@v1
|
||||
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: nightly-2021-08-12
|
||||
|
||||
- name: Cache cargo registry
|
||||
uses: actions/cache@v1
|
||||
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
|
||||
with:
|
||||
path: ~/.cargo/registry
|
||||
key: stable-ubuntu-18.04-node@14-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
- name: Cache cargo index
|
||||
uses: actions/cache@v1
|
||||
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
|
||||
with:
|
||||
path: ~/.cargo/git
|
||||
key: stable-ubuntu-18.04-node@14-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
- name: Cache native binary
|
||||
id: binary-cache
|
||||
uses: actions/cache@v2
|
||||
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
|
||||
with:
|
||||
path: packages/next/native/next-swc.linux-x64-gnu.node
|
||||
key: dev-next-swc-nightly-2021-08-12-linux-x64-gnu-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next/build/swc/**') }}
|
||||
|
||||
# We use restore-key to pick latest cache.
|
||||
# We will not get exact match, but doc says
|
||||
# "If there are multiple partial matches for a restore key, the action returns the most recently created cache."
|
||||
# So we get latest cache
|
||||
- name: Cache built files
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ./packages/next/build/swc/target
|
||||
key: next-swc-cargo-cache-ubuntu-18.04--${{ hashFiles('**/Cargo.lock') }}
|
||||
restore-keys: |
|
||||
next-swc-cargo-cache-ubuntu-18.04
|
||||
|
||||
- name: Build
|
||||
if: ${{ steps.binary-cache.outputs.cache-hit != 'true' && steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
|
||||
run: yarn build-native
|
||||
env:
|
||||
MACOSX_DEPLOYMENT_TARGET: '10.13'
|
||||
working-directory: packages/next
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v2.2.4
|
||||
with:
|
||||
name: next-swc-dev-binary
|
||||
path: packages/next/native/next-swc.linux-x64-gnu.node
|
||||
|
||||
- name: Clear the cargo caches
|
||||
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
|
||||
run: |
|
||||
cargo install cargo-cache --no-default-features --features ci-autoclean
|
||||
cargo-cache
|
||||
|
||||
stats:
|
||||
name: PR Stats
|
||||
needs: build-native-dev
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 25
|
||||
|
||||
- uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: next-swc-dev-binary
|
||||
path: packages/next/native
|
||||
|
||||
- run: cp -r packages/next/native .github/actions/next-stats-action/native
|
||||
|
||||
- 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
|
||||
|
|
|
@ -51,14 +51,14 @@ yarn build
|
|||
yarn prepublish
|
||||
```
|
||||
|
||||
By default the latest canary of the next-swc binaries will be installed and used. If you are actively working on Rust code or you need to test out the most recent Rust code that hasn't been published as a canary yet you can [install Rust](https://www.rust-lang.org/tools/install) and run `yarn --cwd packages/next build-native`.
|
||||
|
||||
If you need to clean the project for any reason, use `yarn clean`.
|
||||
|
||||
## Testing
|
||||
|
||||
See the [testing readme](./test/readme.md) for information on writing tests.
|
||||
|
||||
You may have to [install Rust](https://www.rust-lang.org/tools/install) and build our native packages to see all tests pass locally. We check in binaries for the most common targets and those required for CI so that most people don't have to, but if you do not see a binary for your target in `packages/next/native`, you can build it by running `yarn --cwd packages/next build-native`. If you are working on the Rust code and you need to build the binaries for ci, you can manually trigger [the workflow](https://github.com/vercel/next.js/actions/workflows/build_native.yml) to build and commit with the "Run workflow" button.
|
||||
|
||||
### Running tests
|
||||
|
||||
```sh
|
||||
|
|
13
package.json
13
package.json
|
@ -160,6 +160,19 @@
|
|||
"webpack-bundle-analyzer": "4.3.0",
|
||||
"worker-loader": "3.0.7"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@next/swc-android-arm64": "canary",
|
||||
"@next/swc-darwin-arm64": "canary",
|
||||
"@next/swc-darwin-x64": "canary",
|
||||
"@next/swc-linux-arm-gnueabihf": "canary",
|
||||
"@next/swc-linux-arm64-gnu": "canary",
|
||||
"@next/swc-linux-arm64-musl": "canary",
|
||||
"@next/swc-linux-x64-gnu": "canary",
|
||||
"@next/swc-linux-x64-musl": "canary",
|
||||
"@next/swc-win32-arm64-msvc": "canary",
|
||||
"@next/swc-win32-ia32-msvc": "canary",
|
||||
"@next/swc-win32-x64-msvc": "canary"
|
||||
},
|
||||
"resolutions": {
|
||||
"browserslist": "4.16.6",
|
||||
"caniuse-lite": "1.0.30001271"
|
||||
|
|
|
@ -1,30 +1,49 @@
|
|||
const { loadBinding } = require('@node-rs/helper')
|
||||
const fs = require('fs')
|
||||
const { platform, arch } = require('os')
|
||||
const path = require('path')
|
||||
const { platformArchTriples } = require('@napi-rs/triples')
|
||||
const Log = require('../output/log')
|
||||
|
||||
/**
|
||||
* __dirname means load native addon from current dir
|
||||
* 'next-swc' is the name of native addon
|
||||
* the second arguments was decided by `napi.name` field in `package.json`
|
||||
* the third arguments was decided by `name` field in `package.json`
|
||||
* `loadBinding` helper will load `next-swc.[PLATFORM].node` from `__dirname` first
|
||||
* If failed to load addon, it will fallback to load from `next-swc-[PLATFORM]`
|
||||
*/
|
||||
let bindings
|
||||
const ArchName = arch()
|
||||
const PlatformName = platform()
|
||||
|
||||
try {
|
||||
bindings = loadBinding(
|
||||
path.join(__dirname, '../../../native'),
|
||||
'next-swc',
|
||||
'@next/swc'
|
||||
let bindings
|
||||
let loadError
|
||||
const triples = platformArchTriples[PlatformName][ArchName]
|
||||
for (const triple of triples) {
|
||||
const localFilePath = path.join(
|
||||
__dirname,
|
||||
'../../../native',
|
||||
`next-swc.${triple.platformArchABI}.node`
|
||||
)
|
||||
} catch (err) {
|
||||
// only log the original error message as the stack is not
|
||||
// helpful to the user
|
||||
console.error(err.message)
|
||||
if (fs.existsSync(localFilePath)) {
|
||||
Log.info('Using locally built binary of next-swc')
|
||||
try {
|
||||
bindings = require(localFilePath)
|
||||
} catch (e) {
|
||||
loadError = e
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
try {
|
||||
bindings = require(`@next/swc-${triple.platformArchABI}`)
|
||||
break
|
||||
} catch (e) {
|
||||
if (e?.code !== 'MODULE_NOT_FOUND') {
|
||||
loadError = e
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!bindings) {
|
||||
if (loadError) {
|
||||
console.error(loadError)
|
||||
}
|
||||
|
||||
Log.error(
|
||||
`failed to load SWC binary, see more info here: https://nextjs.org/docs/messages/failed-loading-swc`
|
||||
`Failed to load SWC binary, see more info here: https://nextjs.org/docs/messages/failed-loading-swc`
|
||||
)
|
||||
process.exit(1)
|
||||
}
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -56,7 +56,7 @@
|
|||
"types": "tsc --declaration --emitDeclarationOnly --declarationDir dist",
|
||||
"typescript": "tsc --noEmit --declaration",
|
||||
"ncc-compiled": "ncc cache clean && taskr ncc",
|
||||
"build-native": "npx -p @napi-rs/cli@1.2.1 napi build --platform --release --cargo-cwd build/swc native"
|
||||
"build-native": "npx -p @napi-rs/cli@1.2.1 napi build --platform --cargo-cwd build/swc native"
|
||||
},
|
||||
"taskr": {
|
||||
"requires": [
|
||||
|
@ -71,7 +71,7 @@
|
|||
"@next/polyfill-module": "12.0.2-canary.9",
|
||||
"@next/react-dev-overlay": "12.0.2-canary.9",
|
||||
"@next/react-refresh-utils": "12.0.2-canary.9",
|
||||
"@node-rs/helper": "1.2.1",
|
||||
"@napi-rs/triples": "1.0.3",
|
||||
"acorn": "8.5.0",
|
||||
"assert": "2.0.0",
|
||||
"browserify-zlib": "0.2.0",
|
||||
|
|
|
@ -21,7 +21,7 @@ const cwd = process.cwd()
|
|||
)
|
||||
|
||||
const publishedPkgs = new Set()
|
||||
// TODO: update to latest version where all pacakges were
|
||||
// TODO: update to latest version where all packages were
|
||||
// successfully published
|
||||
const fallbackVersion = `12.0.1`
|
||||
|
||||
|
|
|
@ -11,11 +11,22 @@ const indexPageBak = `${indexPage}.bak`
|
|||
|
||||
describe('Mixed getStaticProps and getServerSideProps error', () => {
|
||||
it('should error when exporting both getStaticProps and getServerSideProps', async () => {
|
||||
// TODO: remove after investigating why dev swc build fails here
|
||||
await fs.writeFile(
|
||||
join(appDir, '.babelrc'),
|
||||
'{ "presets": ["next/babel"] }'
|
||||
)
|
||||
const { stderr } = await nextBuild(appDir, [], { stderr: true })
|
||||
await fs.remove(join(appDir, '.babelrc'))
|
||||
expect(stderr).toContain(SERVER_PROPS_SSG_CONFLICT)
|
||||
})
|
||||
|
||||
it('should error when exporting both getStaticPaths and getServerSideProps', async () => {
|
||||
// TODO: remove after investigating why dev swc build fails here
|
||||
await fs.writeFile(
|
||||
join(appDir, '.babelrc'),
|
||||
'{ "presets": ["next/babel"] }'
|
||||
)
|
||||
await fs.move(indexPage, indexPageBak)
|
||||
await fs.writeFile(
|
||||
indexPage,
|
||||
|
@ -36,7 +47,7 @@ describe('Mixed getStaticProps and getServerSideProps error', () => {
|
|||
`
|
||||
)
|
||||
const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
|
||||
|
||||
await fs.remove(join(appDir, '.babelrc'))
|
||||
await fs.remove(indexPage)
|
||||
await fs.move(indexPageBak, indexPage)
|
||||
expect(code).toBe(1)
|
||||
|
|
59
yarn.lock
59
yarn.lock
|
@ -3553,12 +3553,67 @@
|
|||
toml "^3.0.0"
|
||||
tslib "^2.2.0"
|
||||
|
||||
"@napi-rs/triples@^1.0.3":
|
||||
"@napi-rs/triples@1.0.3", "@napi-rs/triples@^1.0.3":
|
||||
version "1.0.3"
|
||||
resolved "https://registry.yarnpkg.com/@napi-rs/triples/-/triples-1.0.3.tgz#76d6d0c3f4d16013c61e45dfca5ff1e6c31ae53c"
|
||||
integrity sha512-jDJTpta+P4p1NZTFVLHJ/TLFVYVcOqv6l8xwOeBKNPMgY/zDYH/YH7SJbvrr/h1RcS9GzbPcLKGzpuK9cV56UA==
|
||||
|
||||
"@node-rs/helper@1.2.1", "@node-rs/helper@^1.0.0":
|
||||
"@next/swc-android-arm64@canary":
|
||||
version "12.0.2-canary.6"
|
||||
resolved "https://registry.yarnpkg.com/@next/swc-android-arm64/-/swc-android-arm64-12.0.2-canary.6.tgz#565ae8142102059cc2ae287daac31567855e1eb3"
|
||||
integrity sha512-1wwB9DOPRrlyLFud16NzszDuaI+Tv8AoD0oGTtropjyXlVZTWQb2YDqCZScCaOdnAs1Vc/MDF07bdXIpC3If0g==
|
||||
|
||||
"@next/swc-darwin-arm64@canary":
|
||||
version "12.0.2-canary.5"
|
||||
resolved "https://registry.yarnpkg.com/@next/swc-darwin-arm64/-/swc-darwin-arm64-12.0.2-canary.5.tgz#bc76e5432d15bfd293bcd0be8972a82eadcbdc5f"
|
||||
integrity sha512-6ro6LoIjF5eMjadwNDdESge7XNsZfC9xcbmPX45jzLSI/W3Q7LFBBrxkwFGME/FYJWJrabgRaQd6wBH0+mQKYQ==
|
||||
|
||||
"@next/swc-darwin-x64@canary":
|
||||
version "12.0.2-canary.6"
|
||||
resolved "https://registry.yarnpkg.com/@next/swc-darwin-x64/-/swc-darwin-x64-12.0.2-canary.6.tgz#90c11c8f6526bad08769a710d83d3eebb5ac9dfe"
|
||||
integrity sha512-tSLZoEBb4DipRK20Gy15iwe44pXYnSzkP2bb+oXRXYnf/TqSr4cLqRtImw+hVm+uBtX5TCQwhDwMJPLX1C9pAg==
|
||||
|
||||
"@next/swc-linux-arm-gnueabihf@canary":
|
||||
version "12.0.2-canary.6"
|
||||
resolved "https://registry.yarnpkg.com/@next/swc-linux-arm-gnueabihf/-/swc-linux-arm-gnueabihf-12.0.2-canary.6.tgz#a5c06dd79c3f3e4da74ac84e42538a26bf87fc88"
|
||||
integrity sha512-WIsTGpOBRcDG2S9gllyM/BswBNnD1oYt8V6PHZGCk1+MvY73IvjvuW2Mq/w7kT8onWzqe6mJec+DdoBKXpZMSQ==
|
||||
|
||||
"@next/swc-linux-arm64-gnu@canary":
|
||||
version "12.0.2-canary.6"
|
||||
resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-12.0.2-canary.6.tgz#0b371b7bb2e7036581b54dc28c5deb9fa47b22df"
|
||||
integrity sha512-Wv1mVMkhVU027Bai9c3pKlRTFE/4lrYkA5E4naiQnTIgyh6zf/y7DK7BaQVqQdcAAV7OxcQu7AHSdA1Lco9YOQ==
|
||||
|
||||
"@next/swc-linux-arm64-musl@canary":
|
||||
version "12.0.2-canary.6"
|
||||
resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-12.0.2-canary.6.tgz#a2ada1198e59d5c37c86fc93a16bf8b48aa104eb"
|
||||
integrity sha512-+7LL9Zsk+JemQ1qSju/bwv9tqMdD+xHsTuudbqkui+/2D0l+lGjf5xuVJd+1BLXJMJm1l0eD/ZOTdzo6UT9fdQ==
|
||||
|
||||
"@next/swc-linux-x64-gnu@canary":
|
||||
version "12.0.2-canary.6"
|
||||
resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-12.0.2-canary.6.tgz#f25441bbd9aa8b39eca9056900762e68ebaf4fe5"
|
||||
integrity sha512-3qLl07K+EYCM9eQlogg0GX/A7rPLecMKU/2Aq6iSvdPALzBfRxuYQNR9RgRvIzxcaGqPJmwEKm/+omTJakYnOg==
|
||||
|
||||
"@next/swc-linux-x64-musl@canary":
|
||||
version "12.0.2-canary.2"
|
||||
resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-12.0.2-canary.2.tgz#b3ce05442610e16d50cba8302f243bebdc2d61bc"
|
||||
integrity sha512-RnWuxoHmYB4JEo0Yt9pdx5+8mbqvxr0vfULPWOzY03qLILNQakYFuZzKgtuE3DkFYeJF7yEtEAMhJ0cAwVKRSw==
|
||||
|
||||
"@next/swc-win32-arm64-msvc@canary":
|
||||
version "12.0.2-canary.6"
|
||||
resolved "https://registry.yarnpkg.com/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-12.0.2-canary.6.tgz#1a8bbc514bcf544f6fe718a4394c3f236d847e90"
|
||||
integrity sha512-2JPb7/8Dh1LS1iNC96hyWpZ4DFPi31m+bCMT1E5HaXkj75hkVjGFTNGiN3WRQ0t30kGIaBwhEh9scEWoyTcGyw==
|
||||
|
||||
"@next/swc-win32-ia32-msvc@canary":
|
||||
version "12.0.2-canary.6"
|
||||
resolved "https://registry.yarnpkg.com/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-12.0.2-canary.6.tgz#5b97d35e13c6877efb9701f91bd8dc6a0e0763f9"
|
||||
integrity sha512-qHczht2xKYMi/ufz1zahihrmToCKUvkwz3Rdn4M8GRbYyKlrlmiv/hRskjVx6iyU34LUPzGWasaL/xcckMe00w==
|
||||
|
||||
"@next/swc-win32-x64-msvc@canary":
|
||||
version "12.0.2-canary.6"
|
||||
resolved "https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-12.0.2-canary.6.tgz#031d808abd611a22e8c930baf8c15991bacb8112"
|
||||
integrity sha512-ndmHXAtMwHr98HulDWNtVEXQXS/aXrQZncLCCtkKMztqGSExLYZtjrGpHnFuKfcuwGEC9izmnVDpm5hG0rPxbQ==
|
||||
|
||||
"@node-rs/helper@^1.0.0":
|
||||
version "1.2.1"
|
||||
resolved "https://registry.yarnpkg.com/@node-rs/helper/-/helper-1.2.1.tgz#e079b05f21ff4329d82c4e1f71c0290e4ecdc70c"
|
||||
integrity sha512-R5wEmm8nbuQU0YGGmYVjEc0OHtYsuXdpRG+Ut/3wZ9XAvQWyThN08bTh2cBJgoZxHQUPtvRfeQuxcAgLuiBISg==
|
||||
|
|
Loading…
Reference in a new issue