Merge pull request #46 from kaleidawave/checker-improvements #94
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 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/cache@v3 | |
with: | |
path: ${{ env.CACHE_PATHS }} | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Check source is valid | |
run: cargo check --workspace | |
formating: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- 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 | |
steps: | |
- uses: actions/checkout@v3 | |
- 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: Run parser tests | |
if: steps.changes.outputs.parser == 'true' | |
run: cargo test | |
working-directory: parser | |
- name: Run base tests | |
run: cargo test | |
fuzzing: | |
needs: validity | |
runs-on: ubuntu-latest | |
continue-on-error: true | |
strategy: | |
matrix: | |
fuzz-target: [module_roundtrip_naive, module_roundtrip_structured] | |
steps: | |
- uses: actions/checkout@v3 | |
- 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 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/cache@v3 | |
with: | |
path: ${{ env.CACHE_PATHS }} | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Lint code with clippy | |
run: cargo clippy | |
wasm-test: | |
needs: validity | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/cache@v3 | |
with: | |
path: ${{ env.CACHE_PATHS }} | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- uses: brndnmtthws/rust-action-cargo-binstall@v1 | |
with: | |
packages: [email protected] | |
- uses: denoland/setup-deno@v1 | |
with: | |
deno-version: v1.x | |
- name: Build | |
run: | | |
rustup target add wasm32-unknown-unknown | |
npm ci | |
npm run build | |
working-directory: src/js-cli-and-library | |
shell: bash | |
- name: Test modules | |
run: | | |
node test.mjs | |
deno run -A test.mjs | |
node test.cjs | |
working-directory: src/js-cli-and-library | |
shell: bash | |
- name: Check CLI works | |
run: | | |
node ./dist/cli.cjs info | |
deno run -A ./dist/cli.mjs info | |
working-directory: src/js-cli-and-library | |
shell: bash | |
publish-ability: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- 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 |