Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 36 additions & 7 deletions .github/actions/build-upstream/action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: 'Build with Upstream Repositories'
description: 'Builds Vite+ with the upstream repositories'
inputs:
profile:
description: 'Cargo profile for native builds (release or ci).'
required: false
default: 'release'
target:
description: 'The target platform'
required: true
Expand Down Expand Up @@ -30,6 +34,8 @@ runs:
# (packages/cli/package.json is modified by syncTestPackageExports during build-ts).
- uses: ./.github/actions/compute-native-cache-input-hash
id: native-cache-inputs
with:
profile: ${{ inputs.profile }}

# Include the documentation origin so preview binaries cannot reuse release links.
- name: Compute NAPI binding cache key
Expand Down Expand Up @@ -123,8 +129,9 @@ runs:
shell: bash
if: steps.native.outputs.build == 'true' && contains(inputs.target, 'linux') && !contains(inputs.target, 'musl')
run: |
pnpm --filter=vite-plus build-native --target ${INPUTS_TARGET} --use-napi-cross
pnpm --filter=vite-plus build-native --profile "$INPUTS_PROFILE" --target ${INPUTS_TARGET} --use-napi-cross
env:
INPUTS_PROFILE: ${{ inputs.profile }}
TARGET_CC: clang
TARGET_CFLAGS: ${{ contains(inputs.target, 'aarch64') && '-D_BSD_SOURCE' || '' }}
DEBUG: napi:*
Expand All @@ -134,8 +141,9 @@ runs:
shell: bash
if: steps.native.outputs.build == 'true' && contains(inputs.target, 'musl')
run: |
pnpm --filter=vite-plus build-native --target ${INPUTS_TARGET} -x
pnpm --filter=vite-plus build-native --profile "$INPUTS_PROFILE" --target ${INPUTS_TARGET} -x
env:
INPUTS_PROFILE: ${{ inputs.profile }}
TARGET_CC: clang
TARGET_CFLAGS: ${{ contains(inputs.target, 'aarch64') && '-D_BSD_SOURCE' || '' }}
DEBUG: napi:*
Expand All @@ -145,17 +153,19 @@ runs:
shell: bash
if: steps.native.outputs.build == 'true' && !contains(inputs.target, 'linux')
run: |
pnpm --filter=vite-plus build-native --target ${INPUTS_TARGET}
pnpm --filter=vite-plus build-native --profile "$INPUTS_PROFILE" --target ${INPUTS_TARGET}
env:
INPUTS_PROFILE: ${{ inputs.profile }}
DEBUG: napi:*
INPUTS_TARGET: ${{ inputs.target }}

- name: Build Rust CLI binary (Linux gnu)
if: steps.native.outputs.build == 'true' && contains(inputs.target, 'linux') && !contains(inputs.target, 'musl')
shell: bash
run: |
pnpm exec napi build --use-napi-cross --target ${INPUTS_TARGET} --release -p vp_global_cli
pnpm exec napi build --use-napi-cross --target ${INPUTS_TARGET} --profile "$INPUTS_PROFILE" -p vp_global_cli
env:
INPUTS_PROFILE: ${{ inputs.profile }}
TARGET_CC: clang
TARGET_CFLAGS: ${{ contains(inputs.target, 'aarch64') && '-D_BSD_SOURCE' || '' }}
DEBUG: napi:*
Expand All @@ -165,8 +175,9 @@ runs:
if: steps.native.outputs.build == 'true' && contains(inputs.target, 'musl')
shell: bash
run: |
pnpm exec napi build -x --target ${INPUTS_TARGET} --release -p vp_global_cli
pnpm exec napi build -x --target ${INPUTS_TARGET} --profile "$INPUTS_PROFILE" -p vp_global_cli
env:
INPUTS_PROFILE: ${{ inputs.profile }}
TARGET_CC: clang
TARGET_CFLAGS: ${{ contains(inputs.target, 'aarch64') && '-D_BSD_SOURCE' || '' }}
DEBUG: napi:*
Expand All @@ -175,8 +186,9 @@ runs:
- name: Build Rust CLI binary (non-Linux targets)
if: steps.native.outputs.build == 'true' && !contains(inputs.target, 'linux')
shell: bash
run: cargo build --release --target ${INPUTS_TARGET} -p vp_global_cli
run: cargo build --profile "$INPUTS_PROFILE" --target ${INPUTS_TARGET} -p vp_global_cli
env:
INPUTS_PROFILE: ${{ inputs.profile }}
INPUTS_TARGET: ${{ inputs.target }}

