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

chore: use more semantic naming profile #9288

Merged
merged 10 commits into from
Feb 14, 2025
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
uses: ./.github/workflows/reusable-build.yml
with:
target: x86_64-pc-windows-msvc
profile: "debug"
profile: "dev"
runner: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_LABELS }}
skipable: ${{ needs.check-changed.outputs.changed != 'true' }}

Expand All @@ -124,7 +124,7 @@ jobs:
uses: ./.github/workflows/reusable-build.yml
with:
target: x86_64-apple-darwin
profile: "debug"
profile: "ci"
runner: ${{ needs.get-runner-labels.outputs.MACOS_RUNNER_LABELS }}
skipable: ${{ needs.check-changed.outputs.changed != 'true' }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/preview-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
with:
target: ${{ matrix.array.target }}
runner: ${{ matrix.array.runner }}
profile: "release-prod"
profile: "release"
test: false

publish:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/release-canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ on:
default: release
options:
- release
- release-debug
description: "release-debug means release with debug info for profile"
- profiling
- ci
description: "profiling means release with debug info for profiling, ci means release with debug info and faster build time"

permissions:
# To publish packages with provenance
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
with:
target: ${{ matrix.array.target }}
runner: ${{ matrix.array.runner }}
profile: "release-prod"
profile: "release"

release:
name: Release
Expand Down
59 changes: 8 additions & 51 deletions .github/workflows/reusable-build.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,5 @@
name: Reusable Release

# Example job:
#jobs
# build:
# strategy:
# matrix:
# array:
# - target: x86_64-unknown-linux-gnu
# runner: ubuntu-latest
# - target: aarch64-unknown-linux-gnu
# runner: ubuntu-latest
# - target: x86_64-unknown-linux-musl
# runner: ubuntu-latest
# - target: aarch64-unknown-linux-musl
# runner: ubuntu-latest
# - target: i686-pc-windows-msvc
# runner: windows-latest
# - target: x86_64-pc-windows-msvc
# runner: windows-latest
# - target: aarch64-pc-windows-msvc
# runner: windows-latest
# - target: x86_64-apple-darwin
# runner: macos-latest
# - target: aarch64-apple-darwin
# runner: macos-latest
# uses: ./.github/workflows/reusable-build.yml
# with:
# target: ${{ matrix.array.target }}
# runner: ${{ matrix.array.runner }}

on:
workflow_call:
inputs:
Expand All @@ -42,8 +13,8 @@ on:
runner: # Runner labels
required: true
type: string
profile: # Rust profile, "debug" or "release"
default: "release"
profile: # Rust profile, "ci" or "production" or "profiling"
default: "ci"
required: false
type: string
test: # Run tests?
Expand Down Expand Up @@ -85,10 +56,6 @@ jobs:
with:
target: ${{ inputs.target }}

- name: Setup tmate session
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48 # v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled && !inputs.skipable }}

- name: Pnpm Cache
if: ${{ !inputs.skipable }}
uses: ./.github/actions/pnpm-cache
Expand All @@ -102,16 +69,6 @@ jobs:
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 }}

# Compile dependencies with optimization to make tests run faster
- name: Add optimization to debug profile
if: ${{ inputs.profile == 'debug' && !inputs.skipable }}
shell: bash
run: |
echo '[profile.release.package."*"]' >> Cargo.toml
echo 'opt-level = 3' >> Cargo.toml
echo 'codegen-units = 64' >> Cargo.toml
echo 'incremental = false' >> Cargo.toml

- name: Trim paths
if: ${{ !inputs.skipable }}
shell: bash
Expand All @@ -122,7 +79,7 @@ jobs:

