1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
---
name: Cargo Build & Test
on: # yamllint disable-line rule:truthy
push:
pull_request:
env:
CARGO_TERM_COLOR: always
# Make sure CI fails on all warnings, including Clippy lints
RUSTFLAGS: "-Dwarnings"
jobs:
build_and_test:
name: Rust project - latest
runs-on: ubuntu-latest
strategy:
matrix:
toolchain:
- stable
- beta
- nightly
steps:
- name: Install dependencies
run: >
sudo apt-get update
&& sudo apt-get install --no-install-recommends --yes
bzip2 lz4 lzop pigz xz-utils zstd
- uses: actions/checkout@v4
- run: >
rustup update ${{ matrix.toolchain }}
&& rustup default ${{ matrix.toolchain }}
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- run: cargo build --verbose
- run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info
- name: Upload coverage
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.toolchain }}
path: ./lcov.info
build_and_test_minimal:
name: Build and test with minimal deps
runs-on: ubuntu-latest
steps:
- name: Install dependencies
run: >
sudo apt-get update
&& sudo apt-get install --no-install-recommends --yes
bzip2 lz4 xz-utils zstd
- uses: actions/checkout@v4
- run: >
rustup update stable
&& rustup default stable
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- run: cargo build --verbose
- run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info
- name: Upload coverage
uses: actions/upload-artifact@v4
with:
name: coverage-minimal
path: ./lcov.info
build_and_test_root:
name: Build and test as root
runs-on: ubuntu-latest
steps:
- name: Install dependencies
run: >
sudo apt-get update
&& sudo apt-get install --no-install-recommends --yes
bzip2 lz4 lzop pigz xz-utils zstd
- uses: actions/checkout@v4
- run: >
rustup update stable
&& rustup default stable
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- run: cargo build --verbose
- run: >
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER='sudo -E'
cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info
- name: Upload coverage
uses: actions/upload-artifact@v4
with:
name: coverage-root
path: ./lcov.info
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run Clippy
run: cargo clippy --all-targets --all-features
rustfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run rustfmt
run: cargo fmt --all --check
upload-to-codecov:
if: ${{ always() }}
needs:
- build_and_test
- build_and_test_minimal
- build_and_test_root
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
man:
runs-on: ubuntu-latest
steps:
- name: Install asciidoctor
run: >
sudo apt-get update
&& sudo apt-get install --no-install-recommends --yes
asciidoctor
- uses: actions/checkout@v4
- name: Build man pages
run: asciidoctor -b manpage man/3cpio.1.adoc
|