Skip to content

Commit d8f6834

Browse files
authored
Improve CI testing (#3333)
* Improve CI testing * Bail on error * cargo fmt * Invert names * Split misc action * Rename some actions
1 parent e54609e commit d8f6834

File tree

19 files changed

+262
-178
lines changed

19 files changed

+262
-178
lines changed

.github/workflows/rust.yml

Lines changed: 100 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ on:
1010
merge_group:
1111
types: [checks_requested]
1212

13+
env:
14+
RUSTFLAGS: -Dwarnings
15+
1316
jobs:
1417
coverage:
1518
name: Coverage
@@ -38,7 +41,7 @@ jobs:
3841
uses: codecov/codecov-action@v3
3942

4043
tests:
41-
name: Build and Test
44+
name: Test
4245
runs-on: ${{ matrix.os }}
4346
timeout-minutes: 60
4447
strategy:
@@ -58,24 +61,16 @@ jobs:
5861
run: cargo test --no-run --profile ci
5962
# this order is faster according to rust-analyzer
6063
- name: Build
61-
run: cargo build --all-targets --quiet --profile ci
64+
run: cargo build --all-targets --quiet --profile ci --features annex-b,intl,experimental
6265
- name: Install latest nextest
6366
uses: taiki-e/install-action@nextest
6467
- name: Test with nextest
6568
run: cargo nextest run --profile ci --cargo-profile ci --features annex-b,intl,experimental
6669
- name: Test docs
6770
run: cargo test --doc --profile ci --features annex-b,intl,experimental
68-
- name: Build boa_ast crate
69-
run: cargo build -p boa_ast
70-
- name: Build boa_cli crate
71-
run: cargo build -p boa_cli
72-
- name: Build boa_parser crate
73-
run: cargo build -p boa_parser
74-
- name: Build boa_runtime crate
75-
run: cargo build -p boa_runtime
7671

7772
msrv:
78-
name: Minimum supported Rust version
73+
name: MSRV
7974
runs-on: ubuntu-latest
8075
timeout-minutes: 60
8176
steps:
@@ -92,41 +87,113 @@ jobs:
9287
- name: Check compilation
9388
run: cargo check --all-features --all-targets
9489

95-
misc:
96-
name: Misc
90+
fmt:
91+
name: Formatting
92+
runs-on: ubuntu-latest
93+
timeout-minutes: 60
94+
steps:
95+
- uses: actions/checkout@v4
96+
- uses: actions-rs/toolchain@v1.0.7
97+
with:
98+
toolchain: stable
99+
override: true
100+
profile: minimal
101+
components: rustfmt
102+
- name: Format (rustfmt)
103+
run: cargo fmt --all --check
104+
105+
clippy:
106+
name: Lint
107+
runs-on: ubuntu-latest
108+
timeout-minutes: 60
109+
steps:
110+
- uses: actions/checkout@v4
111+
- uses: actions-rs/toolchain@v1.0.7
112+
with:
113+
toolchain: stable
114+
override: true
115+
profile: minimal
116+
components: clippy
117+
- name: Install cargo-workspaces
118+
uses: actions-rs/install@v0.1
119+
with:
120+
crate: cargo-workspaces
121+
- uses: Swatinem/rust-cache@v2
122+
with:
123+
key: clippy
124+
- name: Clippy (All features)
125+
run: cargo workspaces exec cargo clippy --all-features --all-targets -- -D warnings
126+
- name: Clippy (No features)
127+
run: cargo workspaces exec cargo clippy --no-default-features --all-targets -- -D warnings
128+
129+
docs:
130+
name: Documentation
97131
runs-on: ubuntu-latest
98132
timeout-minutes: 60
99133
env:
100-
RUSTFLAGS: -D warnings
134+
RUSTDOCFLAGS: -D warnings
135+
steps:
136+
- uses: actions/checkout@v4
137+
- uses: actions-rs/toolchain@v1.0.7
138+
with:
139+
toolchain: stable
140+
override: true
141+
profile: minimal
142+
- uses: Swatinem/rust-cache@v2
143+
with:
144+
key: docs
145+
- name: Generate documentation
146+
run: cargo doc -v --document-private-items --all-features
147+
148+
build-fuzz:
149+
name: Fuzzing
150+
runs-on: ubuntu-latest
151+
timeout-minutes: 60
101152
steps:
102153
- uses: actions/checkout@v4
103154
- uses: actions-rs/toolchain@v1.0.7
104155
with:
105156
toolchain: stable
106157
override: true
107158
profile: minimal
108-
components: rustfmt, clippy
109-
- uses: actions-rs/install@v0.1
159+
- name: Install cargo-fuzz
160+
uses: actions-rs/install@v0.1
110161
with:
111162
crate: cargo-fuzz
112163
version: latest
113164
- uses: Swatinem/rust-cache@v2
114165
with:
115-
key: misc
116-
- name: Format (rustfmt)
117-
run: cargo fmt --all --check
118-
- name: Lint (All features)
119-
run: cargo clippy --all-features --all-targets
120-
- name: Lint (No features)
121-
run: cargo clippy -p boa_engine --no-default-features --all-targets
122-
- name: Generate documentation
123-
run: cargo doc -v --document-private-items --all-features
124-
- name: Build
125-
run: cargo build --all-targets --quiet --profile ci
126-
- name: Build fuzzers
166+
key: build-fuzz
167+
- name: Build fuzz
127168
run: cargo fuzz build -s none
128-
- run: cd boa_examples
129-
- name: Build examples
130-
run: cargo build --quiet --profile ci
131-
- name: Run example classes
132-
run: cargo run --bin classes --profile ci
169+
170+
build-run-examples:
171+
name: Build & run examples
172+
runs-on: ubuntu-latest
173+
timeout-minutes: 60
174+
steps:
175+
- uses: actions/checkout@v4
176+
- uses: actions-rs/toolchain@v1.0.7
177+
with:
178+
toolchain: stable
179+
override: true
180+
profile: minimal
181+
- name: Install cargo-workspaces
182+
uses: actions-rs/install@v0.1
183+
with:
184+
crate: cargo-workspaces
185+
- uses: Swatinem/rust-cache@v2
186+
with:
187+
key: build-run-examples
188+
189+
- name: Build (All features)
190+
run: cargo workspaces exec cargo build --all-features --all-targets --profile ci
191+
- name: Build (No features)
192+
run: cargo workspaces exec cargo build --no-default-features --all-targets --profile ci
193+
194+
- name: Run examples
195+
run: |
196+
cd boa_examples
197+
cargo run -p boa_examples --bin 2>&1 \
198+
| grep -E '^ ' \
199+
| xargs -n1 sh -c 'cargo run -p boa_examples --profile ci --bin $0 || exit 255'

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ clap = "4.4.6"
4747
colored = "2.0.4"
4848
fast-float = "0.2.0"
4949
hashbrown = { version = "0.14.1", default-features = false }
50-
indexmap = "2.0.1"
50+
indexmap = { version = "2.0.1", default-features = false }
5151
indoc = "2.0.4"
5252
jemallocator = "0.5.4"
5353
num-bigint = "0.4.4"

boa_ast/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repository.workspace = true
1111
rust-version.workspace = true
1212

1313
[features]
14-
serde = ["dep:serde", "boa_interner/serde", "bitflags/serde"]
14+
serde = ["dep:serde", "boa_interner/serde", "bitflags/serde", "num-bigint/serde"]
1515
arbitrary = ["dep:arbitrary", "boa_interner/arbitrary", "num-bigint/arbitrary"]
1616

1717
[dependencies]

boa_cli/src/main.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,11 @@
5959
clippy::pedantic,
6060
clippy::nursery,
6161
)]
62-
#![allow(clippy::option_if_let_else, clippy::redundant_pub_crate)]
63-
64-
use boa_ast as _;
62+
#![allow(
63+
unused_crate_dependencies,
64+
clippy::option_if_let_else,
65+
clippy::redundant_pub_crate
66+
)]
6567

