|
|
|
name: Continuous integration
|
|
|
|
|
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
merge_group:
|
|
|
|
types: [checks_requested]
|
|
|
|
|
|
|
|
env:
|
|
|
|
RUSTFLAGS: -Dwarnings
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
coverage:
|
|
|
|
name: Coverage
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
timeout-minutes: 60
|
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
|
|
|
- name: Install Rust toolchain
|
|
|
|
uses: dtolnay/rust-toolchain@stable
|
|
|
|
with:
|
|
|
|
toolchain: stable
|
|
|
|
|
|
|
|
- uses: Swatinem/rust-cache@v2
|
|
|
|
with:
|
|
|
|
key: tarpaulin
|
|
|
|
- name: Install cargo-tarpaulin
|
|
|
|
uses: baptiste0928/cargo-install@v3.1.0
|
Initial version of a JS -> Rust conversion trait. (#2276)
This Pull Request closes #1975. It's still a work in progress, but tries to go in that direction.
It changes the following:
- Adds a new `TryFromJs` trait, that can be derived using a new `boa_derive` crate.
- Adds a new `try_js_into()` function that, similarly to the standard library `TryInto` trait
Things to think about:
- Should the `boa_derive` crate be re-exported in `boa_engine` using a `derive` feature, similar to how it's done in `serde`?
- The current implementation only converts perfectly valid values. So, if we try to convert a big integer into an `i8`, or any floating point number to an `f32`. So, you cannot derive `TryFromJs` for structures that contain an `f32` for example (you can still manually implement the trait, though, and decide in favour of a loss of precision). Should we also provide some traits for transparent loss of precision?
- Currently, you cannot convert between types, so if the JS struct has an integer, you cannot cast it to a boolean, for example. Should we provide a `TryConvertJs` trait, for example to force conversions?
- Currently we only have basic types and object conversions. Should add `Array` to `Vec` conversion, for example, right? Should we also add `TypedArray` conversions? What about `Map` and `Set`? Does this step over the fine grained APIs that we were creating?
Note that this still requires a bunch of documentation, tests, and validation from the dev team and from the users that requested this feature. I'm particularly interested in @lastmjs's thoughts on this API.
I already added an usage example in `boa_examples/src/bin/derive.rs`.
Co-authored-by: jedel1043 <jedel0124@gmail.com>
2 years ago
|
|
|
with:
|
|
|
|
crate: cargo-tarpaulin
|
|
|
|
|
Initial version of a JS -> Rust conversion trait. (#2276)
This Pull Request closes #1975. It's still a work in progress, but tries to go in that direction.
It changes the following:
- Adds a new `TryFromJs` trait, that can be derived using a new `boa_derive` crate.
- Adds a new `try_js_into()` function that, similarly to the standard library `TryInto` trait
Things to think about:
- Should the `boa_derive` crate be re-exported in `boa_engine` using a `derive` feature, similar to how it's done in `serde`?
- The current implementation only converts perfectly valid values. So, if we try to convert a big integer into an `i8`, or any floating point number to an `f32`. So, you cannot derive `TryFromJs` for structures that contain an `f32` for example (you can still manually implement the trait, though, and decide in favour of a loss of precision). Should we also provide some traits for transparent loss of precision?
- Currently, you cannot convert between types, so if the JS struct has an integer, you cannot cast it to a boolean, for example. Should we provide a `TryConvertJs` trait, for example to force conversions?
- Currently we only have basic types and object conversions. Should add `Array` to `Vec` conversion, for example, right? Should we also add `TypedArray` conversions? What about `Map` and `Set`? Does this step over the fine grained APIs that we were creating?
Note that this still requires a bunch of documentation, tests, and validation from the dev team and from the users that requested this feature. I'm particularly interested in @lastmjs's thoughts on this API.
I already added an usage example in `boa_examples/src/bin/derive.rs`.
Co-authored-by: jedel1043 <jedel0124@gmail.com>
2 years ago
|
|
|
- name: Run tarpaulin
|
|
|
|
run: cargo tarpaulin --workspace --features annex-b,intl_bundled,experimental --ignore-tests --engine llvm --out xml
|
|
|
|
|
|
|
|
- name: Upload to codecov.io
|
|
|
|
uses: codecov/codecov-action@v4
|
|
|
|
|
|
|
|
tests:
|
|
|
|
name: Test
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
timeout-minutes: 60
|
|
|
|
env:
|
|
|
|
RUSTUP_WINDOWS_PATH_ADD_BIN: 1
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
os:
|
|
|
|
- macos-latest
|
|
|
|
- windows-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
|
|
|
- name: Install Rust toolchain
|
|
|
|
uses: dtolnay/rust-toolchain@stable
|
|
|
|
with:
|
|
|
|
toolchain: stable
|
|
|
|
|
|
|
|
- uses: Swatinem/rust-cache@v2
|
|
|
|
- name: Build tests
|
|
|
|
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 --features annex-b,intl_bundled,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_bundled,experimental
|
|
|
|
- name: Test docs
|
|
|
|
run: cargo test --doc --profile ci --features annex-b,intl_bundled,experimental
|
|
|
|
|
|
|
|
msrv:
|
|
|
|
name: MSRV
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
timeout-minutes: 60
|
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
|
|
|
# Get the rust_version from the Cargo.toml
|
|
|
|
- name: Get rust_version
|
|
|
|
id: rust_version
|
|
|
|
run: echo "rust_version=$(grep '^rust-version' Cargo.toml | cut -d' ' -f3 | tr -d '"')" >> $GITHUB_OUTPUT
|
|
|
|
|
|
|
|
- name: Install Rust toolchain
|
|
|
|
uses: dtolnay/rust-toolchain@stable
|
|
|
|
with:
|
|
|
|
toolchain: ${{ steps.rust_version.outputs.rust_version }}
|
|
|
|
|
|
|
|
- name: Check compilation
|
|
|
|
run: cargo check --all-features --all-targets
|
|
|
|
|
|
|
|
fmt:
|
|
|
|
name: Formatting
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
timeout-minutes: 60
|
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
|
|
|
- name: Install Rust toolchain
|
|
|
|
uses: dtolnay/rust-toolchain@stable
|
|
|
|
with:
|
|
|
|
toolchain: stable
|
|
|
|
components: rustfmt
|
|
|
|
|
|
|
|
- name: Format (rustfmt)
|
|
|
|
run: cargo fmt --all --check
|
|
|
|
|
|
|
|
clippy:
|
|
|
|
name: Lint
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
timeout-minutes: 60
|
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
|
|
|
- name: Install Rust toolchain
|
|
|
|
uses: dtolnay/rust-toolchain@stable
|
|
|
|
with:
|
|
|
|
toolchain: stable
|
|
|
|
components: clippy
|
|
|
|
|
|
|
|
- uses: Swatinem/rust-cache@v2
|
|
|
|
with:
|
|
|
|
key: clippy
|
|
|
|
|
|
|
|
- name: Install cargo-workspaces
|
|
|
|
run: cargo install cargo-workspaces
|
|
|
|
|
|
|
|
- name: Clippy (All features)
|
|
|
|
run: cargo workspaces exec cargo clippy --all-features --all-targets
|
|
|
|
- name: Clippy (No features)
|
|
|
|
run: cargo workspaces exec cargo clippy --no-default-features --all-targets
|
|
|
|
- name: Clippy (Intl)
|
|
|
|
run: cargo clippy -p boa_engine --features intl
|
|
|
|
- name: Clippy (Annex-B)
|
|
|
|
run: cargo clippy -p boa_engine --features annex-b
|
|
|
|
- name: Clippy (Experimental)
|
|
|
|
run: cargo clippy -p boa_engine --features experimental
|
|
|
|
|
|
|
|
docs:
|
|
|
|
name: Documentation
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
timeout-minutes: 60
|
|
|
|
env:
|
|
|
|
RUSTDOCFLAGS: -D warnings
|
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
|
|
|
- name: Install Rust toolchain
|
|
|
|
uses: dtolnay/rust-toolchain@stable
|
|
|
|
with:
|
|
|
|
toolchain: stable
|
|
|
|
|
|
|
|
- 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:
|
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
|
|
|
- name: Install Rust toolchain
|
|
|
|
uses: dtolnay/rust-toolchain@stable
|
|
|
|
with:
|
|
|
|
toolchain: stable
|
|
|
|
|
|
|
|
- uses: Swatinem/rust-cache@v2
|
|
|
|
with:
|
|
|
|
key: build-fuzz
|
|
|
|
|
|
|
|
- name: Install cargo-fuzz
|
|
|
|
run: cargo install cargo-fuzz
|
|
|
|
|
|
|
|
- name: Build fuzz
|
|
|
|
run: cd tests/fuzz && cargo fuzz build -s none --dev
|
|
|
|
|
|
|
|
build-run-examples:
|
|
|
|
name: Build & run examples
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
timeout-minutes: 60
|
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
|
|
|
- name: Install Rust toolchain
|
|
|
|
uses: dtolnay/rust-toolchain@stable
|
|
|
|
with:
|
|
|
|
toolchain: stable
|
|
|
|
|
|
|
|
- uses: Swatinem/rust-cache@v2
|
|
|
|
with:
|
|
|
|
key: build-run-examples
|
|
|
|
|
|
|
|
- name: Install cargo-workspaces
|
|
|
|
run: cargo install cargo-workspaces
|
|
|
|
|
|
|
|
- name: Build (All features)
|
|
|
|
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 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'
|