# The helper builds the excluded trampoline from its crate directory.
Expand All @@ -191,8 +203,25 @@ runs:
- name: Build installer binary (Windows only)
if: steps.native.outputs.build == 'true' && contains(inputs.target, 'windows')
shell: bash
run: cargo build --release --target ${INPUTS_TARGET} -p vp_installer
run: cargo build --profile "$INPUTS_PROFILE" --target ${INPUTS_TARGET} -p vp_installer
env:
INPUTS_PROFILE: ${{ inputs.profile }}
INPUTS_TARGET: ${{ inputs.target }}

# Keep the artifact layout used by installers and test consumers.
- name: Stage native CLI binaries
if: steps.native.outputs.build == 'true' && inputs.profile != 'release'
shell: bash
run: |
target_dir="${CARGO_TARGET_DIR:-target}/$INPUTS_TARGET"
mkdir -p "$target_dir/release"
if [[ "$INPUTS_TARGET" == *windows* ]]; then
cp "$target_dir/$INPUTS_PROFILE/vp.exe" "$target_dir/$INPUTS_PROFILE/vp-setup.exe" "$target_dir/release/"
else
cp "$target_dir/$INPUTS_PROFILE/vp" "$target_dir/release/"
fi
env:
INPUTS_PROFILE: ${{ inputs.profile }}
INPUTS_TARGET: ${{ inputs.target }}

- name: Save NAPI binding cache
Expand Down
25 changes: 22 additions & 3 deletions .github/actions/build-windows-cli/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ description: >-
skip-native input). Run on a Linux runner after checkout + clone.

inputs:
profile:
description: 'Cargo profile for native builds (release or ci).'
required: false
default: 'release'
save-cache:
description: "Whether setup-xwin's setup-rust should save its cache (usually only on main)."
required: false
Expand All @@ -22,6 +26,8 @@ runs:
# the native binaries and generated bindings.
- uses: ./.github/actions/compute-native-cache-input-hash
id: native-cache-inputs
with:
profile: ${{ inputs.profile }}

# Use a distinct prefix: this cache stores Linux-relative paths and must
# never mix with the caches build-upstream saves on other runners. Sharing
Expand Down Expand Up @@ -59,7 +65,7 @@ runs:
if: steps.binaries-cache.outputs.cache-hit != 'true'
with:
save-cache: ${{ inputs.save-cache }}
cache-key: windows-cli-cross
cache-key: windows-cli-cross-${{ inputs.profile }}

- uses: oxc-project/setup-node@1f1a5b4450c8905bd1830c3a908d22b960c4559a # main (Node before pnpm; unreleased)
if: steps.binaries-cache.outputs.cache-hit != 'true'
Expand All @@ -70,8 +76,9 @@ runs:
- name: Build NAPI binding
if: steps.binaries-cache.outputs.cache-hit != 'true'
shell: bash
run: pnpm --filter=vite-plus build-native --target x86_64-pc-windows-msvc -x --skip-format
run: pnpm --filter=vite-plus build-native --profile "$INPUTS_PROFILE" --target x86_64-pc-windows-msvc -x --skip-format
env:
INPUTS_PROFILE: ${{ inputs.profile }}
DEBUG: 'napi:*'
XWIN_ACCEPT_LICENSE: '1'
# See setup-xwin / build-windows-tests for why this Detours escape
Expand All @@ -81,8 +88,9 @@ runs:
- name: Build Rust CLI binaries
if: steps.binaries-cache.outputs.cache-hit != 'true'
shell: bash
run: cargo xwin build --release --target x86_64-pc-windows-msvc -p vp_global_cli -p vp_installer
run: cargo xwin build --profile "$INPUTS_PROFILE" --target x86_64-pc-windows-msvc -p vp_global_cli -p vp_installer
env:
INPUTS_PROFILE: ${{ inputs.profile }}
XWIN_ACCEPT_LICENSE: '1'
CXXFLAGS: -D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH

