feat(ci): upload coverage report to pages for easier browsing (#1096)

* feat(ci): upload coverage report to pages for easier browsing

* fix: remove anchors

* fix: release report

* fix: coverage percent

* docs: update README

* chore: only on master
This commit is contained in:
LoricAndre 2026-06-24 18:55:33 +02:00 committed by GitHub
parent e85cf6b708
commit b56eed4125
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 114 additions and 24 deletions

View file

@ -93,6 +93,8 @@ jobs:
permissions: permissions:
"code-quality": "write" "code-quality": "write"
"contents": "read" "contents": "read"
"id-token": "write"
"pages": "write"
# Build and packages all the platform-specific things # Build and packages all the platform-specific things
build-local-artifacts: build-local-artifacts:

View file

@ -19,9 +19,6 @@ concurrency:
jobs: jobs:
nextest: nextest:
runs-on: ${{matrix.os}} runs-on: ${{matrix.os}}
permissions:
contents: read
code-quality: write
strategy: strategy:
matrix: matrix:
build: [linux, macos, windows] build: [linux, macos, windows]
@ -35,6 +32,9 @@ jobs:
- build: windows - build: windows
os: windows-latest os: windows-latest
target: x86_64-pc-windows-msvc target: x86_64-pc-windows-msvc
permissions:
contents: read
code-quality: write
steps: steps:
- name: "[linux] Install dependencies" - name: "[linux] Install dependencies"
run: | run: |
@ -50,6 +50,7 @@ jobs:
if: runner.os == 'macOS' if: runner.os == 'macOS'
env: env:
HOMEBREW_NO_AUTO_UPDATE: 1 HOMEBREW_NO_AUTO_UPDATE: 1
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v6 uses: actions/checkout@v6
with: with:
@ -70,11 +71,24 @@ jobs:
env-vars: "____" env-vars: "____"
cache-on-failure: "true" cache-on-failure: "true"
cache-all-crates: "true" cache-all-crates: "true"
- name: Run doctests - name: Run doctests
run: cargo test --doc run: cargo test --doc
- name: Run tests - name: "[linux] Run tests with coverage"
if: runner.os == 'Linux'
# Do not use `--all-targets` to avoid running benches # Do not use `--all-targets` to avoid running benches
run: cargo llvm-cov nextest --release --profile ci --bins --lib --examples --tests --cobertura --output-path coverage.xml --failure-mode all run: |
cargo llvm-cov nextest --release --profile ci --bins --lib --examples --tests --no-report
cargo llvm-cov report --release --cobertura --output-path coverage.xml
cargo llvm-cov report --release --html
echo "COVERAGE_PERCENT=$(cargo llvm-cov report --release | tail -n1 | awk '{ print $4 }')" | tee --append $GITHUB_ENV
env:
LC_ALL: en_US.UTF-8
TERM: xterm-256color
- name: "[macos/windows] Run tests"
if: runner.os != 'Linux'
# Do not use `--all-targets` to avoid running benches
run: cargo nextest run --release --profile ci --bins --lib --examples --tests
env: env:
LC_ALL: en_US.UTF-8 LC_ALL: en_US.UTF-8
TERM: xterm-256color TERM: xterm-256color
@ -93,17 +107,58 @@ jobs:
fi fi
done done
shell: bash shell: bash
- name: Upload coverage report - name: "[linux] Upload coverage report"
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository if: runner.os == 'Linux' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
# fail-on-error: false continue-on-error: true
uses: actions/upload-code-coverage@v1 uses: actions/upload-code-coverage@v1
with: with:
file: coverage.xml file: coverage.xml
language: Rust language: Rust
label: ${{ runner.os }} label: ${{ runner.os }}
- name: "[linux] Generate coverage badge"
if: &if-linux-master runner.os == 'Linux' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
uses: emibcn/badge-action@v2.0.2
with:
label: 'Coverage'
status: ${{ env.COVERAGE_PERCENT }}
color: 'blue'
path: 'target/llvm-cov/html/coverage.svg'
- name: "[linux] Upload default branch results to gh pages"
if: *if-linux-master
uses: actions/upload-pages-artifact@v3
with:
path: target/llvm-cov/html
deploy-coverage-page:
needs: nextest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: "[linux] Deploy gh pages"
id: deployment
if: *if-linux-master
uses: actions/deploy-pages@v4
clippy: clippy:
runs-on: ubuntu-latest runs-on: ${{matrix.os}}
strategy:
matrix:
build: [linux, macos, windows]
include:
- build: linux
os: ubuntu-latest
target: x86_64-unknown-linux-musl
- build: macos
os: macos-latest
target: x86_64-apple-darwin
- build: windows
os: windows-latest
target: x86_64-pc-windows-msvc
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v6 uses: actions/checkout@v6
@ -117,7 +172,20 @@ jobs:
run: cargo clippy run: cargo clippy
rustfmt: rustfmt:
runs-on: ubuntu-latest runs-on: ${{matrix.os}}
strategy:
matrix:
build: [linux, macos, windows]
include:
- build: linux
os: ubuntu-latest
target: x86_64-unknown-linux-musl
- build: macos
os: macos-latest
target: x86_64-apple-darwin
- build: windows
os: windows-latest
target: x86_64-pc-windows-msvc
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v6 uses: actions/checkout@v6
@ -126,6 +194,33 @@ jobs:
run: | run: |
cargo fmt --all -- --check cargo fmt --all -- --check
build-no-default-features:
runs-on: ${{matrix.os}}
strategy:
matrix:
build: [linux, macos, windows]
include:
- build: linux
os: ubuntu-latest
target: x86_64-unknown-linux-musl
- build: macos
os: macos-latest
target: x86_64-apple-darwin
- build: windows
os: windows-latest
target: x86_64-pc-windows-msvc
steps:
- name: Checkout repository
uses: actions/checkout@v6
- run: rustup toolchain install
- name: Cache
uses: Swatinem/rust-cache@v2
with: *cache-with
- name: Build without any feature
run: |
cargo build --no-default-features
msrv: msrv:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@ -139,16 +234,3 @@ jobs:
tool: cargo-msrv@0.19 tool: cargo-msrv@0.19
- name: MSRV Verify - name: MSRV Verify
run: cargo msrv verify run: cargo msrv verify
build-no-default-features:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- run: rustup toolchain install
- name: Cache
uses: Swatinem/rust-cache@v2
with: *cache-with
- name: Build without any feature
run: |
cargo build --no-default-features

3
.gitignore vendored
View file

@ -36,4 +36,5 @@ __pycache__/
.envrc.local .envrc.local
/public /public
.codex .codex
/coverage.xml

View file

@ -5,6 +5,9 @@
<a href="https://github.com/skim-rs/skim/actions?query=workflow%3A%22Build+%26+Test%22+event%3Apush"> <a href="https://github.com/skim-rs/skim/actions?query=workflow%3A%22Build+%26+Test%22+event%3Apush">
<img src="https://github.com/skim-rs/skim/actions/workflows/test.yml/badge.svg?event=push" alt="Build & Test" /> <img src="https://github.com/skim-rs/skim/actions/workflows/test.yml/badge.svg?event=push" alt="Build & Test" />
</a> </a>
<a href="https://skim-rs.github.io/skim" >
<img src="https://skim-rs.github.io/skim/coverage.svg" alt="coverage badge" />
</a>
<a href="https://repology.org/project/skim-fuzzy-finder/versions"> <a href="https://repology.org/project/skim-fuzzy-finder/versions">
<img src="https://repology.org/badge/tiny-repos/skim-fuzzy-finder.svg" alt="Packaging status" /> <img src="https://repology.org/badge/tiny-repos/skim-fuzzy-finder.svg" alt="Packaging status" />
</a> </a>

View file

@ -27,3 +27,5 @@ publish-prereleases = true
[dist.github-custom-job-permissions.test] [dist.github-custom-job-permissions.test]
code-quality = "write" code-quality = "write"
contents = "read" contents = "read"
pages = "write"
id-token = "write"