diff --git a/.github/workflows/build_test_deploy.yml b/.github/workflows/build_test_deploy.yml index 171f5e69840c8..93bc2dd719eda 100644 --- a/.github/workflows/build_test_deploy.yml +++ b/.github/workflows/build_test_deploy.yml @@ -27,6 +27,7 @@ jobs: outputs: docsChange: ${{ steps.docs-change.outputs.DOCS_CHANGE }} isRelease: ${{ steps.check-release.outputs.IS_RELEASE }} + weekNum: ${{ steps.get-week.outputs.WEEK }} steps: - name: Setup node uses: actions/setup-node@v2 @@ -59,6 +60,9 @@ jobs: else echo "::set-output name=IS_RELEASE::false" fi + # We use week in the turbo cache key to keep the cache from infinitely growing + - id: get-week + run: echo ::set-output name=WEEK::$(date +%U) - uses: actions/cache@v2 id: cache-build @@ -655,13 +659,20 @@ jobs: path: ~/.cargo/git key: stable-ubuntu-18.04-node@14-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }} - - name: Cache native binary - id: binary-cache + # We use week in the turbo cache key to keep the cache from infinitely growing + - id: get-week + run: echo ::set-output name=WEEK::$(date +%U) + + - name: Turbo Cache + id: turbo-cache uses: actions/cache@v2 if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }} with: - path: packages/next-swc/native/next-swc.linux-x64-gnu.node - key: dev-next-swc-nightly-2021-11-15-linux-x64-gnu-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next-swc/**') }} + path: .turbo + key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ steps.get-week.outputs.WEEK }}-${{ github.sha }} + restore-keys: | + turbo-${{ github.job }}-${{ github.ref_name }}-${{ steps.get-week.outputs.WEEK }}- + turbo-${{ github.job }}-canary-${{ steps.get-week.outputs.WEEK }}- # We use restore-key to pick latest cache. # We will not get exact match, but doc says @@ -678,13 +689,16 @@ jobs: # since the repo's dependencies aren't installed we need # to install napi globally - run: npm i -g @napi-rs/cli@1.2.1 + - run: npm i -g turbo@1.0.14 - name: Build - if: ${{ steps.binary-cache.outputs.cache-hit != 'true' && steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }} - run: yarn build-native + if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }} + run: turbo run build-native --cache-dir=".turbo" env: MACOSX_DEPLOYMENT_TARGET: '10.13' - working-directory: packages/next-swc + TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} + TURBO_TEAM: nextjs + TURBO_PROJECT: nextjs - name: Upload artifact uses: actions/upload-artifact@v2.2.4 @@ -833,12 +847,15 @@ jobs: path: ~/.cargo/git key: stable-${{ matrix.os }}-node@14-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }} - - name: Cache native binary - id: binary-cache + - name: Turbo cache + id: turbo-cache uses: actions/cache@v2 with: - path: packages/next-swc/native/next-swc.${{ matrix.name }}.node - key: next-swc-nightly-2021-11-15-${{ matrix.target }}-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next-swc/**') }} + path: .turbo + key: turbo-${{ github.job }}-${{ matrix.name }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} + restore-keys: | + turbo-${{ github.job }}-${{ matrix.name }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- + turbo-${{ github.job }}-${{ matrix.name }}-canary-${{ needs.build.outputs.weekNum }}- - name: Cross build aarch64 setup if: ${{ matrix.target == 'aarch64-apple-darwin' }} @@ -861,11 +878,12 @@ jobs: next-swc-cargo-cache-${{ matrix.os }} - name: 'Build' - if: ${{ steps.binary-cache.outputs.cache-hit != 'true' }} - run: yarn build-native --release --target ${{ matrix.target }} + run: turbo run build-native --cache-dir=".turbo" -- --release --target ${{ matrix.target }} env: MACOSX_DEPLOYMENT_TARGET: '10.13' - working-directory: packages/next-swc + TURBO_TOKEN: ${{secrets.TURBO_TOKEN}} + TURBO_TEAM: nextjs + TURBO_PROJECT: nextjs - name: Upload artifact uses: actions/upload-artifact@v2.2.4 @@ -907,7 +925,7 @@ jobs: # since the repo's dependencies aren't installed we need # to install napi globally - run: npm i -g @napi-rs/cli@1.2.1 - + - run: npm i -g turbo@1.0.14 - name: Install Rust uses: actions-rs/toolchain@v1 with: @@ -916,18 +934,23 @@ jobs: override: true target: i686-pc-windows-msvc - - name: Cache native binary - id: binary-cache + - name: Turbo Cache + id: turbo-cache uses: actions/cache@v2 with: - path: packages/next-swc/native/next-swc.win32-ia32-msvc.node - key: next-swc-nightly-2021-11-15-win32-ia32-msvc-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next-swc/**') }} + path: .turbo + key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} + restore-keys: | + turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- + turbo-${{ github.job }}-canary-${{ needs.build.outputs.weekNum }}- - name: Build - if: ${{ steps.binary-cache.outputs.cache-hit != 'true' }} shell: bash - run: yarn build-native --release --target i686-pc-windows-msvc - working-directory: packages/next-swc + run: turbo run build-native --cache-dir=".turbo" -- --release --target i686-pc-windows-msvc + env: + TURBO_TOKEN: ${{secrets.TURBO_TOKEN}} + TURBO_TEAM: nextjs + TURBO_PROJECT: nextjs - name: Upload artifact uses: actions/upload-artifact@v2 @@ -953,7 +976,7 @@ jobs: # since the repo's dependencies aren't installed we need # to install napi globally - run: npm i -g @napi-rs/cli@1.2.1 - + - run: npm i -g turbo@1.0.14 - name: Install Rust uses: actions-rs/toolchain@v1 with: @@ -962,18 +985,23 @@ jobs: override: true target: aarch64-pc-windows-msvc - - name: Cache native binary - id: binary-cache + - name: Turbo Cache + id: turbo-cache uses: actions/cache@v2 with: - path: packages/next-swc/native/next-swc.win32-arm64-msvc.node - key: next-swc-nightly-2021-11-15-win32-arm64-msvc-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next-swc/**') }} + path: .turbo + key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} + restore-keys: | + turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- + turbo-${{ github.job }}-canary-${{ needs.build.outputs.weekNum }}- - name: Build - if: ${{ steps.binary-cache.outputs.cache-hit != 'true' }} shell: bash - run: yarn build-native --release --target aarch64-pc-windows-msvc - working-directory: packages/next-swc + run: turbo run build-native --cache-dir=".turbo" -- --release --target aarch64-pc-windows-msvc + env: + TURBO_TOKEN: ${{secrets.TURBO_TOKEN}} + TURBO_TEAM: nextjs + TURBO_PROJECT: nextjs - name: Upload artifact uses: actions/upload-artifact@v2 @@ -1011,17 +1039,19 @@ jobs: docker pull ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine docker tag ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine builder - - name: Cache native binary - id: binary-cache + - name: Turbo Cache + id: turbo-cache uses: actions/cache@v2 with: - path: packages/next-swc/native/next-swc.linux-x64-musl.node - key: next-swc-nightly-2021-11-15-linux-x64-musl-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next-swc/**') }} + path: .turbo + key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} + restore-keys: | + turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- + turbo-${{ github.job }}-canary-${{ needs.build.outputs.weekNum }}- - name: 'Build' - if: ${{ steps.binary-cache.outputs.cache-hit != 'true' }} run: | - docker run --rm -v ~/.cargo/git:/root/.cargo/git -v ~/.cargo/registry:/root/.cargo/registry -v $(pwd)/packages/next-swc:/build -w /build builder sh -c "npm i -g @napi-rs/cli@1.2.1 && yarn build-native --release --target x86_64-unknown-linux-musl" + docker run --rm -v ~/.cargo/git:/root/.cargo/git -v ~/.cargo/registry:/root/.cargo/registry -v $(pwd)/packages/next-swc:/build -w /build builder sh -c "npm i -g @napi-rs/cli@1.2.1 && npm i -g turbo@1.0.14 && turbo run build-native --cache-dir=".turbo" -- --release --target x86_64-unknown-linux-musl" - name: Upload artifact uses: actions/upload-artifact@v2 @@ -1049,6 +1079,7 @@ jobs: # since the repo's dependencies aren't installed we need # to install napi globally - run: npm i -g @napi-rs/cli@1.2.1 + - run: npm i -g turbo@1.0.14 - name: Install Rust uses: actions-rs/toolchain@v1 @@ -1070,17 +1101,23 @@ jobs: sudo apt-get update sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu -y - - name: Cache native binary - id: binary-cache + - name: Turbo Cache + id: turbo-cache uses: actions/cache@v2 with: - path: packages/next-swc/native/next-swc.linux-arm64-gnu.node - key: next-swc-nightly-2021-11-15-linux-arm64-gnu-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next-swc/**') }} + path: .turbo + key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} + restore-keys: | + turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- + turbo-${{ github.job }}-canary-${{ needs.build.outputs.weekNum }}- - name: Cross build aarch64 if: ${{ steps.binary-cache.outputs.cache-hit != 'true' }} - run: yarn build-native --release --target aarch64-unknown-linux-gnu - working-directory: packages/next-swc + run: turbo run build-native --cache-dir=".turbo" -- --release --target aarch64-unknown-linux-gnu + env: + TURBO_TOKEN: ${{secrets.TURBO_TOKEN}} + TURBO_TEAM: nextjs + TURBO_PROJECT: nextjs - name: Upload artifact uses: actions/upload-artifact@v2 @@ -1106,7 +1143,7 @@ jobs: # since the repo's dependencies aren't installed we need # to install napi globally - run: npm i -g @napi-rs/cli@1.2.1 - + - run: npm i -g turbo@1.0.14 - name: Install Rust uses: actions-rs/toolchain@v1 with: @@ -1127,17 +1164,22 @@ jobs: sudo apt-get update sudo apt-get install gcc-aarch64-linux-gnu -y - - name: Cache native binary - id: binary-cache + - name: Turbo Cache + id: turbo-cache uses: actions/cache@v2 with: - path: packages/next-swc/native/next-swc.linux-arm64-musl.node - key: next-swc-nightly-2021-11-15-linux-arm64-musl-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next-swc/**') }} + path: .turbo + key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} + restore-keys: | + turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- + turbo-${{ github.job }}-canary-${{ needs.build.outputs.weekNum }}- - name: Cross build aarch64 - if: ${{ steps.binary-cache.outputs.cache-hit != 'true' }} - run: yarn build-native --release --target aarch64-unknown-linux-musl - working-directory: packages/next-swc + run: turbo run build-native --cache-dir=".turbo" -- --release --target aarch64-unknown-linux-musl + env: + TURBO_TOKEN: ${{secrets.TURBO_TOKEN}} + TURBO_TEAM: nextjs + TURBO_PROJECT: nextjs - name: Upload artifact uses: actions/upload-artifact@v2 @@ -1165,6 +1207,7 @@ jobs: # since the repo's dependencies aren't installed we need # to install napi globally - run: npm i -g @napi-rs/cli@1.2.1 + - run: npm i -g turbo@1.0.14 - name: Install Rust uses: actions-rs/toolchain@v1 @@ -1186,17 +1229,22 @@ jobs: sudo apt-get update sudo apt-get install gcc-arm-linux-gnueabihf -y - - name: Cache native binary - id: binary-cache + - name: Turbo Cache + id: turbo-cache uses: actions/cache@v2 with: - path: packages/next-swc/native/next-swc.linux-arm-gnueabihf.node - key: next-swc-nightly-2021-11-15-linux-arm-gnueabihf-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next-swc/**') }} + path: .turbo + key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} + restore-keys: | + turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- + turbo-${{ github.job }}-canary-${{ needs.build.outputs.weekNum }}- - name: Cross build aarch64 - if: ${{ steps.binary-cache.outputs.cache-hit != 'true' }} - run: yarn build-native --release --target armv7-unknown-linux-gnueabihf - working-directory: packages/next-swc + run: turbo run build-native --cache-dir=".turbo" -- --release --target armv7-unknown-linux-gnueabihf + env: + TURBO_TOKEN: ${{secrets.TURBO_TOKEN}} + TURBO_TEAM: nextjs + TURBO_PROJECT: nextjs - name: Upload artifact uses: actions/upload-artifact@v2 @@ -1222,6 +1270,7 @@ jobs: # since the repo's dependencies aren't installed we need # to install napi globally - run: npm i -g @napi-rs/cli@1.2.1 + - run: npm i -g turbo@1.0.14 - name: Install Rust uses: actions-rs/toolchain@v1 @@ -1231,20 +1280,25 @@ jobs: override: true target: aarch64-linux-android - - name: Cache native binary - id: binary-cache + - name: Turbo Cache + id: turbo-cache uses: actions/cache@v2 with: - path: packages/next-swc/native/next-swc.android-arm64.node - key: next-swc-nightly-2021-11-15-android-arm64-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next-swc/**') }} + path: .turbo + key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} + restore-keys: | + turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- + turbo-${{ github.job }}-canary-${{ needs.build.outputs.weekNum }}- - name: Build - if: ${{ steps.binary-cache.outputs.cache-hit != 'true' }} 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 --release --target aarch64-linux-android - working-directory: packages/next-swc + turbo run build-native --cache-dir=".turbo" -- --release --target aarch64-linux-android + env: + TURBO_TOKEN: ${{secrets.TURBO_TOKEN}} + TURBO_TEAM: nextjs + TURBO_PROJECT: nextjs - name: Upload artifact uses: actions/upload-artifact@v2 diff --git a/.github/workflows/pull_request_stats.yml b/.github/workflows/pull_request_stats.yml index a6b481f7b2a07..8a724a5594507 100644 --- a/.github/workflows/pull_request_stats.yml +++ b/.github/workflows/pull_request_stats.yml @@ -48,13 +48,20 @@ jobs: path: ~/.cargo/git key: stable-ubuntu-18.04-node@14-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }} - - name: Cache native binary - id: binary-cache + # We use week in the turbo cache key to keep the cache from infinitely growing + - id: get-week + run: echo ::set-output name=WEEK::$(date +%U) + + - name: Turbo Cache + id: turbo-cache uses: actions/cache@v2 if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }} with: - path: packages/next-swc/native/next-swc.linux-x64-gnu.node - key: dev-next-swc-nightly-2021-11-15-linux-x64-gnu-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next-swc/**') }} + path: .turbo + key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ steps.get-week.outputs.WEEK }}-${{ github.sha }} + restore-keys: | + turbo-${{ github.job }}-${{ github.ref_name }}-${{ steps.get-week.outputs.WEEK }}- + turbo-${{ github.job }}-canary-${{ steps.get-week.outputs.WEEK }}- # We use restore-key to pick latest cache. # We will not get exact match, but doc says @@ -71,13 +78,16 @@ jobs: # since the repo's dependencies aren't installed we need # to install napi globally - run: npm i -g @napi-rs/cli@1.2.1 + - run: npm i -g turbo@1.0.14 - name: Build - if: ${{ steps.binary-cache.outputs.cache-hit != 'true' && steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }} - run: yarn build-native + if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }} + run: turbo run build-native --cache-dir=".turbo" env: MACOSX_DEPLOYMENT_TARGET: '10.13' - working-directory: packages/next-swc + TURBO_TOKEN: ${{secrets.TURBO_TOKEN}} + TURBO_TEAM: nextjs + TURBO_PROJECT: nextjs - name: Upload artifact uses: actions/upload-artifact@v2.2.4 diff --git a/package.json b/package.json index 7b668f6c8f9da..738204a6e80cc 100644 --- a/package.json +++ b/package.json @@ -153,6 +153,7 @@ "tailwindcss": "1.1.3", "taskr": "1.1.0", "tree-kill": "1.2.2", + "turbo": "1.0.14", "typescript": "4.4.3", "wait-port": "0.2.2", "web-streams-polyfill": "2.1.1", @@ -166,5 +167,25 @@ }, "engines": { "node": ">=12.22.0" + }, + "turbo": { + "pipeline": { + "build-native": { + "dependsOn": [ + "^build-native" + ], + "outputs": [ + "native/*.node" + ] + }, + "build-wasm": { + "dependsOn": [ + "^build-wasm" + ], + "outputs": [ + "crates/wasm/pkg/*" + ] + } + } } } diff --git a/packages/next-swc/package.json b/packages/next-swc/package.json index da91d21f90867..c9fc2da8d683b 100644 --- a/packages/next-swc/package.json +++ b/packages/next-swc/package.json @@ -3,7 +3,8 @@ "version": "12.0.8-canary.8", "private": true, "scripts": { - "build-native": "napi build --platform --cargo-name next_swc_napi native" + "build-native": "napi build --platform --cargo-name next_swc_napi native", + "build-wasm": "wasm-pack build crates/wasm --scope=next" }, "napi": { "name": "next-swc", diff --git a/packages/next/package.json b/packages/next/package.json index f339609fe00d3..4aac5fe3c0f9c 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -162,6 +162,7 @@ "@babel/types": "7.15.0", "@napi-rs/cli": "1.2.1", "@next/polyfill-nomodule": "12.0.8-canary.8", + "@next/swc": "12.0.8-canary.8", "@peculiar/webcrypto": "1.1.7", "@taskr/clear": "1.1.0", "@taskr/esnext": "1.1.0", diff --git a/yarn.lock b/yarn.lock index fe4f17b24b728..1a5daa05b0c09 100644 --- a/yarn.lock +++ b/yarn.lock @@ -19131,6 +19131,11 @@ tunnel-agent@^0.6.0: dependencies: safe-buffer "^5.0.1" +turbo@1.0.14: + version "1.0.14" + resolved "https://registry.yarnpkg.com/turbo/-/turbo-1.0.14.tgz#42ace0d1c699f0c1cb19b589b6d629dfa72b62b4" + integrity sha512-FfKP1rjx8LF/n8eibVOVlv7XzTszMHCg43RHCLFxGAEKluDCw3hyFAFNJumECktiGOt19M54h+HEGW/BDZeW2g== + tweetnacl@^0.14.3, tweetnacl@~0.14.0: version "0.14.5" resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64"