Expand All @@ -95,6 +103,17 @@ runs:
env:
XWIN_ACCEPT_LICENSE: '1'

# Keep the artifact layout used by installers and test consumers.
- name: Stage native CLI binaries
if: steps.binaries-cache.outputs.cache-hit != 'true' && inputs.profile != 'release'
shell: bash
run: |
target_dir="${CARGO_TARGET_DIR:-target}/x86_64-pc-windows-msvc"
mkdir -p "$target_dir/release"
cp "$target_dir/$INPUTS_PROFILE/vp.exe" "$target_dir/$INPUTS_PROFILE/vp-setup.exe" "$target_dir/release/"
env:
INPUTS_PROFILE: ${{ inputs.profile }}

# TypeScript builds need only these Cargo package fields for toolchain
# versions. Export them where the Rust dependencies are already present.
- name: Export Cargo metadata
Expand Down
10 changes: 8 additions & 2 deletions .github/actions/compute-native-cache-input-hash/action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: 'Compute native cache input hash'
description: 'Hash every input that can affect the native CLI binaries and generated bindings.'

inputs:
profile:
description: 'Cargo profile for native builds (release or ci).'
required: false
default: 'release'

outputs:
hash:
description: 'Combined hash of the native build inputs.'
Expand All @@ -12,9 +18,9 @@ runs:
- name: Compute native cache input hash
id: compute
shell: bash
run: |
echo "hash=$NATIVE_CACHE_INPUT_HASH" >> "$GITHUB_OUTPUT"
run: echo "hash=${NATIVE_CACHE_INPUT_HASH}-${INPUTS_PROFILE}" >> "$GITHUB_OUTPUT"
env:
INPUTS_PROFILE: ${{ inputs.profile }}
# crates/vp_cli_snapshots is excluded: the snapshot suite (runner,
# vpt, fixtures, recorded .md baselines) never feeds the native
# binaries, and its dependency changes surface in the hashed root
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
# Shares the Cargo cache with the Linux CLI test build job, which
# builds the same target. Only that job saves it.
save-cache: false
cache-key: cli-snapshot-test-x86_64-unknown-linux-gnu
cache-key: cli-snapshot-test-x86_64-unknown-linux-gnu-ci

- uses: ./.github/actions/setup-ci-node

Expand All @@ -87,6 +87,7 @@ jobs:
- name: Build with upstream
uses: ./.github/actions/build-upstream
with:
profile: ci
target: x86_64-unknown-linux-gnu

- name: Run vp fmt --check
Expand Down Expand Up @@ -378,6 +379,7 @@ jobs:
- uses: ./.github/actions/clone
- uses: ./.github/actions/build-windows-cli
with:
profile: ci
save-cache: ${{ github.ref_name == 'main' }}

cli-e2e-test:
Expand Down Expand Up @@ -953,7 +955,7 @@ jobs:
- uses: oxc-project/setup-rust@68c3199c5339f965e6e163924c3c450773eba42b # main (pending v1.0.17 — Swatinem/rust-cache v2.9.1 for node24)
with:
save-cache: ${{ github.ref_name == 'main' }}
cache-key: cli-snapshot-test-${{ matrix.target }}
cache-key: cli-snapshot-test-${{ matrix.target }}-ci

- uses: ./.github/actions/setup-ci-node

