Unverified Commit ddd94f0a authored by Sebastian "Sebbie" Silbermann's avatar Sebastian "Sebbie" Silbermann Committed by GitHub

[15.5.x] Authenticate Turborepo remote caching with OIDC instead of a static PAT (#97604)

parent 1da7a0a0
......@@ -5,10 +5,6 @@ inputs:
description: 'SCCACHE_BASE_DIR for path normalization (default: $GITHUB_WORKSPACE)'
required: false
default: ''
turbo-token:
description: 'Fallback TURBO_TOKEN if not set in environment (e.g. from secrets.TURBO_TOKEN)'
required: false
default: ''
runs:
using: 'node20'
main: 'main.js'
......
#!/usr/bin/env bash
set -euo pipefail
# Normalize TURBO_API and TURBO_TOKEN: prefer environment values and
# fall back to Vercel's public API and the secret passed as an action input.
# Default TURBO_API to Vercel's public API when the workflow does not set it.
if [ -z "${TURBO_API:-}" ]; then
export TURBO_API="https://api.vercel.com"
echo "TURBO_API=${TURBO_API}" >> "$GITHUB_ENV"
fi
if [ -z "${TURBO_TOKEN:-}" ]; then
if [ -n "${INPUT_TURBO_TOKEN:-}" ]; then
export TURBO_TOKEN="${INPUT_TURBO_TOKEN}"
echo "TURBO_TOKEN=${TURBO_TOKEN}" >> "$GITHUB_ENV"
else
echo "WARNING: no TURBO_TOKEN available"
fi
fi
# Exported by `vercel/setup-turborepo-remote-cache-action`, and unset entirely
# when that step was skipped. Bind them so the substring expansions below don't
# trip `set -u`, which rejects an unset name even in `${var:0:3}`.
TURBO_TOKEN="${TURBO_TOKEN:-}"
TURBO_TEAM="${TURBO_TEAM:-}"
if [ -z "${TURBO_TEAM:-}" ]; then
export TURBO_TEAM="vtest314-next-adapter-e2e-tests"
echo "TURBO_TEAM=${TURBO_TEAM}" >> "$GITHUB_ENV"
if [ -z "$TURBO_TOKEN" ]; then
echo "WARNING: no TURBO_TOKEN available"
fi
echo "::add-mask::${TURBO_TOKEN:-}"
echo "::add-mask::${TURBO_TOKEN}"
echo "Cache endpoint: ${TURBO_API:0:9}..."
echo "TURBO_TOKEN: ${TURBO_TOKEN:0:3}..."
echo "TURBO_TEAM: ${TURBO_TEAM}"
......
......@@ -29,11 +29,10 @@ env:
TURBO_VERSION: 2.5.5
NODE_LTS_VERSION: 20
CARGO_PROFILE_RELEASE_LTO: 'true'
TURBO_TEAM: 'vtest314-next-adapter-e2e-tests'
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
# Prefer shared remote cache across runs, but keep local cache enabled so jobs
# degrade gracefully if the remote cache or token is unavailable.
TURBO_CACHE: 'local:rw,remote:rw'
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
# Without this environment variable, rust-lld will fail because some dependencies defaults to newer version of macOS by default.
#
# See https://doc.rust-lang.org/rustc/platform-support/apple-darwin.html#os-version for more details
......@@ -131,7 +130,17 @@ 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
permissions:
contents: read
id-token: write
steps:
- name: Set up Turborepo remote cache
if: ${{ vars.TURBO_TEAM != '' }}
continue-on-error: true
uses: vercel/setup-turborepo-remote-cache-action@135046f5efcadb17337d9b29b8d5b4035ae64b10 # v1.0.0
with:
team: ${{ vars.TURBO_TEAM }}
- name: Setup node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
......@@ -340,7 +349,17 @@ jobs:
env:
# Disable all build caches for production/staging/force-preview deploys
NEXT_SKIP_BUILD_CACHE: ${{ contains(fromJSON('["production","staging","force-preview"]'), needs.deploy-target.outputs.value) && '1' || '' }}
permissions:
contents: read
id-token: write
steps:
- name: Set up Turborepo remote cache
if: ${{ vars.TURBO_TEAM != '' }}
continue-on-error: true
uses: vercel/setup-turborepo-remote-cache-action@135046f5efcadb17337d9b29b8d5b4035ae64b10 # v1.0.0
with:
team: ${{ vars.TURBO_TEAM }}
# https://github.com/actions/virtual-environments/issues/1187
- name: tune linux network
run: sudo ethtool -K eth0 tx off rx off
......@@ -476,7 +495,17 @@ jobs:
runs-on: ubuntu-latest-16-core-oss
permissions:
contents: read
id-token: write
steps:
- name: Set up Turborepo remote cache
if: ${{ vars.TURBO_TEAM != '' }}
continue-on-error: true
uses: vercel/setup-turborepo-remote-cache-action@135046f5efcadb17337d9b29b8d5b4035ae64b10 # v1.0.0
with:
team: ${{ vars.TURBO_TEAM }}
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup node
......
This diff is collapsed.
......@@ -85,11 +85,10 @@ env:
# disable backtrace for test snapshots
RUST_BACKTRACE: 0
TURBO_TEAM: 'vtest314-next-adapter-e2e-tests'
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
# Prefer shared remote cache across runs, but keep local cache enabled so jobs
# degrade gracefully if the remote cache or token is unavailable.
TURBO_CACHE: 'local:rw,remote:rw'
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
NEXT_TELEMETRY_DISABLED: 1
# allow not skipping install-native postinstall script if we don't have a binary available already
......@@ -120,6 +119,13 @@ jobs:
input_step_key: ${{ steps.var.outputs.input_step_key }}
steps:
- name: Set up Turborepo remote cache
if: ${{ vars.TURBO_TEAM != '' }}
continue-on-error: true
uses: vercel/setup-turborepo-remote-cache-action@135046f5efcadb17337d9b29b8d5b4035ae64b10 # v1.0.0
with:
team: ${{ vars.TURBO_TEAM }}
# enforce consistent line endings for git on windows
- name: Configure git to use LF endings
if: ${{ runner.os == 'Windows' }}
......@@ -230,8 +236,6 @@ jobs:
- name: Start sccache
uses: ./.github/actions/sccache
if: ${{ runner.os != 'Windows' && (inputs.skipNativeBuild != 'yes' || inputs.needsNextest == 'yes' || inputs.needsRust == 'yes') }}
with:
turbo-token: ${{ secrets.TURBO_TOKEN }}
- run: pnpm dlx turbo@${TURBO_VERSION} run build-native-${{ inputs.rustBuildProfile }} -v --env-mode loose --remote-cache-timeout 90 --summarize -- --target ${{ inputs.buildNativeTarget }}
if: ${{ inputs.skipNativeBuild != 'yes' }}
......
......@@ -41,6 +41,9 @@ jobs:
# First, build Next.js to execute across tests.
build-next:
name: build-next
permissions:
contents: read
id-token: write
uses: ./.github/workflows/build_reusable.yml
with:
skipNativeBuild: yes
......@@ -49,6 +52,9 @@ jobs:
build-native:
name: build-native
permissions:
contents: read
id-token: write
uses: ./.github/workflows/build_reusable.yml
with:
skipInstallBuild: yes
......@@ -86,6 +92,9 @@ jobs:
fail-fast: false
matrix:
group: ${{ fromJSON(needs.generate-matrices.outputs.e2e) }}
permissions:
contents: read
id-token: write
uses: ./.github/workflows/build_reusable.yml
with:
afterBuild: |
......@@ -117,6 +126,9 @@ jobs:
fail-fast: false
matrix:
group: ${{ fromJSON(needs.generate-matrices.outputs.integration) }}
permissions:
contents: read
id-token: write
uses: ./.github/workflows/build_reusable.yml
with:
nodeVersion: 18.18.2
......
......@@ -10,11 +10,10 @@ env:
NODE_LTS_VERSION: 20
TEST_CONCURRENCY: 6
TURBO_TEAM: 'vtest314-next-adapter-e2e-tests'
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
# Prefer shared remote cache across runs, but keep local cache enabled so jobs
# degrade gracefully if the remote cache or token is unavailable.
TURBO_CACHE: 'local:rw,remote:rw'
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
NEXT_TELEMETRY_DISABLED: 1
# we build a dev binary for use in CI so skip downloading
# canary next-swc binaries in the monorepo
......@@ -27,6 +26,9 @@ env:
jobs:
build:
permissions:
contents: read
id-token: write
uses: ./.github/workflows/build_reusable.yml
secrets: inherit
with:
......@@ -39,7 +41,17 @@ jobs:
needs: build
timeout-minutes: 25
runs-on: ubuntu-latest-16-core-oss
permissions:
contents: read
id-token: write
steps:
- name: Set up Turborepo remote cache
if: ${{ vars.TURBO_TEAM != '' }}
continue-on-error: true
uses: vercel/setup-turborepo-remote-cache-action@135046f5efcadb17337d9b29b8d5b4035ae64b10 # v1.0.0
with:
team: ${{ vars.TURBO_TEAM }}
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 25
......
......@@ -9,6 +9,9 @@ on:
jobs:
test-dev:
name: Rspack integration tests
permissions:
contents: read
id-token: write
uses: ./.github/workflows/integration_tests_reusable.yml
with:
name: rspack-production
......
......@@ -9,6 +9,9 @@ on:
jobs:
test-dev:
name: Rspack integration tests
permissions:
contents: read
id-token: write
uses: ./.github/workflows/integration_tests_reusable.yml
with:
name: rspack-development
......
......@@ -17,14 +17,20 @@ env:
TURBOPACK_BENCH_PROGRESS: '1'
NODE_LTS_VERSION: 20
TURBO_TEAM: 'vtest314-next-adapter-e2e-tests'
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
jobs:
test:
name: Test
runs-on: ${{ fromJSON(inputs.runner) }}
steps:
- name: Set up Turborepo remote cache
if: ${{ vars.TURBO_TEAM != '' }}
continue-on-error: true
uses: vercel/setup-turborepo-remote-cache-action@135046f5efcadb17337d9b29b8d5b4035ae64b10 # v1.0.0
with:
team: ${{ vars.TURBO_TEAM }}
- name: Set git to use LF
run: |
git config --global core.autocrlf false
......@@ -51,8 +57,6 @@ jobs:
- name: Start sccache
uses: ./.github/actions/sccache
with:
turbo-token: ${{ secrets.TURBO_TOKEN }}
- name: Build benchmarks for tests
timeout-minutes: 120
......
......@@ -93,6 +93,9 @@ jobs:
test-deploy:
name: Run Deploy Tests
needs: setup
permissions:
contents: read
id-token: write
uses: ./.github/workflows/build_reusable.yml
secrets: inherit
strategy:
......
......@@ -22,17 +22,26 @@ env:
CARGO_INCREMENTAL: 0
# For faster CI
RUST_LOG: 'off'
TURBO_TEAM: 'vtest314-next-adapter-e2e-tests'
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
# Prefer shared remote cache across runs, but keep local cache enabled so jobs
# degrade gracefully if the remote cache or token is unavailable.
TURBO_CACHE: 'local:rw,remote:rw'
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
jobs:
benchmark-tiny:
name: Benchmark Rust Crates (tiny)
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Set up Turborepo remote cache
if: ${{ vars.TURBO_TEAM != '' }}
continue-on-error: true
uses: vercel/setup-turborepo-remote-cache-action@135046f5efcadb17337d9b29b8d5b4035ae64b10 # v1.0.0
with:
team: ${{ vars.TURBO_TEAM }}
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup Rust toolchain
......@@ -45,8 +54,6 @@ jobs:
- name: Start sccache
uses: ./.github/actions/sccache
with:
turbo-token: ${{ secrets.TURBO_TOKEN }}
- name: Build app build benchmarks
run: cargo codspeed build -p next-api
......@@ -60,7 +67,17 @@ jobs:
benchmark-small-apps:
name: Benchmark Rust Crates (small apps)
runs-on: ubuntu-latest-16-core-oss
permissions:
contents: read
id-token: write
steps:
- name: Set up Turborepo remote cache
if: ${{ vars.TURBO_TEAM != '' }}
continue-on-error: true
uses: vercel/setup-turborepo-remote-cache-action@135046f5efcadb17337d9b29b8d5b4035ae64b10 # v1.0.0
with:
team: ${{ vars.TURBO_TEAM }}
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup Rust toolchain
......@@ -73,8 +90,6 @@ jobs:
- name: Start sccache
uses: ./.github/actions/sccache
with:
turbo-token: ${{ secrets.TURBO_TOKEN }}
- name: Install pnpm dependencies
working-directory: turbopack/benchmark-apps
......@@ -96,7 +111,17 @@ jobs:
name: Benchmark Rust Crates (large)
if: ${{ github.event.label.name == 'benchmark' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest-16-core-oss
permissions:
contents: read
id-token: write
steps:
- name: Set up Turborepo remote cache
if: ${{ vars.TURBO_TEAM != '' }}
continue-on-error: true
uses: vercel/setup-turborepo-remote-cache-action@135046f5efcadb17337d9b29b8d5b4035ae64b10 # v1.0.0
with:
team: ${{ vars.TURBO_TEAM }}
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup Rust toolchain
......@@ -109,8 +134,6 @@ jobs:
- name: Start sccache
uses: ./.github/actions/sccache
with:
turbo-token: ${{ secrets.TURBO_TOKEN }}
- name: Build the benchmark target(s)
run: cargo codspeed build -p turbopack -p turbopack-bench
......
......@@ -8,6 +8,9 @@ on:
jobs:
test-dev:
name: Next.js integration tests
permissions:
contents: read
id-token: write
uses: ./.github/workflows/integration_tests_reusable.yml
with:
name: turbopack-production
......
......@@ -8,6 +8,9 @@ on:
jobs:
test-dev:
name: Next.js integration tests
permissions:
contents: read
id-token: write
uses: ./.github/workflows/integration_tests_reusable.yml
with:
name: turbopack-development
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment