Skip to content

Commit

Permalink
Merge branch 'main' into faulty/circular-dependencies-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
faultyserver authored Dec 30, 2024
2 parents 25898e8 + 437c370 commit 821af75
Show file tree
Hide file tree
Showing 423 changed files with 9,517 additions and 2,521 deletions.
1 change: 1 addition & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
0043842221e9a8ff8914d644ddcdedb4a359ef8a
ad68a593001497a9f0e78d9277d18f1bd613bacb
734ba4cfbec00ab68ff55bac95e7740fe8228229
1 change: 1 addition & 0 deletions .github/teams.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ team:
- "@SoonIter"
- "@fi3ework"
- "@Timeless0911"
- "@GiveMe-A-Name"
37 changes: 6 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ on:
tags-ignore:
- "**"

env:
# Since CI builds are more akin to from-scratch builds, incremental compilation adds unnecessary dependency-tracking and IO overhead, reducing caching effectiveness.
# https://github.com/rust-lang/rust-analyzer/blob/25368d24308d6a94ffe8b99f0122bcf5a2175322/.github/workflows/ci.yaml#L11
CARGO_INCREMENTAL: 0

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: ${{ github.ref_name != 'main' }}
Expand Down Expand Up @@ -61,10 +66,10 @@ jobs:
uses: ./.github/workflows/reusable-build.yml
with:
target: x86_64-unknown-linux-gnu
profile: "debug"
native: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS == '"ubuntu-22.04"' }}
runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }}
skipable: ${{ needs.check-changed.outputs.changed != 'true' }}
bench: true

test-release-linux:
name: Test Release Linux
Expand Down Expand Up @@ -354,36 +359,6 @@ jobs:
# reason for excluding https://github.com/napi-rs/napi-rs/issues/2200
run: cargo miri test --workspace --exclude rspack_node -- --nocapture

run_rust_benchmark:
name: Run rust benchmark
runs-on: ubuntu-latest
needs: [rust_changes, rust_check, rust_test]
steps:
- uses: actions/checkout@v4
- name: Pnpm Cache # Required by some tests
uses: ./.github/actions/pnpm-cache

- name: Install Rust Toolchain
uses: ./.github/actions/rustup
with:
save-cache: ${{ github.ref_name == 'main' }}
shared-key: check

- name: Install Tools
uses: taiki-e/install-action@v2
with:
tool: cargo-codspeed

- name: Build Benchmark
run: cargo codspeed build -p rspack_benchmark --features codspeed

- name: Run benchmark
uses: CodSpeedHQ/action@v3
timeout-minutes: 30
with:
run: cargo codspeed run
token: ${{ secrets.CODSPEED_TOKEN }}

run_benchmark:
name: Run benchmark
runs-on: ubuntu-latest
Expand Down
157 changes: 157 additions & 0 deletions .github/workflows/ecosystem-benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
name: ecosystem-benchmark

on:
workflow_dispatch:
inputs:
pr:
type: number
description: "Run Benchmark PR number"
required: true
push:
branches:
- main
paths-ignore:
- "**/*.md"
- "website/**"
tags-ignore:
- "**"

jobs:
get-runner-labels:
name: Get Runner Labels
uses: ./.github/workflows/get-runner-labels.yml

build:
name: Test Linux
needs: [get-runner-labels]
uses: ./.github/workflows/reusable-build.yml
with:
target: x86_64-unknown-linux-gnu
native: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS == '"ubuntu-22.04"' }}
runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }}
ref: ${{ github.event_name == 'workflow_dispatch' && format('pull/{0}/head', inputs.pr) || github.sha }}
test: false
bench: false

create-comment:
runs-on: ubuntu-latest
outputs:
comment-id: ${{ steps.create-comment.outputs.result }}
steps:
- id: create-comment
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
const url = `${context.serverUrl}//${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`
const urlLink = `[Open](${url})`
const body = `⏳ Triggered benchmark: ${urlLink}`
if (context.eventName === 'workflow_dispatch') {
const { data: comment } = await github.rest.issues.createComment({
issue_number: context.payload.inputs.pr,
owner: context.repo.owner,
repo: context.repo.repo,
body
})
return comment.id
}
const { data: comment } = await github.rest.repos.createCommitComment({
commit_sha: context.sha,
owner: context.repo.owner,
repo: context.repo.repo,
body
})
return comment.id
bench:
needs: [build]
runs-on: [self-hosted, benchmark]
outputs:
diff-result: ${{ steps.run-benchmark.outputs.diff-result }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'workflow_dispatch' && format('pull/{0}/head', inputs.pr) || github.sha }}

- name: Clean
uses: ./.github/actions/clean
with:
target: x86_64-unknown-linux-gnu

- name: Download bindings
uses: ./.github/actions/download-artifact
with:
name: bindings-x86_64-unknown-linux-gnu
path: crates/node_binding/
try-local-cache: false