Expand All @@ -966,6 +968,7 @@ jobs:
- name: Build with upstream
uses: ./.github/actions/build-upstream
with:
profile: ci
target: ${{ matrix.target }}

- name: Ensure no unexpected file changes after build
Expand Down Expand Up @@ -1308,7 +1311,7 @@ jobs:
- uses: oxc-project/setup-rust@68c3199c5339f965e6e163924c3c450773eba42b # main (pending v1.0.17 — Swatinem/rust-cache v2.9.1 for node24)
with:
save-cache: ${{ github.ref_name == 'main' }}
cache-key: cli-e2e-test-musl
cache-key: cli-e2e-test-musl-ci

- uses: ./.github/actions/setup-ci-node

Expand All @@ -1322,6 +1325,7 @@ jobs:
- name: Build with upstream (musl)
uses: ./.github/actions/build-upstream
with:
profile: ci
target: x86_64-unknown-linux-musl

# Run bootstrap-cli:ci and E2E tests inside an Alpine container where musl is native.
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ jobs:
- uses: ./.github/actions/clone
- uses: ./.github/actions/build-windows-cli
with:
profile: ci
save-cache: ${{ github.ref_name == 'main' }}

# Each platform starts its tests as soon as its own packages are ready.
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/reusable-ecosystem-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ jobs:
- uses: oxc-project/setup-rust@68c3199c5339f965e6e163924c3c450773eba42b # main (pending v1.0.17 — Swatinem/rust-cache v2.9.1 for node24)
if: ${{ !contains(inputs.target, 'windows') }}
with:
# The CI CLI build caches these release dependencies and saves the cache.
# Reuse the CLI build job's Cargo cache for the ci profile.
save-cache: false
cache-key: cli-snapshot-test-${{ inputs.target }}
cache-key: cli-snapshot-test-${{ inputs.target }}-ci

- uses: oxc-project/setup-node@1f1a5b4450c8905bd1830c3a908d22b960c4559a # main (Node before pnpm; unreleased)

Expand All @@ -68,6 +68,7 @@ jobs:
- name: Build with upstream
uses: ./.github/actions/build-upstream
with:
profile: ci
target: ${{ inputs.target }}
skip-native: ${{ contains(inputs.target, 'windows') }}

Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/test-vp-create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ jobs:

- uses: oxc-project/setup-rust@68c3199c5339f965e6e163924c3c450773eba42b # main (pending v1.0.17 — Swatinem/rust-cache v2.9.1 for node24)
with:
# The CI CLI build caches these release dependencies and saves the cache.
# Reuse the CLI build job's Cargo cache for the ci profile.
save-cache: false
cache-key: cli-snapshot-test-x86_64-unknown-linux-gnu
cache-key: cli-snapshot-test-x86_64-unknown-linux-gnu-ci

- uses: oxc-project/setup-node@1f1a5b4450c8905bd1830c3a908d22b960c4559a # main (Node before pnpm; unreleased)

Expand All @@ -91,6 +91,7 @@ jobs:
- name: Build with upstream
uses: ./.github/actions/build-upstream
with:
profile: ci
target: x86_64-unknown-linux-gnu

- name: Pack packages into tgz
Expand Down
7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -446,3 +446,10 @@ panic = "abort" # Let it crash and force ourselves to write safe Rust.
# The installer binary is downloaded by users, so optimize for size.
[profile.release.package.vp_installer]
opt-level = "z"

# Oxc's compilation settings for native CI test binaries.
[profile.ci]
inherits = "release"
opt-level = 2
lto = "thin"
codegen-units = 256
2 changes: 1 addition & 1 deletion packages/cli/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ async function buildNapiBinding() {
platform: true,
jsBinding: 'index.cjs',
dts: 'index.d.cts',
release: process.env.VP_CLI_DEBUG !== '1',
release: !passedInOptions.profile && process.env.VP_CLI_DEBUG !== '1',
features: bindingFeatures,
});

Expand Down
Loading
Loading