Files
pnpm/.github/workflows/build-pnpr.yml
Zoltan Kochanandgithub-actions[bot] 95fc851c75 chore: update dependencies, Node.js, pnpm, and GitHub Actions (#16864)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-10-12 11:25:04 +02:00

91 lines
3.7 KiB
YAML

name: Build pnpr (reusable)
# Build the pnpr server and registry fixture preparer once for the given OS,
# then share the binaries with every test job/shard as an artifact. Building
# inside each test job instead rebuilt pnpr once per shard, because the
# parallel shards all miss the build cache at job start.
#
# This is a per-OS reusable workflow rather than a single matrix job so each
# platform's test jobs can gate on their own build. `needs` can only target a
# whole job, never an individual matrix leg, so a matrix build would force the
# ubuntu tests to wait for the (slower) windows build and vice versa.
on:
workflow_call:
inputs:
os:
required: true
type: string
permissions:
contents: read
jobs:
build-pnpr:
name: ${{ inputs.os }}
runs-on: ${{ inputs.os }}
env:
CARGO_PROFILE_RELEASE_LTO: "off"
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: "16"
CARGO_PROFILE_RELEASE_OPT_LEVEL: "1"
steps:
- name: Free up runner disk space
if: ${{ runner.os == 'Linux' }}
run: |
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL
df -h /
- name: Checkout Commit
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# The binaries are cached and keyed on the Rust sources that produce them,
# so a run that only touches TypeScript restores them in seconds instead of
# recompiling. They are copied out of `target/` into a stable dir so
# `Swatinem/rust-cache`'s `target/` cleanup can't strip them before the
# cache saves. Integration test directories never link into these
# binaries, so they stay out of the key.
- name: Restore prebuilt pnpr binaries
id: pnpr-bins
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: .pnpr-bin
key: pnpr-bins-v2-${{ runner.os }}-${{ hashFiles('.github/workflows/build-pnpr.yml', 'rust-toolchain.toml', '**/Cargo.lock', '**/Cargo.toml', 'pnpr/**/*.rs', 'pnpm/**/*.rs', '!pnpm/crates/*/tests/**', '!pnpr/crates/*/tests/**') }}
- name: Install Rust
if: steps.pnpr-bins.outputs.cache-hit != 'true'
uses: $/.github/actions/rustup
with:
save-cache: ${{ github.ref_name == 'main' }}
shared-key: registry-prepare-v2
- name: Install pnpm
if: steps.pnpr-bins.outputs.cache-hit != 'true'
uses: pnpm/setup@a0881977cd8ea73b1ed212236c99ca10dcc80cf4 # v3.1.1
with:
install: false
- name: Build the pnpr server and registry fixture preparer
if: steps.pnpr-bins.outputs.cache-hit != 'true'
shell: bash
run: |
pnpm pipeline build-pnpr --include-workspace-root --full --no-cache
mkdir -p .pnpr-bin
ext=""
[ -f target/release/pnpr.exe ] && ext=".exe"
cp "target/release/pnpr$ext" "target/release/pnpr-prepare$ext" .pnpr-bin/
# Save the binaries to the cache right after they build, not in a post-job
# step: a later step failing would otherwise skip the save and force a full
# Rust rebuild on the next run.
- name: Save prebuilt pnpr binaries
if: steps.pnpr-bins.outputs.cache-hit != 'true'
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: .pnpr-bin
key: ${{ steps.pnpr-bins.outputs.cache-primary-key }}
- name: Upload pnpr binaries
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: pnpr-bins-${{ runner.os }}
path: .pnpr-bin
# `.pnpr-bin` is a dotfile dir, which upload-artifact skips by default.
include-hidden-files: true
if-no-files-found: error
retention-days: 1