Skip to content

Commit

Permalink
Eagerly build swc binaries on change (#43142)
Browse files Browse the repository at this point in the history
This is a follow-up to leveraging the turbo remote cache and this now
eagerly updates the cache on merge to canary when swc files changed so
that it doesn't have to wait for a publish to update.
  • Loading branch information
ijjk committed Nov 20, 2022
1 parent 0e65335 commit f4b4c09
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/build_test_deploy.yml
Expand Up @@ -30,9 +30,12 @@ jobs:
# 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
Expand All @@ -56,6 +59,14 @@ jobs:

- run: echo ${{steps.docs-change.outputs.DOCS_CHANGE}}

- run: echo "::set-output name=SWC_CHANGE::$(node scripts/run-for-change.js --type next-swc --exec echo 'yup')"
id: swc-change

- run: echo "::set-output name=TURBO_TOKEN::$(echo ${TURBO_TOKEN:-empty})"
id: turbo-token

- run: echo ${{steps.swc-change.outputs.SWC_CHANGE}}

- run: npm i -g pnpm@${PNPM_VERSION}

- id: get-store-path
Expand Down Expand Up @@ -1274,7 +1285,7 @@ jobs:
build: |
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" "pnpm@${PNPM_VERSION}"
turbo run build-native-no-plugin -- --release --target aarch64-pc-windows-msvc --cargo-flags=--no-default-features
if: ${{ needs.build.outputs.isRelease == 'true' }}
if: ${{ needs.build.outputs.isRelease == 'true' || (needs.build.outputs.swcChange == 'yup' && needs.build.outputs.turboToken != 'empty') }}
needs: build
name: stable - ${{ matrix.settings.target }} - node@16
runs-on: ${{ matrix.settings.host }}
Expand Down Expand Up @@ -1367,7 +1378,7 @@ jobs:
path: packages/next-swc/native/next-swc.*.node

build-native-freebsd:
if: ${{ needs.build.outputs.isRelease == 'true' }}
if: ${{ needs.build.outputs.isRelease == 'true' || (needs.build.outputs.swcChange == 'yup' && needs.build.outputs.turboToken != 'empty') }}
needs: build
name: stable - x86_64-unknown-freebsd - node@16
runs-on: macos-12
Expand Down Expand Up @@ -1459,7 +1470,7 @@ jobs:

build-wasm:
needs: build
if: ${{ needs.build.outputs.isRelease == 'true' }}
if: ${{ needs.build.outputs.isRelease == 'true' || (needs.build.outputs.swcChange == 'yup' && needs.build.outputs.turboToken != 'empty') }}
strategy:
matrix:
target: [web, nodejs]
Expand Down
2 changes: 1 addition & 1 deletion scripts/run-for-change.js
Expand Up @@ -15,7 +15,7 @@ const CHANGE_ITEM_GROUPS = {
'CODE_OF_CONDUCT.md',
'readme.md',
],
'next-swc': ['packages/next-swc', '.github/workflows/build_test_deploy.yml'],
'next-swc': ['packages/next-swc'],
}

async function main() {
Expand Down

0 comments on commit f4b4c09

Please sign in to comment.