mirror of
https://github.com/Magnus167/rustframe.git
synced 2025-08-20 04:30:01 +00:00
88 lines
2.4 KiB
YAML
88 lines
2.4 KiB
YAML
name: docs-and-testcov
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
# pull_request:
|
|
# branches: [main]
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
id-token: write
|
|
pages: write
|
|
|
|
jobs:
|
|
docs-and-testcov:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Rust
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
override: true
|
|
|
|
- name: Build documentation
|
|
run: cargo doc --no-deps
|
|
|
|
- name: Prepare documentation for Pages
|
|
run: |
|
|
|
|
- name: Install Cargo binstall
|
|
uses: cargo-bins/cargo-binstall@main
|
|
|
|
- name: Install cargo-tarpaulin via binstall
|
|
run: cargo binstall cargo-tarpaulin --no-confirm --locked
|
|
|
|
- name: Generate coverage report
|
|
run: |
|
|
mkdir -p testcov
|
|
cargo tarpaulin --engine llvm --out Html --out Json
|
|
|
|
- name: Check for tarpaulin-report.html
|
|
run: |
|
|
if [ ! -f tarpaulin-report.html ]; then
|
|
echo "tarpaulin-report.html not found!"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Export tarpaulin coverage badge JSON
|
|
run: |
|
|
# extract raw coverage
|
|
coverage=$(jq '.coverage' tarpaulin-report.json)
|
|
# round to 2 decimal places
|
|
formatted=$(printf "%.2f" "$coverage")
|
|
# build the badge JSON using the pre-formatted string
|
|
jq --arg message "$formatted" \
|
|
'{schemaVersion:1,
|
|
label:"tarpaulin-report",
|
|
message:$message,
|
|
color:"blue"}' \
|
|
tarpaulin-report.json \
|
|
> tarpaulin-badge.json
|
|
|
|
- name: Copy files to output directory
|
|
run: |
|
|
mkdir output
|
|
cp tarpaulin-report.html target/doc/rustframe/
|
|
cp tarpaulin-report.json target/doc/rustframe/
|
|
cp tarpaulin-badge.json target/doc/rustframe/
|
|
echo "<meta http-equiv=\"refresh\" content=\"0; url=rustframe\">" > target/doc/index.html
|
|
|
|
- name: Upload Pages artifact
|
|
if: github.event_name == 'push'
|
|
uses: actions/upload-pages-artifact@v3
|
|
with:
|
|
path: target/doc/
|
|
|
|
- name: Deploy to GitHub Pages
|
|
if: github.event_name == 'push'
|
|
uses: actions/deploy-pages@v4
|