Skip to content

Commit

Permalink
ci: only install binding dependencies when building binary
Browse files Browse the repository at this point in the history
  • Loading branch information
LingyuCoder committed Feb 21, 2025
1 parent f7ec690 commit d504eba
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
10 changes: 8 additions & 2 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 @@ -49,6 +53,7 @@ runs:

- name: Get pnpm store directory
id: pnpm-cache
if: ${{ inputs.run-install }}
shell: bash
run: |
# set store-dir to $(pnpm config get store-dir)/$(pnpm -v)
Expand All @@ -62,7 +67,7 @@ runs:
- name: Restore pnpm cache
id: restore
if: ${{ startsWith(runner.name, 'GitHub Actions') }}
if: ${{ startsWith(runner.name, 'GitHub Actions') && inputs.run-install }}
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 }}
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: ${{ startsWith(runner.name, 'GitHub Actions') && inputs.save-if == 'true' && steps.restore.outputs.cache-hit != 'true' && inputs.run-install }}
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: node-cache-${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
13 changes: 12 additions & 1 deletion .github/workflows/reusable-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,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: false

- name: Install node dependencies
if: ${{ !inputs.skipable }}
shell: bash
run: |
cd ./crates/node_binding
pnpm install --ignore-workspace
cd ../../
- name: Install Rust Toolchain
if: ${{ !inputs.skipable }}
Expand Down Expand Up @@ -99,6 +108,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 +194,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

0 comments on commit d504eba

Please sign in to comment.