[WIP] [Refactor] Defining clippy rules #225
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Rust | |
# Contains checks: | |
# - That the code compiles | |
# - That the code complies with formatting | |
# - Lints (using clippy) to find errors | |
# - That crates that are published are publish-able | |
# - Testing | |
# - Standard Rust integration and unit tests | |
# - Fuzz tests | |
# - WASM edition works tests | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
env: | |
CARGO_TERM_COLOR: always | |
CACHE_PATHS: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
jobs: | |
validity: | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: dtolnay/rust-toolchain@stable | |
- uses: actions/cache@v3 | |
with: | |
path: ${{ env.CACHE_PATHS }} | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- uses: dorny/paths-filter@v2 | |
id: changes | |
with: | |
filters: | | |
parser: | |
- 'parser/**' | |
checker: | |
- 'checker/**' | |
src: | |
- 'src/**' | |
- name: Check source is valid | |
run: cargo check --workspace | |
- name: Check binary | |
run: cargo check --bin ezno | |
- uses: brndnmtthws/rust-action-cargo-binstall@v1 | |
if: steps.changes.outputs.src == 'true' | |
with: | |
packages: [email protected] | |
- name: Check WASM | |
if: steps.changes.outputs.src == 'true' | |
run: | | |
rustup target add wasm32-unknown-unknown | |
# Need to build to check that the JS builds | |
npm ci | |
npm run build | |
working-directory: src/js-cli-and-library | |
- name: Check parser without extras | |
if: steps.changes.outputs.parser == 'true' | |
run: | |
cargo check -p ezno-parser --no-default-features | |
- name: Check checker without default features | |
if: steps.changes.outputs.checker == 'true' | |
run: | |
cargo check -p ezno-checker --no-default-features | |
formating: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: dtolnay/rust-toolchain@stable | |
- name: Check Rust formatting with rustfmt | |
run: cargo fmt --all --check | |
- uses: brndnmtthws/rust-action-cargo-binstall@v1 | |
with: | |
packages: taplo-cli | |
- name: Check TOML formatting with taplo | |
run: | | |
taplo fmt --check **/*/Cargo.toml | |
tests: | |
needs: validity | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: dtolnay/rust-toolchain@stable | |
- uses: actions/cache@v3 | |
with: | |
path: ${{ env.CACHE_PATHS }} | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- uses: dorny/paths-filter@v2 | |
id: changes | |
with: | |
filters: | | |
parser: | |
- 'parser/**' | |
checker: | |
- 'checker/**' | |
- name: Run parser tests | |
if: steps.changes.outputs.parser == 'true' | |
run: | | |
cargo test | |
# TODO test other big libraries | |
curl https://esm.sh/v128/[email protected]/es2022/react-dom.mjs > react.js | |
cargo run -p ezno-parser --example parse react.js > /dev/null | |
cargo test -p ezno-ast-generator | |
working-directory: parser | |
- name: Run checker specification | |
if: steps.changes.outputs.checker == 'true' | |
run: cargo test | |
working-directory: checker/specification | |
- name: Run checker tests | |
if: steps.changes.outputs.checker == 'true' | |
run: cargo test -F ezno-parser | |
working-directory: checker | |
- name: Run base tests | |
run: cargo test | |
- uses: brndnmtthws/rust-action-cargo-binstall@v1 | |
with: | |
packages: [email protected] | |
- uses: denoland/setup-deno@v1 | |
with: | |
deno-version: v1.x | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Build and test WASM | |
run: | | |
rustup target add wasm32-unknown-unknown | |
npm ci | |
npm run test | |
node ./dist/cli.cjs info | |
deno run -A ./dist/cli.mjs info | |
working-directory: src/js-cli-and-library | |
shell: bash | |
fuzzing: | |
needs: validity | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
continue-on-error: true | |
strategy: | |
matrix: | |
fuzz-target: [module_roundtrip_naive, module_roundtrip_structured] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: dtolnay/rust-toolchain@stable | |
- uses: actions/cache@v3 | |
with: | |
path: ${{ env.CACHE_PATHS }} | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- uses: dorny/paths-filter@v2 | |
id: changes | |
with: | |
filters: | | |
parser: | |
- 'parser/**' | |
- name: Install latest nightly and set it as default | |
if: steps.changes.outputs.parser == 'true' | |
run: | | |
rustup install nightly | |
rustup default nightly | |
- uses: brndnmtthws/rust-action-cargo-binstall@v1 | |
if: steps.changes.outputs.parser == 'true' | |
with: | |
packages: cargo-fuzz | |
- name: Run fuzzing | |
if: steps.changes.outputs.parser == 'true' | |
run: | | |
cargo fuzz run -s none ${{ matrix.fuzz-target }} -- -timeout=10 -max_total_time=120 -use_value_profile=1 | |
working-directory: parser/fuzz | |
clippy: | |
needs: validity | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: dtolnay/rust-toolchain@stable | |
- uses: actions/cache@v3 | |
with: | |
path: ${{ env.CACHE_PATHS }} | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Lint code with clippy | |
run: cargo clippy | |
publish-ability: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: dtolnay/rust-toolchain@stable | |
- name: Check that it will publish to crates | |
run: | | |
cargo metadata --offline --format-version 1 --no-deps | jq -r ".workspace_members[]" | while read -r _n _v pathInfo ; do | |
cd ${pathInfo:13:-1} | |
cargo publish --no-verify --dry-run | |
done | |
shell: bash |