- name: Show restored binding
shell: bash
run: ls -lah crates/node_binding/*.node

- name: Pnpm Cache
uses: ./.github/actions/pnpm-cache

- name: Build JS
run: pnpm run build:js

- name: Run rspack-ecosystem-benchmark
id: run-benchmark
run: |
RSPACK_DIR=$(pwd)
git clone --single-branch --depth 1 https://github.com/web-infra-dev/rspack-ecosystem-benchmark.git
cd rspack-ecosystem-benchmark
pnpm i
RSPACK_DIR="$RSPACK_DIR" node bin/cli.js bench
result=$(node bin/cli.js compare --base latest --current current)
echo "$result"
echo "diff-result=${result//$'\n'/'@@'}" >> $GITHUB_OUTPUT
comment-compare-results:
runs-on: ubuntu-latest
needs: [create-comment, bench]
if: ${{ !cancelled() }}
steps:
- uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const diffResult = `${{ needs.bench.outputs.diff-result }}`
let result = "task ${{ needs.bench.result }}"
if (diffResult) {
result = diffResult.replace(/@@/g, "\n");
}
const url = `${context.serverUrl}//${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`
const urlLink = `[Open](${url})`
const body = `
📝 Benchmark detail: ${urlLink}
${result}
`
if (context.eventName === 'workflow_dispatch') {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: `${{ needs.create-comment.outputs.comment-id }}`,
body
})
} else {
await github.rest.repos.updateCommitComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: `${{ needs.create-comment.outputs.comment-id }}`,
body,
});
}
if (result.includes("Threshold exceeded")) {
console.log("Some benchmark cases exceed the threshold, please visit the previous step for more information");
process.exit(1);
}
11 changes: 10 additions & 1 deletion .github/workflows/release-canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ on:
required: true
type: string
description: "Commit SHA"
profile:
required: true
type: choice
default: release
options:
- release
- release-debug
description: "release-debug means release with debug info for profile"

permissions:
# To publish packages with provenance
Expand Down Expand Up @@ -49,6 +57,7 @@ jobs:
ref: ${{inputs.commit}}
target: ${{ matrix.array.target }}
runner: ${{ matrix.array.runner }}
profile: ${{inputs.profile}}
test: false

release:
Expand Down Expand Up @@ -88,4 +97,4 @@ jobs:
./x publish snapshot --tag canary
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.RSPACK_CANARY_RELEASE_TOKEN }}
63 changes: 62 additions & 1 deletion .github/workflows/reusable-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ on:
type: boolean
required: false
default: true
bench: # Run benchmarks?
type: boolean
required: false
default: false
ref: # Git reference to checkout
required: false
type: string
Expand Down Expand Up @@ -96,7 +100,7 @@ jobs:
uses: ./.github/actions/rustup
with:
save-cache: ${{ github.ref_name == 'main' }} # This should be safe because we have nightly building the cache every day
shared-key: build-${{ inputs.target }}
shared-key: build-${{ inputs.target }}-${{ inputs.profile }}

# Compile dependencies with optimization to make tests run faster
- name: Add optimization to debug profile
Expand Down Expand Up @@ -389,3 +393,60 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
sha: ${{ github.sha }}

bench:
name: Bench
needs: build
if: ${{ inputs.bench && !inputs.skipable }}
runs-on: ${{ fromJSON(needs.build.outputs.runner-labels) }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
clean: ${{ startsWith(runner.name, 'GitHub Actions') }}

- name: Clean
if: ${{ !startsWith(runner.name, 'GitHub Actions') }}
uses: ./.github/actions/clean
with:
target: ${{ inputs.target }}

- name: Download bindings
uses: ./.github/actions/download-artifact
with:
name: bindings-${{ inputs.target }}
path: crates/node_binding/
try-local-cache: ${{ inputs.profile == 'debug' }}
link-when-local: true

- name: Show restored binding
shell: bash
run: ls -lah crates/node_binding/*.node

- name: Install Rust Toolchain
uses: ./.github/actions/rustup
with:
save-cache: ${{ github.ref_name == 'main' }} # This should be safe because we have nightly building the cache every day
shared-key: build-${{ inputs.target }}-${{ inputs.profile }}

- name: Pnpm Cache
uses: ./.github/actions/pnpm-cache

- name: Build JS
run: pnpm run build:js

- name: Install cargo-codspeed binary
uses: taiki-e/install-action@v2
with:
tool: cargo-codspeed

- name: Build Benchmark
run: cargo codspeed build -p rspack_benchmark --features codspeed

- name: Run benchmark
uses: CodSpeedHQ/action@v3
timeout-minutes: 30
with:
run: pnpm run bench:ci
token: ${{ secrets.CODSPEED_TOKEN }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ esbuild.cpuprofile
!packages/rspack-test-tools/tests/treeShakingCases/node_modules

# Binding artifacts
artifacts
/artifacts/

# Node Addons
npm/**/*.node
Expand Down
Loading

0 comments on commit 821af75

Please sign in to comment.