Skip to content

chore(tasks): use assert_eq! instead of assert! (`tasks/minsize/s… #33033

chore(tasks): use assert_eq! instead of assert! (`tasks/minsize/s…

chore(tasks): use assert_eq! instead of assert! (`tasks/minsize/s… #33033

Workflow file for this run

name: CI
on:
workflow_dispatch:
pull_request:
types: [opened, synchronize]
paths-ignore:
- "**/*.md"
- "**/*.yml"
- "!.github/workflows/ci.yml"
- "!.github/actions/clone-submodules/action.yml"
push:
branches:
- main
- "renovate/**"
paths-ignore:
- "**/*.md"
- "**/*.yml"
- "!.github/workflows/ci.yml"
- "!.github/actions/clone-submodules/action.yml"
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: ${{ github.ref_name != 'main' }}
jobs:
test:
name: Test
strategy:
fail-fast: false
matrix:
include:
# - os: windows-latest # See `test-windows` job below
- os: ubuntu-latest
- os: macos-latest
runs-on: ${{ matrix.os }}
steps:
- uses: taiki-e/checkout-action@b13d20b7cda4e2f325ef19895128f7ff735c0b3d # v1.3.1
- uses: oxc-project/setup-rust@cd82e1efec7fef815e2c23d296756f31c7cdc03d # v1.0.0
with:
# warm cache factory for all other CI jobs
# cache `target` directory to avoid download crates
save-cache: ${{ github.ref_name == 'main' }}
cache-key: warm
- run: cargo ck
- run: cargo test
- run: git diff --exit-code # Must commit everything
test-windows:
name: Test (windows-latest)
if: ${{ github.ref_name == 'main' }}
runs-on: windows-latest
steps:
- uses: taiki-e/checkout-action@b13d20b7cda4e2f325ef19895128f7ff735c0b3d # v1.3.1
# Unsung heros of the internet, who led me here to speed up window's slowness:
# https://github.com/actions/cache/issues/752#issuecomment-1847036770
# https://github.com/astral-sh/uv/blob/502e04200d52de30d3159894833b3db4f0d6644d/.github/workflows/ci.yml#L158
- uses: samypr100/setup-dev-drive@d3f2420389ae9ea6e91dd178779e122c42352047 # v3
with:
workspace-copy: true
drive-size: 8GB
- name: Install Rust
working-directory: ${{ env.DEV_DRIVE_WORKSPACE }}
env:
CARGO_HOME: ${{ env.DEV_DRIVE }}/.cargo
RUSTUP_HOME: ${{ env.DEV_DRIVE }}/.rustup
shell: bash
run: |
# This `awk` command will find the value of our Minimum Supported Rust Version and store it as `MSRV`.
# NOTE: this will fail if there are any other items named `rust-version`. We assume there is only one in our `Cargo.toml`.
MSRV=$(awk -F'=' '/rust-version/ {gsub(/[" ]/, "", $2); printf "%s", ($2 + "")}' Cargo.toml)
# Set profile to minimal and channel to our Minimum Supported Rust Version.
# Running our tests on this channel ensures that our code uses APIs that are supported in our `MSRV`.
sed -i -e 's/profile = "default"/profile = "minimal"/g' -e "s/channel = .*/channel = \"$MSRV\"/g" rust-toolchain.toml
rustup set profile minimal
rustup show
git restore .
- uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2
with:
workspaces: ${{ env.DEV_DRIVE_WORKSPACE }}
save-if: ${{ github.ref_name == 'main' }}
shared-key: windows-latest
env:
CARGO_HOME: ${{ env.DEV_DRIVE }}/.cargo
RUSTUP_HOME: ${{ env.DEV_DRIVE }}/.rustup
- name: Run
working-directory: ${{ env.DEV_DRIVE_WORKSPACE }}
env:
CARGO_HOME: ${{ env.DEV_DRIVE }}/.cargo
RUSTUP_HOME: ${{ env.DEV_DRIVE }}/.rustup
shell: bash
run: |
# cargo ck # no need to check because it's already checked in linux
cargo test --workspace
test-wasm32-wasip1-threads:
name: Test wasm32-wasip1-threads
if: ${{ github.ref_name == 'main' }}
runs-on: ubuntu-latest
env:
RUSTFLAGS: "--cfg tokio_unstable -C target-feature=+atomics,+bulk-memory,+mutable-globals,+simd128 -C link-args=--max-memory=67108864"
CARGO_TARGET_WASM32_WASIP1_THREADS_RUNNER: "wasmtime run -W bulk-memory=y -W threads=y -S threads=y --dir=${{ github.workspace }}::${{ github.workspace }} --"
# Insta is not able to run on wasmtime, omit the packages that depend on it
TEST_FLAGS: "-p oxc_ast -p oxc_cfg -p oxc_regular_expression -- --nocapture"
steps:
- uses: taiki-e/checkout-action@b13d20b7cda4e2f325ef19895128f7ff735c0b3d # v1.3.1
- uses: oxc-project/setup-rust@cd82e1efec7fef815e2c23d296756f31c7cdc03d # v1.0.0
with:
cache-key: wasi
save-cache: ${{ github.ref_name == 'main' }}
- run: rustup target add wasm32-wasip1-threads
- uses: bytecodealliance/actions/wasmtime/setup@d742827944dcb656569399571a8a45261b5089f6 # v1.1.0
- run: cargo test --target wasm32-wasip1-threads ${TEST_FLAGS}
- run: git diff --exit-code # Must commit everything
test-wasm32-unknown-unknown:
name: Check wasm32-unknown-unknown
runs-on: ubuntu-latest
steps:
- uses: taiki-e/checkout-action@b13d20b7cda4e2f325ef19895128f7ff735c0b3d # v1.3.1
- uses: oxc-project/setup-rust@cd82e1efec7fef815e2c23d296756f31c7cdc03d # v1.0.0
with:
cache-key: wasm
save-cache: ${{ github.ref_name == 'main' }}
tools: wasm-pack,just
- name: Check
run: |
rustup target add wasm32-unknown-unknown
cargo check -p oxc_wasm --target wasm32-unknown-unknown
- uses: ./.github/actions/pnpm
- run: just build-wasm debug
- working-directory: npm/oxc-wasm
run: pnpm run check
- working-directory: wasm/parser
run: pnpm run build
- working-directory: npm/parser-wasm
run: pnpm run check
typos:
name: Spell Check
runs-on: ubuntu-latest
steps:
- uses: taiki-e/checkout-action@b13d20b7cda4e2f325ef19895128f7ff735c0b3d # v1.3.1
- uses: crate-ci/typos@d1c850b2b5d502763520c25fb4a6a1128ad99bd9 # v1.28.3
with:
files: .
lint:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: taiki-e/checkout-action@b13d20b7cda4e2f325ef19895128f7ff735c0b3d # v1.3.1
- uses: oxc-project/setup-rust@cd82e1efec7fef815e2c23d296756f31c7cdc03d # v1.0.0
with:
save-cache: ${{ github.ref_name == 'main' }}
cache-key: clippy
components: clippy
- run: cargo lint -- -D warnings
- name: Check Char and Byte Offset
run: |
npm i @ast-grep/cli -g
output=$(sg -p '$A.chars().enumerate()' -r '$A.char_indices()' -l rs)
echo "Output: $output"
if [ -n "$output" ]; then
echo "Error: Unexpected output detected"
exit 1
fi
doc:
name: Doc
runs-on: ubuntu-latest
steps:
- uses: taiki-e/checkout-action@b13d20b7cda4e2f325ef19895128f7ff735c0b3d # v1.3.1
- uses: oxc-project/setup-rust@cd82e1efec7fef815e2c23d296756f31c7cdc03d # v1.0.0
with:
cache-key: warm
components: rust-docs
- run: RUSTDOCFLAGS='-D warnings' cargo doc --no-deps --document-private-items
conformance:
name: Conformance
runs-on: ubuntu-latest
steps:
- uses: taiki-e/checkout-action@b13d20b7cda4e2f325ef19895128f7ff735c0b3d # v1.3.1
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3
id: filter
with:
filters: |
src:
- '!.github/**'
- '!.vscode/**'
- '!apps/**'
- '!editors/**'
- '!napi/**'
- '!npm/**'
- '!wasm/**'
- '!crates/oxc_linter/**'
- '!crates/oxc_wasm/**'
- '!crates/oxc_language_server/**'
- '!tasks/**'
- 'tasks/conformance/**'
- uses: ./.github/actions/clone-submodules
if: steps.filter.outputs.src == 'true'
- uses: ./.github/actions/pnpm
if: steps.filter.outputs.src == 'true'
- uses: oxc-project/setup-rust@cd82e1efec7fef815e2c23d296756f31c7cdc03d # v1.0.0
if: steps.filter.outputs.src == 'true'
with:
cache-key: conformance
save-cache: ${{ github.ref_name == 'main' }}
tools: just
- name: Check Conformance
if: steps.filter.outputs.src == 'true'
run: |
just update-transformer-fixtures
just coverage
git diff --exit-code
minification:
name: Minification Size
runs-on: ubuntu-latest
steps:
- uses: taiki-e/checkout-action@b13d20b7cda4e2f325ef19895128f7ff735c0b3d # v1.3.1
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3
id: filter
with:
filters: |
src:
- '.github/workflows/ci.yml'
- 'crates/oxc_minifier/**'
- 'crates/oxc_codegen/**'
- 'tasks/minsize/**'
- uses: oxc-project/setup-rust@cd82e1efec7fef815e2c23d296756f31c7cdc03d # v1.0.0
if: steps.filter.outputs.src == 'true'
with:
cache-key: minsize
save-cache: ${{ github.ref_name == 'main' }}
- name: Check minification size
if: steps.filter.outputs.src == 'true'
run: |
cargo minsize
git diff --exit-code
ast_changes:
name: AST Changes
runs-on: ubuntu-latest
steps:
- uses: taiki-e/checkout-action@b13d20b7cda4e2f325ef19895128f7ff735c0b3d # v1.3.1
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3
id: filter
with:
filters: ".github/.generated_ast_watch_list.yml"
- uses: oxc-project/setup-rust@cd82e1efec7fef815e2c23d296756f31c7cdc03d # v1.0.0
if: steps.filter.outputs.src == 'true'
with:
components: rustfmt
tools: dprint
cache-key: ast_changes
save-cache: ${{ github.ref_name == 'main' }}
- name: Restore dprint plugin cache
id: cache-restore
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4
with:
key: dprint-autofix-ci-${{ runner.os }}-${{ hashFiles('dprint.json') }}
path: ~/.cache/dprint
- name: Check AST Changes
if: steps.filter.outputs.src == 'true'
run: |
cargo run -p oxc_ast_tools
git diff --exit-code ||
(echo 'AST changes caused the "generated" code to get outdated. Have you forgotten to run the `just ast` command and/or commit generated codes?' && exit 1)
- name: Save dprint plugin cache
if: ${{ github.ref_name == 'main' }}
id: cache-save
uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4
with:
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
path: ~/.cache/dprint
napi:
name: Test NAPI
runs-on: ubuntu-latest
steps:
- uses: taiki-e/checkout-action@b13d20b7cda4e2f325ef19895128f7ff735c0b3d # v1.3.1
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3
id: filter
with:
filters: |
src:
- '!crates/oxc_linter/**'
- uses: oxc-project/setup-rust@cd82e1efec7fef815e2c23d296756f31c7cdc03d # v1.0.0
if: steps.filter.outputs.src == 'true'
with:
cache-key: warm
- uses: ./.github/actions/pnpm
if: steps.filter.outputs.src == 'true'
- run: pnpm run build-dev
if: steps.filter.outputs.src == 'true'
- run: pnpm run test
if: steps.filter.outputs.src == 'true'
- run: git diff --exit-code # Must commit everything
if: steps.filter.outputs.src == 'true'