name: CI
on: [push, pull_request]
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
RUSTFLAGS: -Dwarnings
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
CI: true
jobs:
check_project_files:
if: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Restore lychee cache
uses: actions/cache@v5
with:
path: .lycheecache
key: cache-lychee-${{ github.sha }}
restore-keys: cache-lychee-
- uses: lycheeverse/lychee-action@8646ba30535128ac92d33dfc9133794bfdd9b411 with:
args: "--cache --max-cache-age 1d . -v *.md"
failIfEmpty: false
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- uses: Swatinem/rust-cache@v2
with:
shared-key: "${{ github.workflow }}"
- uses: mozilla-actions/sccache-action@v0.0.9
- name: Query Cargo.toml
id: query-cargo-toml
run: echo "rust_version=$(yq '.package.rust-version' Cargo.toml)" >> "$GITHUB_OUTPUT"
- run: rustup default "${STEPS_QUERY_CARGO_TOML_OUTPUTS_RUST_VERSION}"
env:
STEPS_QUERY_CARGO_TOML_OUTPUTS_RUST_VERSION: ${{ steps.query-cargo-toml.outputs.rust_version }}
- run: rustup component add rustfmt clippy llvm-tools-preview
- run: cargo verify-project
- run: cargo fmt --check --all
- run: cargo clippy --all-targets -- -D warnings
- run: cargo check --all-targets --future-incompat-report
- run: cargo doc --no-deps --document-private-items
- name: Build
env:
RUSTFLAGS: -Cinstrument-coverage
run: cargo build --verbose
- name: Install grcov
uses: taiki-e/install-action@v2
with:
tool: grcov
- name: Test
env:
LLVM_PROFILE_FILE: toml-rgb2ansi256-%p-%m.profraw
RUSTFLAGS: -Cinstrument-coverage
run: cargo test --verbose
- name: Generate coverage
run: |
mkdir -p ./target/debug/coverage/
grcov $(find . -name "toml-rgb2ansi256-*.profraw" -print) \
--branch \
--ignore-not-existing \
--binary-path ./target/debug/ \
-s . \
-t lcov \
--ignore "/*" \
-o ./target/debug/coverage/
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: ./target/debug/coverage/lcov