rsnext/.github/workflows/build_reusable.yml
2023-05-27 23:29:08 -07:00

116 lines
3.5 KiB
YAML

name: Build Reusable
on:
workflow_call:
inputs:
afterBuild:
required: false
description: 'additional steps to run'
type: string
skipInstallBuild:
required: false
description: 'whether to skip pnpm install && pnpm build'
type: string
skipForDocsOnly:
required: false
description: 'skip for docs only changes'
type: string
nodeVersion:
required: false
description: 'version of Node.js to use'
type: string
needsNextest:
required: false
description: 'if nextest rust dep is needed'
type: string
env:
NAPI_CLI_VERSION: 2.14.7
TURBO_VERSION: 1.9.6
RUST_TOOLCHAIN: nightly-2023-03-09
PNPM_VERSION: 7.24.3
NODE_MAINTENANCE_VERSION: 16
NODE_LTS_VERSION: 18
TEST_CONCURRENCY: 8
# TODO: remove after testing
# NEXT_TEST_CONTINUE_ON_ERROR: 'true'
TURBO_TEAM: 'vercel'
TURBO_REMOTE_ONLY: 'true'
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
TEST_TIMINGS_TOKEN: ${{ secrets.TEST_TIMINGS_TOKEN }}
NEXT_TEST_JOB: 1
jobs:
build:
runs-on: [self-hosted, linux, x64]
steps:
- run: fnm install ${{ inputs.nodeVersion || env.NODE_LTS_VERSION }}
- run: fnm use ${{ inputs.nodeVersion || env.NODE_LTS_VERSION }}
- run: node -v
- run: pwd
- name: Install
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: rustfmt, clippy
- name: Install nextest
if: ${{ inputs.needsNextest == 'yes' }}
uses: taiki-e/install-action@nextest
- run: rustc --version
- run: npm i -g yarn "pnpm@${PNPM_VERSION}" "turbo@${TURBO_VERSION}" "@napi-rs/cli@${NAPI_CLI_VERSION}"
- uses: actions/checkout@v3
with:
fetch-depth: 25
# clean up any previous artifacts to avoid hitting disk space limits
- run: git clean -xdf && rm -rf /tmp/next-repo-*; rm -rf /tmp/next-install-* /tmp/yarn-* /tmp/ncc-cache target && cargo clean
- 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
name: check docs only change
id: docs-change
# normalize versions before build-native for better cache hits
- run: node scripts/normalize-version-bump.js
name: normalize versions
- run: turbo run build-native-release --summarize true -- --target x86_64-unknown-linux-gnu
# undo normalize version changes for install/build
- run: git checkout .
if: ${{ inputs.skipInstallBuild != 'yes' }}
- run: pnpm store path
- run: pnpm install
if: ${{ inputs.skipInstallBuild != 'yes' }}
- run: pnpm build
if: ${{ inputs.skipInstallBuild != 'yes' }}
- run: pnpm playwright install-deps
if: ${{ inputs.skipInstallBuild != 'yes' }}
- run: pnpm playwright install chromium
if: ${{ inputs.skipInstallBuild != 'yes' }}
- run: turbo run get-test-timings -- --build ${{ github.sha }}
- run: /bin/bash -c "${{ inputs.afterBuild }}"
if: ${{inputs.skipForDocsOnly != 'yes' || steps.docs-change.outputs.DOCS_CHANGE == 'nope'}}
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: turbo run summary
path: .turbo/runs