Skip to content

Commit 2fab84c

Browse files
authored
Simplify CI & development make targets (#1061)
* Simplify CI & development make targets This commit is an attempt to simplify and unify our build scripts, with the idea of potentially making it easier to integrate new crates in the future and more importantly avoid divergence between our testing in CI and our testing locally. For instance, as part of this change, I realized that at some point we stopped running `cargo fmt` in CI, which is not ideal. `cargo fmt` is not runnig as part of this change yet though, I plan to add that as a follow-up. * Fix formatting in the Makefile
1 parent be5997a commit 2fab84c

File tree

3 files changed

+91
-109
lines changed

3 files changed

+91
-109
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -25,34 +25,16 @@ jobs:
2525
cache-prefix: wasi
2626

2727
- name: Lint
28-
run: |
29-
cargo clippy --workspace \
30-
--exclude=javy-cli \
31-
--exclude=javy-codegen \
32-
--exclude=javy-plugin-processing \
33-
--exclude=javy-runner \
34-
--exclude=javy-fuzz \
35-
--target=wasm32-wasip2 --all-targets --all-features -- -D warnings
28+
run: make lint-wasi-targets
3629

3730
- name: Test
38-
run: |
39-
cargo hack test --workspace \
40-
--exclude=javy-cli \
41-
--exclude=javy-codegen \
42-
--exclude=javy-plugin-processing \
43-
--exclude=javy-runner \
44-
--exclude=javy-test-plugin-wasip2 \
45-
--exclude=javy-test-invalid-plugin \
46-
--target=wasm32-wasip2 --each-feature -- --nocapture
31+
run: make test-wasi-targets
4732

4833
- name: Build plugin
49-
run: |
50-
cargo build --package=javy-plugin --release --target=wasm32-wasip2
34+
run: make build-default-plugin
5135

5236
- name: Build test plugins
53-
run: |
54-
cargo build --package=javy-test-plugin-wasip2 --release --target=wasm32-wasip2
55-
cargo build --package=javy-test-invalid-plugin --release --target=wasm32-unknown-unknown
37+
run: make build-test-plugins
5638

5739
- name: Upload plugins
5840
uses: actions/upload-artifact@v5
@@ -64,8 +46,6 @@ jobs:
6446
name: Native targets
6547
needs: wasi_ci
6648
runs-on: ubuntu-latest
67-
env:
68-
CARGO_PROFILE_RELEASE_LTO: off
6949
steps:
7050
- uses: actions/checkout@v5
7151
with:
@@ -83,25 +63,10 @@ jobs:
8363
path: target/
8464

8565
- name: Lint
86-
run: |
87-
cargo clippy --workspace \
88-
--exclude=javy \
89-
--exclude=javy-plugin-api \
90-
--exclude=javy-plugin \
91-
--exclude=javy-test-plugin-wasip2 \
92-
--release --all-targets --all-features -- -D warnings
93-
94-
- name: Initialize test plugin
95-
run: cargo run --package=javy-plugin-processing --release -- target/wasm32-wasip2/release/test_plugin.wasm target/wasm32-wasip2/release/test_plugin.wasm
66+
run: make lint-native-targets
9667

9768
- name: Test
98-
run: |
99-
cargo hack test --workspace \
100-
--exclude=javy \
101-
--exclude=javy-plugin-api \
102-
--exclude=javy-plugin \
103-
--exclude=javy-test-plugin-wasip2 \
104-
--release --each-feature -- --nocapture
69+
run: make test-native-targets-ci
10570

10671
- name: WPT
10772
run: |

Makefile

Lines changed: 78 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,90 @@
1-
.PHONY: cli plugin test fmt clean
1+
.PHONY: fmt fmt-check lint-wasi-targets test-wasi-targets wasi-targets lint-native-targets test-native-targets native-targets test-wpt test clean cli plugin build-test-plugins
22
.DEFAULT_GOAL := cli
33

4-
install:
5-
cargo install --path crates/cli
6-
7-
# Disabling LTO substantially improves compile time
8-
cli: plugin
9-
CARGO_PROFILE_RELEASE_LTO=off cargo build --package=javy-cli --release
10-
11-
plugin:
12-
cargo build --package=javy-plugin --release --target=wasm32-wasip2
13-
cargo run --package=javy-plugin-processing --release target/wasm32-wasip2/release/plugin.wasm target/wasm32-wasip2/release/plugin_wizened.wasm
14-
15-
build-test-plugins: cli
16-
cargo build --package=javy-test-plugin-wasip2 --target=wasm32-wasip2 --release
17-
cargo build --package=javy-test-invalid-plugin --target=wasm32-unknown-unknown --release
18-
cargo run --package=javy-plugin-processing --release -- target/wasm32-wasip2/release/test_plugin.wasm target/wasm32-wasip2/release/test_plugin.wasm
19-
20-
docs:
21-
cargo doc --package=javy-cli --open
22-
cargo doc --package=javy-plugin --open --target=wasm32-wasip2
23-
24-
test-javy:
25-
cargo hack test --package=javy --target=wasm32-wasip2 --each-feature -- --nocapture
26-
27-
test-plugin-api:
28-
cargo hack test --package=javy-plugin-api --target=wasm32-wasip2 --each-feature -- --nocapture
29-
30-
test-plugin:
31-
cargo test --package=javy-plugin --target=wasm32-wasip2 -- --nocapture
32-
33-
test-plugin-processing:
34-
cargo test --package=javy-plugin-processing --release -- --nocapture
35-
36-
test-codegen: cli
37-
CARGO_PROFILE_RELEASE_LTO=off cargo hack test --package=javy-codegen --release --each-feature -- --nocapture
38-
39-
# Test in release mode to skip some debug assertions
40-
# Note: to make this faster, the engine should be optimized beforehand (wasm-strip + wasm-opt).
41-
# Disabling LTO substantially improves compile time
42-
test-cli: plugin build-test-plugins
43-
CARGO_PROFILE_RELEASE_LTO=off cargo test --package=javy-cli --release -- --nocapture
44-
45-
test-runner:
46-
cargo test --package=javy-runner -- --nocapture
47-
48-
test-wpt: cli
4+
# === Format checks ===
5+
fmt-check:
6+
cargo fmt --all --check
7+
fmt:
8+
cargo fmt --all
9+
10+
# === Lint & Test WASI Targets ===
11+
lint-wasi-targets:
12+
cargo clippy --workspace \
13+
--exclude=javy-cli \
14+
--exclude=javy-codegen \
15+
--exclude=javy-plugin-processing \
16+
--exclude=javy-runner \
17+
--exclude=javy-fuzz \
18+
--target=wasm32-wasip2 --all-targets --all-features -- -D warnings
19+
20+
test-wasi-targets:
21+
cargo hack test --workspace \
22+
--exclude=javy-cli \
23+
--exclude=javy-codegen \
24+
--exclude=javy-plugin-processing \
25+
--exclude=javy-runner \
26+
--exclude=javy-fuzz \
27+
--exclude=javy-test-plugin-wasip2 \
28+
--exclude=javy-test-invalid-plugin \
29+
--target=wasm32-wasip2 --each-feature -- --nocapture
30+
31+
wasi-targets: lint-wasi-targets test-wasi-targets
32+
33+
# === Lint & Test Native Targets ===
34+
lint-native-targets:
35+
CARGO_PROFILE_RELEASE_LTO=off cargo clippy --workspace \
36+
--exclude=javy \
37+
--exclude=javy-plugin-api \
38+
--exclude=javy-plugin \
39+
--exclude=javy-test-plugin-wasip2 \
40+
--release --all-targets --all-features -- -D warnings
41+
42+
test-native-targets: build-default-plugin build-test-plugins test-native-targets-ci
43+
44+
# This command assumes a CI environment in which the test plugin
45+
# assets have been previously created in the expected directories.
46+
# This ensures that we can recycle CI time.
47+
test-native-targets-ci:
48+
CARGO_PROFILE_RELEASE_LTO=off cargo hack test --workspace \
49+
--exclude=javy \
50+
--exclude=javy-plugin-api \
51+
--exclude=javy-plugin \
52+
--exclude=javy-test-plugin-wasip2 \
53+
--release --each-feature -- --nocapture
54+
55+
56+
native-targets: lint-native-targets test-native-targets
57+
58+
# === Web Platform Tests
59+
60+
# For usage in CI, in which we assume pre-existing assets.
61+
test-wpt-ci:
4962
npm install --prefix wpt
5063
npm test --prefix wpt
5164

52-
tests: test-javy test-plugin-api test-plugin test-plugin-processing test-runner test-codegen test-cli test-wpt
65+
test-wpt: cli test-wpt-ci
5366

54-
fmt: fmt-javy fmt-plugin-api fmt-plugin fmt-plugin-processing fmt-cli fmt-codegen
67+
# === All tests ===
68+
test-all: wasi-targets native-targets test-wpt
5569

56-
fmt-javy:
57-
cargo fmt --package=javy -- --check
58-
cargo clippy --package=javy --target=wasm32-wasip2 --all-targets --all-features -- -D warnings
5970

60-
fmt-plugin-api:
61-
cargo fmt --package=javy-plugin-api -- --check
62-
cargo clippy --package=javy-plugin-api --target=wasm32-wasip2 --all-targets --all-features -- -D warnings
6371

64-
fmt-plugin:
65-
cargo fmt --package=javy-plugin -- --check
66-
cargo clippy --package=javy-plugin --target=wasm32-wasip2 --all-targets --all-features -- -D warnings
72+
# === Misc ===
73+
clean:
74+
cargo clean
6775

68-
fmt-plugin-processing:
69-
cargo fmt --package=javy-plugin-processing -- --check
70-
cargo clippy --package=javy-plugin-processing --release --all-targets --all-features -- -D warnings
76+
# First, build the default plugin, which is a dependency to the CLI.
77+
# No need to run `javy_plugin_processing`, the CLI build.rs will take
78+
# care of doing that.
79+
cli: build-default-plugin
80+
CARGO_PROFILE_RELEASE_LTO=off cargo build -p=javy-cli --release
7181

72-
# Use `--release` on CLI clippy to align with `test-cli`.
73-
# This reduces the size of the target directory which improves CI stability.
74-
fmt-cli:
75-
cargo fmt --package=javy-cli -- --check
76-
CARGO_PROFILE_RELEASE_LTO=off cargo clippy --package=javy-cli --release --all-targets -- -D warnings
82+
# Build the default plugin
83+
build-default-plugin:
84+
cargo build -p=javy-plugin --target=wasm32-wasip2 --release
7785

78-
fmt-codegen:
79-
cargo fmt --package=javy-codegen -- --check
80-
cargo clippy --package=javy-codegen --release --all-targets --all-features -- -D warnings
86+
# Build auxiliary plugins, for testing
87+
build-test-plugins:
88+
cargo build --package=javy-test-plugin-wasip2 --target=wasm32-wasip2 --release
89+
cargo build --package=javy-test-invalid-plugin --target=wasm32-unknown-unknown --release
90+
cargo run --package=javy-plugin-processing --release -- target/wasm32-wasip2/release/test_plugin.wasm target/wasm32-wasip2/release/test_plugin.wasm

flake.nix

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,16 @@
1010
{
1111
devShells.default = pkgs.mkShell {
1212
packages = with pkgs; [
13+
wasmtime
1314
llvmPackages_latest.libclang
1415
];
1516

17+
BINDGEN_EXTRA_CLANG_ARGS = builtins.concatStringsSep " " [
18+
"-isystem ${pkgs.llvmPackages_latest.libclang.lib}/lib/clang/${pkgs.llvmPackages_latest.libclang.version}/include"
19+
"-isystem ${pkgs.glibc.dev}/include"
20+
];
21+
# rquickjs automatically installs the WASI SDK.
22+
BINDGEN_EXTRA_CLANG_ARGS_wasm32_wasip2 = "";
1623
LIBCLANG_PATH = "${pkgs.llvmPackages_latest.libclang.lib}/lib";
1724
};
1825
});

0 commit comments

Comments
 (0)