Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: only install binding dependencies when building binary #9429

Merged
merged 9 commits into from
Feb 21, 2025
12 changes: 9 additions & 3 deletions .github/actions/pnpm-cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ inputs:
default: false
required: false
type: boolean
run-install:
default: true
required: false
type: boolean
save-if:
default: false
required: false
Expand Down Expand Up @@ -40,14 +44,15 @@ runs:
# https://pnpm.io/continuous-integration#github-actions
# Uses `packageManagement` field from package.json
- name: Install pnpm
uses: pnpm/action-setup@v4
if: ${{ inputs.node-version == '16' }}
uses: pnpm/action-setup@v4
with:
dest: ${{ runner.tool_cache }}/pnpm
# Use `@pnpm/exe` for Node 16
standalone: true

- name: Get pnpm store directory
if: ${{ inputs.run-install == 'true' }}
id: pnpm-cache
shell: bash
run: |
Expand All @@ -62,7 +67,7 @@ runs:

- name: Restore pnpm cache
id: restore
if: ${{ startsWith(runner.name, 'GitHub Actions') }}
if: ${{ inputs.run-install == 'true' && startsWith(runner.name, 'GitHub Actions') }}
uses: actions/cache/restore@0c907a75c2c80ebcb7f088228285e798b750cf8f # v4
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
Expand All @@ -72,6 +77,7 @@ runs:

- name: Install dependencies
shell: bash
if: ${{ inputs.run-install == 'true' }}
run: |
if [[ "${{ inputs.frozen-lockfile}}" == 'true' ]]; then
pnpm install --frozen-lockfile --prefer-offline
Expand All @@ -81,7 +87,7 @@ runs:

- name: Save pnpm cache
uses: actions/cache/save@0c907a75c2c80ebcb7f088228285e798b750cf8f # v4
if: ${{ startsWith(runner.name, 'GitHub Actions') && inputs.save-if == 'true' && steps.restore.outputs.cache-hit != 'true' }}
if: ${{ inputs.run-install == 'true' && startsWith(runner.name, 'GitHub Actions') && inputs.save-if == 'true' && steps.restore.outputs.cache-hit != 'true' }}
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: node-cache-${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ jobs:
runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }}
skipable: ${{ needs.check-changed.outputs.changed != 'true' }}
bench: true
full-install: false

test-windows:
name: Test Windows
Expand All @@ -78,6 +79,8 @@ jobs:
profile: "dev"
runner: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_LABELS }}
skipable: ${{ needs.check-changed.outputs.changed != 'true' }}
full-install: false

test-mac:
name: Test Mac
needs: [get-runner-labels, check-changed]
Expand All @@ -88,6 +91,7 @@ jobs:
profile: "ci"
runner: ${{ needs.get-runner-labels.outputs.MACOS_RUNNER_LABELS }}
skipable: ${{ needs.check-changed.outputs.changed != 'true' }}
full-install: false

cargo-deny:
name: Check license of dependencies
Expand Down Expand Up @@ -212,6 +216,11 @@ jobs:
fmt: true
shared-key: check

- name: Pnpm Cache # Required by some tests
uses: ./.github/actions/pnpm-cache
with:
run-install: false

- name: Run Cargo Check
run: cargo check --workspace --all-targets --locked # Not using --release because it uses too much cache, and is also slow.

Expand Down
17 changes: 16 additions & 1 deletion .github/workflows/reusable-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ on:
target:
required: true
type: string
full-install:
default: true
required: false
type: boolean
runner: # Runner labels
required: true
type: string
Expand Down Expand Up @@ -60,11 +64,20 @@ jobs:
with:
target: ${{ inputs.target }}

- name: Pnpm Cache
- name: Pnpm Setup
if: ${{ !inputs.skipable }}
uses: ./.github/actions/pnpm-cache
with:
save-if: ${{ github.ref_name == 'main' }}
run-install: ${{ inputs.full-install == 'true' }}

- name: Install binding node dependencies
if: ${{ !inputs.skipable && inputs.full-install != 'true' }}
shell: bash
run: |
cd ./crates/node_binding
pnpm install --ignore-workspace --no-lockfile
cd ../../

- name: Install Rust Toolchain
if: ${{ !inputs.skipable }}
Expand Down Expand Up @@ -99,6 +112,7 @@ jobs:
uses: xc2/free-disk-space@fbe203b3788f2bebe2c835a15925da303eaa5efe # v1.0.0
with:
tool-cache: false

# Linux
- name: Build x86_64-unknown-linux-gnu in Docker
if: ${{ inputs.target == 'x86_64-unknown-linux-gnu' && steps.check_cache.outputs.exists != 'true' && !inputs.skipable }}
Expand Down Expand Up @@ -184,6 +198,7 @@ jobs:
SYSROOT=$(xcrun --sdk macosx --show-sdk-path);
export CFLAGS="-isysroot $SYSROOT -isystem $SYSROOT";
RUST_TARGET=${{ inputs.target }} pnpm build:binding:${{ inputs.profile }}

- name: Upload artifact
id: upload-artifact
uses: ./.github/actions/upload-artifact
Expand Down
Loading