oxc/.github/workflows/ci.yml
Boshen d49195f7f2
feat: napi (#302)
* chore: only ignore js files from the root

* feat: napi
2023-04-22 14:41:45 +08:00

147 lines
3.5 KiB
YAML

name: CI
on:
workflow_dispatch:
pull_request:
paths:
- 'crates/**'
- 'tasks/**'
- 'Cargo.toml'
- 'Cargo.lock'
- 'rust-toolchain.toml'
- '!**/*.md'
push:
branches:
- main
paths-ignore:
- '**/*.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
jobs:
cache: # Warm cache factory for all other CI jobs
name: Build Cache
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
- os: ubuntu-latest
- os: macos-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install cargo-nextest
uses: taiki-e/install-action@cargo-nextest
- name: Install Rust Toolchain
uses: ./.github/actions/rustup
with:
save-cache: ${{ github.ref_name == 'main' }}
# NAPI crashes nextest on windows
# https://github.com/napi-rs/napi-rs/issues/1405
- name: Build cache by Cargo Check and Cargo Test
if: runner.os == 'Windows'
run: |
cargo check --workspace --all-targets --all-features --locked
cargo test run --workspace --all-targets --all-features --no-run
- name: Build cache by Cargo Check and Cargo Test
if: runner.os != 'Windows'
run: |
cargo check --workspace --all-targets --all-features --locked
cargo nextest run --workspace --all-targets --all-features --no-run
format:
name: Format Rust Files
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Rust Toolchain
uses: ./.github/actions/rustup
with:
fmt: true
restore-cache: false
- 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 Rust Toolchain
uses: ./.github/actions/rustup
with:
clippy: true
- name: Run Clippy
run: cargo lint -- -D warnings
typos:
name: Spell Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: crate-ci/typos@master
with:
files: .
check-dependencies:
name: Check Dependencies
runs-on: ubuntu-latest
steps:
- name: Checkout PR Branch
uses: actions/checkout@v3
- name: Install Rust Toolchain
uses: ./.github/actions/rustup
- name: Install cargo-udeps
uses: taiki-e/install-action@v2
with:
tool: cargo-udeps
- name: Run udeps
run: cargo udeps
test:
name: Test
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
- os: ubuntu-latest
- os: macos-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Rust Toolchain
uses: ./.github/actions/rustup
- name: Install cargo-nextest
uses: taiki-e/install-action@cargo-nextest
# NAPI crashes nextest on windows
# https://github.com/napi-rs/napi-rs/issues/1405
- name: Run tests
if: runner.os == 'Windows'
run: cargo test
- name: Run tests
if: runner.os != 'Windows'
run: cargo nextest run