mirror of
https://github.com/danbulant/oxc
synced 2026-05-21 21:29:01 +00:00
132 lines
2.9 KiB
YAML
132 lines
2.9 KiB
YAML
name: Check and Test
|
|
|
|
on:
|
|
pull_request: {}
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- 'crates/**'
|
|
- 'tasks/**'
|
|
- 'Cargo.toml'
|
|
- 'Cargo.lock'
|
|
- 'rust-toolchain.toml'
|
|
- '!**/*.md'
|
|
|
|
# cancel previous job runs for the same workflow + pr
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
CARGO_TERM_QUIET: true
|
|
RUSTFLAGS: -D warnings # https://rust-unofficial.github.io/patterns/anti_patterns/deny-warnings.html#alternatives
|
|
|
|
jobs:
|
|
format:
|
|
name: Format Rust Files
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Install toolchain
|
|
run: rustup show
|
|
|
|
- name: Run rustfmt
|
|
run: cargo fmt --all -- --check
|
|
|
|
lint:
|
|
name: Lint Rust Files
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Install toolchain
|
|
run: rustup show
|
|
|
|
- name: Cache
|
|
uses: Swatinem/rust-cache@v2
|
|
with:
|
|
shared-key: check
|
|
|
|
- name: Run cargo check
|
|
run: cargo check --workspace --all-targets --all-features --release --locked
|
|
|
|
- name: Run clippy
|
|
run: cargo lint
|
|
|
|
check-dependencies:
|
|
name: Check Dependencies
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout PR Branch
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Cache
|
|
uses: Swatinem/rust-cache@v2
|
|
with:
|
|
shared-key: "dependencies"
|
|
|
|
- name: Install toolchain
|
|
run: rustup show
|
|
|
|
- name: Install udeps
|
|
run: cargo install cargo-udeps --locked
|
|
|
|
- name: Run udeps
|
|
run: cargo udeps
|
|
|
|
test:
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- os: windows-2022
|
|
- os: ubuntu-20.04
|
|
- os: macos-11
|
|
|
|
name: Test
|
|
runs-on: ${{ matrix.os }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Install toolchain
|
|
run: rustup show
|
|
|
|
- name: Cache
|
|
uses: Swatinem/rust-cache@v2
|
|
with:
|
|
shared-key: test
|
|
|
|
- name: Run tests on ${{ matrix.os }}
|
|
run: cargo test --workspace
|
|
|
|
documentation:
|
|
if: github.ref == 'refs/heads/main'
|
|
name: Deploy Rust Doc
|
|
runs-on: ubuntu-latest
|
|
needs: test
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Install toolchain
|
|
run: rustup show
|
|
|
|
- name: Cache
|
|
uses: Swatinem/rust-cache@v2
|
|
|
|
- name: Build Doc
|
|
run: |
|
|
# https://dev.to/deciduously/prepare-your-rust-api-docs-for-github-pages-2n5i
|
|
cargo doc --all --no-deps
|
|
echo "<meta http-equiv=\"refresh\" content=\"0; url=oxc_parser\">" > target/doc/index.html
|
|
|
|
- name: Deploy Rust Doc
|
|
uses: peaceiris/actions-gh-pages@v3
|
|
with:
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
publish_dir: ./target/doc
|
|
publish_branch: docs
|