Skip to content

Commit

Permalink
feat: split build job
Browse files Browse the repository at this point in the history
  • Loading branch information
SyMind committed Mar 15, 2024
1 parent 3b41365 commit 1944962
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 6 deletions.
54 changes: 54 additions & 0 deletions .github/actions/build-rspack/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: 'Build Rspack'
description: 'Checkout, download rspack binding, and build rspack js'

inputs:
repository:
description: 'The rspack repository to use'
required: true
default: 'web-infra-dev/rspack'
path:
description: 'Destination path to the rspack repository'
required: true
default: '.rspack'
ref:
description: 'The branch, tag or SHA to checkout'
required: true
default: 'main'
node-version:
description: 'The version of Node.js to set up'
required: true
default: '18'

outputs:
artifact-name:
description: 'The name of the uploaded artifact'

runs:
using: composite
steps:
- uses: actions/setup-node@v3
with:
node-version: 18
- shell: bash
run: corepack enable
- shell: bash
run: pnpm --version
- name: Checkout Rspack repo
uses: actions/checkout@v4
with:
repository: ${{ inputs.repository }}
path: ${{ inputs.path }}
ref: ${{ inputs.ref }}
- uses: actions/download-artifact@v4
with:
name: binding-linux-x64-gnu
path: ${{ inputs.path }}/npm/linux-x64-gnu
- name: Show restored binding
shell: bash
run: ls -lah ${{ inputs.path }}/npm/linux-x64-gnu/*.node
- name: Build Rspack JS
shell: bash
run: |
cd ${{ inputs.path }}
pnpm i
pnpm run build:js
65 changes: 65 additions & 0 deletions .github/actions/prepare-rspack-binding/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: 'Prepare Rspack Binding'
description: 'Checkout, build, and upload rspack native bindings'

inputs:
repository:
description: 'The rspack repository to use'
required: true
default: 'web-infra-dev/rspack'
path:
description: 'Destination path to clone'
required: true
default: '.rspack'
ref:
description: 'The branch, tag or SHA to checkout'
required: true
default: 'main'
node-version:
description: 'The version of Node.js to set up'
required: true
default: '18'

outputs:
artifact-name:
description: 'The name of the uploaded artifact'

runs:
using: composite
steps:
- name: Checkout Rspack repo
uses: actions/checkout@v4
with:
repository: ${{ inputs.repository }}
path: ${{ inputs.path }}
ref: ${{ inputs.ref }}
- uses: actions/setup-node@v3
with:
node-version: ${{ inputs.node-version }}
- shell: bash
run: |
cd ${{ inputs.path }}
corepack enable
- shell: bash
run: |
cd ${{ inputs.path }}
pnpm --version
- id: rust-cache
uses: MasterworksIO/action-local-cache@2
with:
path: '${{ inputs.path }}/target'
key: 'rspack'
strategy: 'copy'
- name: Show Rust Cache
if: steps.rust-cache.outputs.cache-hit == 'true'
shell: bash
run: ls -lah ${{ inputs.path }}/target
- name: Build Rspack
shell: bash
run: |
cd ${{ inputs.path }}
pnpm i --frozen-lockfile
pnpm run build:binding:release
- uses: actions/upload-artifact@v4
with:
name: binding-linux-x64-gnu
path: ${{ inputs.path }}/crates/node_binding/*.node
17 changes: 11 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,21 @@ concurrency:
cancel-in-progress: ${{ github.ref_name != 'main' }}

jobs:
ci:
prepare-binding:
name: Prepare Rspack Binding
runs-on: [self-hosted, rspack-bench]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare-rspack-binding

ci:
needs: prepare-binding
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Init env
uses: ./.github/actions/env
- name: Build rspack
run: node bin/build-rspack.js
uses: actions/checkout@v4
- uses: ./.github/actions/build-rspack
- name: Run benchmark
run: node bin/bench.js
- id: print-compare-results
Expand Down

0 comments on commit 1944962

Please sign in to comment.