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

Improve CI testing #3333

Merged
merged 6 commits into from
Oct 2, 2023
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
133 changes: 100 additions & 33 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ on:
merge_group:
types: [checks_requested]

env:
RUSTFLAGS: -Dwarnings

jobs:
coverage:
name: Coverage
Expand Down Expand Up @@ -38,7 +41,7 @@ jobs:
uses: codecov/codecov-action@v3

tests:
name: Build and Test
name: Test
runs-on: ${{ matrix.os }}
timeout-minutes: 60
strategy:
Expand All @@ -58,24 +61,16 @@ jobs:
run: cargo test --no-run --profile ci
# this order is faster according to rust-analyzer
- name: Build
run: cargo build --all-targets --quiet --profile ci
run: cargo build --all-targets --quiet --profile ci --features annex-b,intl,experimental
- name: Install latest nextest
uses: taiki-e/install-action@nextest
- name: Test with nextest
run: cargo nextest run --profile ci --cargo-profile ci --features annex-b,intl,experimental
- name: Test docs
run: cargo test --doc --profile ci --features annex-b,intl,experimental
- name: Build boa_ast crate
run: cargo build -p boa_ast
- name: Build boa_cli crate
run: cargo build -p boa_cli
- name: Build boa_parser crate
run: cargo build -p boa_parser
- name: Build boa_runtime crate
run: cargo build -p boa_runtime

msrv:
name: Minimum supported Rust version
name: MSRV
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
Expand All @@ -92,41 +87,113 @@ jobs:
- name: Check compilation
run: cargo check --all-features --all-targets

misc:
name: Misc
fmt:
name: Formatting
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
- uses: actions-rs/[email protected]
with:
toolchain: stable
override: true
profile: minimal
components: rustfmt
- name: Format (rustfmt)
run: cargo fmt --all --check

clippy:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
- uses: actions-rs/[email protected]
with:
toolchain: stable
override: true
profile: minimal
components: clippy
- name: Install cargo-workspaces
uses: actions-rs/[email protected]
with:
crate: cargo-workspaces
- uses: Swatinem/rust-cache@v2
with:
key: clippy
- name: Clippy (All features)
run: cargo workspaces exec cargo clippy --all-features --all-targets -- -D warnings
- name: Clippy (No features)
run: cargo workspaces exec cargo clippy --no-default-features --all-targets -- -D warnings

docs:
name: Documentation
runs-on: ubuntu-latest
timeout-minutes: 60
env:
RUSTFLAGS: -D warnings
RUSTDOCFLAGS: -D warnings
steps:
- uses: actions/checkout@v4
- uses: actions-rs/[email protected]
with:
toolchain: stable
override: true
profile: minimal
- uses: Swatinem/rust-cache@v2
with:
key: docs
- name: Generate documentation
run: cargo doc -v --document-private-items --all-features

build-fuzz:
name: Fuzzing
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
- uses: actions-rs/[email protected]
with:
toolchain: stable
override: true
profile: minimal
components: rustfmt, clippy
- uses: actions-rs/[email protected]
- name: Install cargo-fuzz
uses: actions-rs/[email protected]
with:
crate: cargo-fuzz
version: latest
- uses: Swatinem/rust-cache@v2
with:
key: misc
- name: Format (rustfmt)
run: cargo fmt --all --check
- name: Lint (All features)
run: cargo clippy --all-features --all-targets
- name: Lint (No features)
run: cargo clippy -p boa_engine --no-default-features --all-targets
- name: Generate documentation
run: cargo doc -v --document-private-items --all-features
- name: Build
run: cargo build --all-targets --quiet --profile ci
- name: Build fuzzers
key: build-fuzz
- name: Build fuzz
run: cargo fuzz build -s none
- run: cd boa_examples
- name: Build examples
run: cargo build --quiet --profile ci
- name: Run example classes
run: cargo run --bin classes --profile ci

build-run-examples:
name: Build & run examples
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
- uses: actions-rs/[email protected]
with:
toolchain: stable
override: true
profile: minimal
- name: Install cargo-workspaces
uses: actions-rs/[email protected]
with:
crate: cargo-workspaces
- uses: Swatinem/rust-cache@v2
with:
key: build-run-examples

- name: Build (All features)
jedel1043 marked this conversation as resolved.
Show resolved Hide resolved
run: cargo workspaces exec cargo build --all-features --all-targets --profile ci
- name: Build (No features)
run: cargo workspaces exec cargo build --no-default-features --all-targets --profile ci