6668
mod debug;
6769
mod helper;
@@ -88,16 +90,21 @@ use std::{
8890
println,
8991
};
9092

93+
#[cfg(all(
94+
target_arch = "x86_64",
95+
target_os = "linux",
96+
target_env = "gnu",
97+
feature = "dhat"
98+
))]
99+
use jemallocator as _;
100+
91101
#[cfg(all(
92102
target_arch = "x86_64",
93103
target_os = "linux",
94104
target_env = "gnu",
95105
not(feature = "dhat")
96106
))]
97-
#[cfg_attr(
98-
all(target_arch = "x86_64", target_os = "linux", target_env = "gnu"),
99-
global_allocator
100-
)]
107+
#[global_allocator]
101108
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
102109

103110
#[cfg(feature = "dhat")]

boa_engine/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ rustc-hash = { workspace = true, features = ["std"] }
6565
num-bigint = { workspace = true, features = ["serde"] }
6666
num-integer = "0.1.45"
6767
bitflags.workspace = true
68-
indexmap.workspace = true
68+
indexmap = { workspace = true, features = ["std"] }
6969
ryu-js = "0.2.2"
7070
chrono = { workspace = true, default-features = false, features = ["clock", "std"] }
7171
fast-float.workspace = true

boa_engine/src/vm/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ mod runtime_limits;
3232
#[cfg(feature = "flowgraph")]
3333
pub mod flowgraph;
3434

