ci: only run on main
(and prs)
#27
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: ci (rust + web) | |
on: | |
push: | |
branches: | |
- "main" | |
pull_request: | |
types: ["opened", "reopened"] | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
build_and_test: | |
name: build + test (rust, linux) | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
toolchain: | |
- stable | |
- nightly | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: ${{ matrix.toolchain }} | |
- name: Cache cargo registry | |
id: cargo-reg-cache | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cargo/registry | |
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
- name: Cache cargo index | |
id: cargo-index-cache | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cargo/git | |
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} | |
- name: Cache cargo build | |
id: cargo-build-cache | |
uses: actions/cache@v4 | |
with: | |
path: target | |
key: ${{ runner.os }}-cargo-build-target-${{ matrix.toolchain }}-${{ hashFiles('**/Cargo.lock') }} | |
- name: Cache cargo bin | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cargo/bin | |
key: ${{ runner.os }}-cargo-bin-${{ hashFiles('**/Cargo.lock') }} | |
- name: Build | |
run: cargo build | |
# save all the caches real quick | |
- name: Save cargo registry cache before testing | |
id: cargo-reg-save | |
uses: actions/cache/restore@v4 | |
with: | |
path: ~/.cargo/registry | |
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
- name: Save cargo index cache before testing | |
id: cargo-index-save | |
uses: actions/cache/restore@v4 | |
with: | |
path: ~/.cargo/git | |
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} | |
- name: Save cargo build cache before testing | |
id: cargo-build-save | |
uses: actions/cache/restore@v4 | |
with: | |
path: target | |
key: ${{ runner.os }}-cargo-build-target-${{ matrix.toolchain }}-${{ hashFiles('**/Cargo.lock') }} | |
# ok all good, continue with the tests | |
- name: Install `cargo-nextest` | |
uses: taiki-e/install-action@nextest | |
- name: Run tests | |
run: RUST_BACKTRACE=1 cargo nextest run --no-fail-fast --verbose | |
- name: Run doctests | |
run: cargo test --doc | |
windows_build: | |
name: build (rust, windows) | |
runs-on: windows-latest | |
strategy: | |
matrix: | |
toolchain: | |
- stable | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: ${{ matrix.toolchain }} | |
- name: Build | |
run: cargo build | |
web: | |
name: lint web stuff | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Biome | |
uses: biomejs/setup-biome@v2 | |
with: | |
version: latest | |
- name: Run Biome | |
run: biome ci frontend/src | |
test_semver: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Ensure we have `cmake` | |
run: sudo apt update && sudo apt install -y cmake | |
- name: Check semver | |
uses: obi1kenobi/cargo-semver-checks-action@v2 | |
with: | |
package: libghr |