- name: Run examples
run: |
cd boa_examples
cargo run -p boa_examples --bin 2>&1 \
| grep -E '^ ' \
| xargs -n1 sh -c 'cargo run -p boa_examples --profile ci --bin $0 || exit 255'
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ clap = "4.4.6"
colored = "2.0.4"
fast-float = "0.2.0"
hashbrown = { version = "0.14.1", default-features = false }
indexmap = "2.0.1"
indexmap = { version = "2.0.1", default-features = false }
indoc = "2.0.4"
jemallocator = "0.5.4"
num-bigint = "0.4.4"
Expand Down
2 changes: 1 addition & 1 deletion boa_ast/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repository.workspace = true
rust-version.workspace = true

[features]
serde = ["dep:serde", "boa_interner/serde", "bitflags/serde"]
serde = ["dep:serde", "boa_interner/serde", "bitflags/serde", "num-bigint/serde"]
arbitrary = ["dep:arbitrary", "boa_interner/arbitrary", "num-bigint/arbitrary"]

[dependencies]
Expand Down
21 changes: 14 additions & 7 deletions boa_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@
clippy::pedantic,
clippy::nursery,
)]
#![allow(clippy::option_if_let_else, clippy::redundant_pub_crate)]

use boa_ast as _;
#![allow(
unused_crate_dependencies,
clippy::option_if_let_else,
clippy::redundant_pub_crate
)]

mod debug;
mod helper;
Expand All @@ -88,16 +90,21 @@ use std::{
println,
};

#[cfg(all(
target_arch = "x86_64",
target_os = "linux",
target_env = "gnu",
feature = "dhat"
))]
use jemallocator as _;

#[cfg(all(
target_arch = "x86_64",
target_os = "linux",
target_env = "gnu",
not(feature = "dhat")
))]
#[cfg_attr(
all(target_arch = "x86_64", target_os = "linux", target_env = "gnu"),
global_allocator
)]
#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;

#[cfg(feature = "dhat")]
Expand Down
2 changes: 1 addition & 1 deletion boa_engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ rustc-hash = { workspace = true, features = ["std"] }
num-bigint = { workspace = true, features = ["serde"] }
num-integer = "0.1.45"
bitflags.workspace = true
indexmap.workspace = true
indexmap = { workspace = true, features = ["std"] }
ryu-js = "0.2.2"
chrono = { workspace = true, default-features = false, features = ["clock", "std"] }
fast-float.workspace = true
Expand Down
2 changes: 2 additions & 0 deletions boa_engine/src/vm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ mod runtime_limits;
#[cfg(feature = "flowgraph")]
pub mod flowgraph;

// TODO: see if this can be exposed on all features.
#[allow(unused_imports)]
pub(crate) use opcode::{Instruction, InstructionIterator, Opcode, VaryingOperandKind};
pub use runtime_limits::RuntimeLimits;
pub use {
Expand Down
8 changes: 8 additions & 0 deletions boa_engine/src/vm/opcode/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,8 @@ macro_rules! generate_opcodes {
impl Opcode {
const MAX: usize = 2usize.pow(8) * 3;

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

/// Name of this opcode.
#[must_use]
// TODO: see if this can be exposed on all features.
#[allow(unused)]
pub(crate) const fn as_str(self) -> &'static str {
Self::NAMES[self as usize]
}
Expand Down Expand Up @@ -505,6 +509,8 @@ macro_rules! generate_opcodes {
/// Get the [`Opcode`] of the [`Instruction`].
#[inline]
#[must_use]
// TODO: see if this can be exposed on all features.
#[allow(unused)]
pub(crate) const fn opcode(&self) -> Opcode {
match self {
$(
Expand Down Expand Up @@ -2193,6 +2199,8 @@ pub(crate) struct InstructionIterator<'bytecode> {
pc: usize,
}

// TODO: see if this can be exposed on all features.
#[allow(unused)]
impl<'bytecode> InstructionIterator<'bytecode> {
/// Create a new [`InstructionIterator`] from bytecode array.
#[inline]
Expand Down
1 change: 1 addition & 0 deletions boa_examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ boa_interner.workspace = true
boa_gc.workspace = true
boa_parser.workspace = true
boa_runtime.workspace = true
chrono.workspace = true
smol = "1.3.0"
futures-util = "0.3.28"
3 changes: 1 addition & 2 deletions boa_examples/src/bin/commuter_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ impl<'ast> VisitorMut<'ast> for CommutorVisitor {
}

fn main() {
let mut parser =
Parser::new(Source::from_filepath(Path::new("boa_examples/scripts/calc.js")).unwrap());
let mut parser = Parser::new(Source::from_filepath(Path::new("./scripts/calc.js")).unwrap());
let mut ctx = Context::default();

let mut script = parser.parse_script(ctx.interner_mut()).unwrap();
Expand Down
Loading
Loading