35+
// TODO: see if this can be exposed on all features.
36+
#[allow(unused_imports)]
3537
pub(crate) use opcode::{Instruction, InstructionIterator, Opcode, VaryingOperandKind};
3638
pub use runtime_limits::RuntimeLimits;
3739
pub use {

boa_engine/src/vm/opcode/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,8 @@ macro_rules! generate_opcodes {
398398
impl Opcode {
399399
const MAX: usize = 2usize.pow(8) * 3;
400400

401+
// TODO: see if this can be exposed on all features.
402+
#[allow(unused)]
401403
const NAMES: [&'static str; Self::MAX] = [
402404
$(<generate_opcodes!(name $Variant $(=> $mapping)?)>::NAME),*,
403405
$(<generate_opcodes!(name $Variant $(=> $mapping)?)>::NAME),*,
@@ -406,6 +408,8 @@ macro_rules! generate_opcodes {
406408

407409
/// Name of this opcode.
408410
#[must_use]
411+
// TODO: see if this can be exposed on all features.
412+
#[allow(unused)]
409413
pub(crate) const fn as_str(self) -> &'static str {
410414
Self::NAMES[self as usize]
411415
}
@@ -505,6 +509,8 @@ macro_rules! generate_opcodes {
505509
/// Get the [`Opcode`] of the [`Instruction`].
506510
#[inline]
507511
#[must_use]
512+
// TODO: see if this can be exposed on all features.
513+
#[allow(unused)]
508514
pub(crate) const fn opcode(&self) -> Opcode {
509515
match self {
510516
$(
@@ -2193,6 +2199,8 @@ pub(crate) struct InstructionIterator<'bytecode> {
21932199
pc: usize,
21942200
}
21952201

2202+
// TODO: see if this can be exposed on all features.
2203+
#[allow(unused)]
21962204
impl<'bytecode> InstructionIterator<'bytecode> {
21972205
/// Create a new [`InstructionIterator`] from bytecode array.
21982206
#[inline]

boa_examples/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ boa_interner.workspace = true
1616
boa_gc.workspace = true
1717
boa_parser.workspace = true
1818
boa_runtime.workspace = true
19+
chrono.workspace = true
1920
smol = "1.3.0"
2021
futures-util = "0.3.28"

boa_examples/src/bin/commuter_visitor.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ impl<'ast> VisitorMut<'ast> for CommutorVisitor {
6565
}
6666

6767
fn main() {
68-
let mut parser =
69-
Parser::new(Source::from_filepath(Path::new("boa_examples/scripts/calc.js")).unwrap());
68+
let mut parser = Parser::new(Source::from_filepath(Path::new("./scripts/calc.js")).unwrap());
7069
let mut ctx = Context::default();
7170

7271
let mut script = parser.parse_script(ctx.interner_mut()).unwrap();

0 commit comments

Comments
 (0)