- name: Check local cache
id: check_cache
if: ${{ inputs.profile == 'debug' && !startsWith(runner.name, 'GitHub Actions') && !inputs.skipable }}
if: ${{ inputs.profile == 'ci' && !startsWith(runner.name, 'GitHub Actions') && !inputs.skipable }}
shell: bash
run: |
set -e
Expand Down Expand Up @@ -227,7 +184,7 @@ jobs:
with:
name: bindings-${{ inputs.target }}
path: crates/node_binding/*.node
try-local-cache: ${{ inputs.profile == 'debug' }}
try-local-cache: ${{ inputs.profile == 'ci' }}
mv-when-local: true

e2e:
Expand All @@ -253,7 +210,7 @@ jobs:
with:
name: bindings-${{ inputs.target }}
path: crates/node_binding/
try-local-cache: ${{ inputs.profile == 'debug' }}
try-local-cache: ${{ inputs.profile == 'ci' }}
link-when-local: true

- name: Setup Pnpm
Expand Down Expand Up @@ -315,7 +272,7 @@ jobs:
with:
name: bindings-${{ inputs.target }}
path: crates/node_binding/
try-local-cache: ${{ inputs.profile == 'debug' }}
try-local-cache: ${{ inputs.profile == 'ci' }}
link-when-local: true

- name: Show restored binding
Expand Down Expand Up @@ -414,7 +371,7 @@ jobs:
with:
name: bindings-${{ inputs.target }}
path: crates/node_binding/
try-local-cache: ${{ inputs.profile == 'debug' }}
try-local-cache: ${{ inputs.profile == 'ci' }}
link-when-local: true

- name: Show restored binding
Expand All @@ -436,7 +393,7 @@ jobs:
- name: Install cargo-codspeed binary
uses: taiki-e/install-action@995f97569c4a8ae84dcd7e1a0107f65ca6ebf139 # v2
with:
tool: cargo-codspeed
tool: cargo-codspeed@2.7.2

- name: Build Benchmark
env:
Expand Down
34 changes: 22 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -195,29 +195,39 @@ rspack_util = { version = "0.2.0", path = "crates/rsp

[workspace.metadata.release]
rate-limit = { existing-packages = 70, new-packages = 70 }

# Follow servo's style https://github.com/servo/servo/blob/c95bd9d052d7eae378d31c5be0f92669cadb2c85/Cargo.toml#L175

# This is for local development
[profile.dev]
codegen-units = 16
debug = 2 # debug build will cause runtime panic if codegen-unints is default
incremental = true
panic = "abort"
debug = 2 # debug build will cause runtime panic if codegen-unints is default
incremental = true
panic = "abort"

# This is for release build for users
[profile.release]
codegen-units = 1
debug = false
# Performs “thin” LTO. This is similar to “fat”, but takes substantially less time to run while still achieving performance gains similar to “fat”.
lto = "thin"
opt-level = 3
# Performs “fat” LTO which attempts to perform optimizations across all crates within the dependency graph.
lto = "fat"
opt-level = "s"
panic = "abort"
strip = true

[profile.release-prod]
inherits = "release"
# Performs “fat” LTO which attempts to perform optimizations across all crates within the dependency graph.
lto = "fat"
# This is for CI build based on release but with faster build time
[profile.ci]
codegen-units = 64
inherits = "release"
## reduce little optimization to reduce build time
lto = "thin"
## reduce little optimization to reduce build time
opt-level = 2

[profile.release-debug]
# This is for production for profiling production build
[profile.profiling]
debug = true
inherits = "release"
lto = "thin"
strip = false

# the following lints rules are from https://github.com/biomejs/biome/blob/4bd3d6f09642952ee14445ed56af81a73796cea1/Cargo.toml#L7C1-L75C1
Expand Down
22 changes: 4 additions & 18 deletions crates/node_binding/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,10 @@
"binding.d.ts"
],
"scripts": {
"build:debug": "node scripts/build.js",
"watch:debug": "node scripts/build.js --watch",
"build:debug:x64": "cross-env RUST_TARGET=x86_64-apple-darwin node scripts/build.js",
"build:debug:linux": "cross-env RUST_TARGET=x86_64-unknown-linux-gnu node scripts/build.js",
"build:release": "node scripts/build.js --release",
"watch:release": "node scripts/build.js --release --watch",
"build:release:arm64": "cross-env RUST_TARGET=aarch64-apple-darwin node scripts/build.js --release",
"build:release:x64": "cross-env RUST_TARGET=x86_64-apple-darwin node scripts/build.js --release",
"build:release:linux": "cross-env RUST_TARGET=x86_64-unknown-linux-gnu node scripts/build.js --release",
"build:release:musl": "cross-env RUST_TARGET=aarch64-unknown-linux-musl node scripts/build.js --release",
"build:release:win": "cross-env RUST_TARGET=x86_64-pc-windows-msvc node scripts/build.js --release",
"build:release-prod": "node scripts/build.js --release-prod",
"watch:release-prod": "node scripts/build.js --release-prod --watch",
"build:release-prod:arm64": "cross-env RUST_TARGET=aarch64-apple-darwin node scripts/build.js --release-prod",
"build:release-prod:x64": "cross-env RUST_TARGET=x86_64-apple-darwin node scripts/build.js --release-prod",
"build:release-prod:linux": "cross-env RUST_TARGET=x86_64-unknown-linux-gnu node scripts/build.js --release-prod",
"build:release-prod:win": "cross-env RUST_TARGET=x86_64-pc-windows-msvc node scripts/build.js --release-prod",
"build:release-debug": "node scripts/build.js --release-debug",
"build:dev": "node scripts/build.js",
"build:ci": "node scripts/build.js --profile ci",
"build:production": "node scripts/build.js --profile production",
"build:release": "node scripts/build.js --profile release",
"move-binding": "node scripts/move-binding",
"test": "tsc -p tsconfig.type-test.json"
},
Expand Down
23 changes: 10 additions & 13 deletions crates/node_binding/scripts/build.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
const path = require("path");
const { readFileSync, writeFileSync } = require("fs")
const { values } = require('util').parseArgs({
args: process.argv.slice(2),
options: {
profile: {
type: 'string'
}
}
})

const { spawn } = require("child_process");

const CARGO_SAFELY_EXIT_CODE = 0;

// Faster release for CI & canary with `thin` LTO
let release = process.argv.includes("--release");
// Slower release for production with `fat` LTO
let releaseProd = process.argv.includes("--release-prod");
let releaseDebug = process.argv.includes("--release-debug");
let watch = process.argv.includes("--watch");

build().then((value) => {
Expand All @@ -35,14 +38,8 @@ async function build() {
"--pipe",
`"node ./scripts/dts-header.js"`
];
if (release) {
args.push("--release");
}
if (releaseProd) {
args.push('--profile release-prod');
}
if (releaseDebug) {
args.push('--profile release-debug');
if (values.profile) {
args.push("--profile", values.profile)
}
if (watch) {
args.push("--watch");
Expand Down
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"clean": "pnpm --filter @rspack/cli run clean",
"check-dependency-version": "pnpx check-dependency-version-consistency@5 . --ignore-dep @napi-rs/cli --ignore-dep chalk --ignore-package webpack-test --ignore-package webpack-examples --ignore-package plugin-test",
"build:js": "pnpm --filter \"@rspack/core\" build:force && pnpm --filter \"@rspack/*\" --filter \"create-rspack\" --filter \"!@rspack/core\" build",
"build:cli:debug": "npm run build:binding:debug && npm run build:js",
"build:cli:dev": "npm run build:binding:dev && npm run build:js",
"build:cli:release": "npm run build:binding:release && npm run build:js",
"build:cli:release:all": "pnpm --filter @rspack/binding build:release:all && npm run build:js",
"build:cli:release:arm64": "pnpm --filter @rspack/binding build:release:arm64 && npm run build:js",
Expand All @@ -28,10 +28,10 @@
"lint:js": "pnpm run lint-ci:js --write",
"lint-ci:js": "biome check --diagnostic-level=warn --no-errors-on-unmatched --max-diagnostics=none",
"lint:rs": "node ./scripts/check_rust_dependency.cjs",
"build:binding:debug": "pnpm --filter @rspack/binding run build:debug",
"build:binding:dev": "pnpm --filter @rspack/binding run build:dev",
"build:binding:ci": "pnpm --filter @rspack/binding run build:ci",
"build:binding:release": "pnpm --filter @rspack/binding run build:release",
"build:binding:release-debug": "pnpm --filter @rspack/binding run build:release-debug",
"build:binding:release-prod": "pnpm --filter @rspack/binding run build:release-prod",
"build:binding:profiling": "pnpm --filter @rspack/binding run build:profiling",
"prepare": "is-ci || husky",
"test:diff": "pnpm --filter \"@rspack/*\" test:diff",
"test:hot": "pnpm --filter \"@rspack/*\" test:hot",
Expand All @@ -43,7 +43,8 @@
"doc-coverage": "pnpm --filter \"@rspack/core\" doc-coverage",
"api-extractor:local": "pnpm --filter \"@rspack/*\" api-extractor --local",
"api-extractor:ci": "pnpm --filter \"@rspack/*\" api-extractor:ci",
"bench:ci": "cargo codspeed run && pnpm --filter bench run bench"
"bench:ci:rust": "cargo codspeed run",
"bench:ci:js": "pnpm --filter bench run bench"
},
"homepage": "https://rspack.dev",
"bugs": "https://github.com/web-infra-dev/rspack/issues",
Expand Down
2 changes: 1 addition & 1 deletion website/docs/en/contribute/development/debugging.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ To illustrate this process, I'll use an example. Let's start by introduce the en
Firstly, you need to build rspack in debug mode. To do this, execute the following commands in the project's root directory:

```bash
npm run build:binding:debug
npm run build:binding:dev
npm run build:js
```

Expand Down
2 changes: 1 addition & 1 deletion website/docs/zh/contribute/development/debugging.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Target 0: (node) stopped.
首先,你需要在调试模式下构建 rspack。为此,请在项目的根目录中执行以下命令:

```bash
npm run build:binding:debug
npm run build:binding:dev
npm run build:js
```

Expand Down
2 changes: 1 addition & 1 deletion x.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ buildCommand
.command("binding")
.description("build rust binding")
.action(async () => {
await $`pnpm --filter @rspack/binding build:debug`;
await $`pnpm --filter @rspack/binding build:dev`;
});

// x build js
Expand Down
Loading