Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: extend compile pipeline #6

Merged
merged 7 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 67 additions & 64 deletions .github/workflows/rust-compile.yml
Original file line number Diff line number Diff line change
@@ -1,72 +1,75 @@
on:
push:
branches:
push:
branches:
- "main"
pull_request:
pull_request:

name: Rust

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
RUST_LOG: info
RUST_BACKTRACE: 1
RUSTFLAGS: "-D warnings"
CARGO_TERM_COLOR: always
RUST_LOG: info
RUST_BACKTRACE: 1
RUSTFLAGS: "-D warnings"
CARGO_TERM_COLOR: always

jobs:
check-rustdoc-links:
name: Check intra-doc links
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- run: |
for package in $(cargo metadata --no-deps --format-version=1 | jq -r '.packages[] | .name'); do
cargo rustdoc -p "$package" --all-features -- -D warnings -W unreachable-pub
done

format_and_lint:
name: Format and Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: clippy, rustfmt
- name: Run rustfmt
uses: actions-rust-lang/rustfmt@v1
- name: Run clippy
run: cargo clippy --all-targets

test:
name: Test
runs-on: ubuntu-latest
needs: [ format_and_lint ]
steps:
- name: Checkout source code
uses: actions/checkout@v4
check-rustdoc-links:
name: Check intra-doc links
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- shell: bash
run: >
./intra-doc-links.bash
format_and_lint:
name: Format and Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: clippy, rustfmt
- name: Run rustfmt
uses: actions-rust-lang/rustfmt@v1
- name: Run clippy
run: cargo clippy --all-targets

test:
name: Test
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
needs: [format_and_lint]
steps:
- name: Checkout source code
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: rustfmt
cache: false

- uses: Swatinem/rust-cache@v2

- name: Install cargo nextest
uses: taiki-e/install-action@v2
with:
tool: cargo-nextest

- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: rustfmt
cache: false
- name: Run tests
run: >
cargo nextest run --workspace

- name: Install cargo nextest
uses: taiki-e/install-action@v2
with:
tool: cargo-nextest

- name: Run tests
run: >
cargo nextest run --workspace

- name: Run doctests
run: >
cargo test --doc

- name: Run doctests
run: >
cargo test --doc
22 changes: 22 additions & 0 deletions intra-doc-links.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
cargo metadata --no-deps --format-version=1 \
| jq -r '.packages[] | .name as $pname | .targets[] | [$pname, .kind[], .name] | @tsv' \
| while IFS=$'\t' read -r package kind name; do
case "$kind" in
lib)
cargo rustdoc -p "$package" --lib --all-features -- -D warnings -W unreachable-pub
;;
bin)
cargo rustdoc -p "$package" --bin "$name" --all-features -- -D warnings -W unreachable-pub
;;
example)
cargo rustdoc -p "$package" --example "$name" --all-features -- -D warnings -W unreachable-pub
;;
test)
cargo rustdoc -p "$package" --test "$name" --all-features -- -D warnings -W unreachable-pub
;;
bench)
cargo rustdoc -p "$package" --bench "$name" --all-features -- -D warnings -W unreachable-pub
;;
esac
done