Publish measured toolkit badges from main CI
This commit is contained in:
@@ -76,8 +76,10 @@ jobs:
|
|||||||
|
|
||||||
- name: Unit tests
|
- name: Unit tests
|
||||||
run: |
|
run: |
|
||||||
cargo test -p alkane-gui --offline
|
set -o pipefail
|
||||||
cargo test -p alkane-artifacts -p alkane-flash -p alkane-cli --offline
|
cargo test -p alkane-gui --offline 2>&1 | tee tests-gui.txt
|
||||||
|
cargo test -p alkane-artifacts -p alkane-flash -p alkane-cli --offline 2>&1 | tee tests-core.txt
|
||||||
|
cat tests-gui.txt tests-core.txt > tests-current.txt
|
||||||
|
|
||||||
- name: Load previous main benchmark measurement
|
- name: Load previous main benchmark measurement
|
||||||
env:
|
env:
|
||||||
@@ -119,42 +121,32 @@ jobs:
|
|||||||
echo "cargo-audit not installed on this runner; skipping"
|
echo "cargo-audit not installed on this runner; skipping"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Merge coverage from the unit tests AND the headless self-test (ci/coverage.sh)
|
# Merge coverage from unit tests and the headless UI self-test. A failed
|
||||||
# so the committed badge reflects real coverage, not the tests-only number a
|
# measurement must not publish a stale badge or create a release.
|
||||||
# plain `cargo llvm-cov` reports. Best-effort: cargo-llvm-cov is fetched as a
|
- name: Coverage
|
||||||
# prebuilt binary because the vendored .cargo/config blocks `cargo install`,
|
|
||||||
# and the instrumented rebuild is slow, so a failure here never blocks a
|
|
||||||
# release. Feeds steps.cov.outputs.pct to the badge refresh below. xvfb is
|
|
||||||
# already installed by the self-test step above.
|
|
||||||
- name: Coverage (best-effort)
|
|
||||||
id: cov
|
id: cov
|
||||||
continue-on-error: true
|
|
||||||
run: |
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
rustup component add llvm-tools-preview >/dev/null 2>&1 || true
|
rustup component add llvm-tools-preview >/dev/null 2>&1 || true
|
||||||
if ! command -v cargo-llvm-cov >/dev/null 2>&1; then
|
if ! command -v cargo-llvm-cov >/dev/null 2>&1; then
|
||||||
V=0.8.7
|
V=0.8.7
|
||||||
URL="https://github.com/taiki-e/cargo-llvm-cov/releases/download/v${V}/cargo-llvm-cov-x86_64-unknown-linux-gnu.tar.gz"
|
URL="https://github.com/taiki-e/cargo-llvm-cov/releases/download/v${V}/cargo-llvm-cov-x86_64-unknown-linux-gnu.tar.gz"
|
||||||
DEST="${CARGO_HOME:-$HOME/.cargo}/bin"
|
DEST="${CARGO_HOME:-$HOME/.cargo}/bin"
|
||||||
mkdir -p "$DEST"
|
mkdir -p "$DEST"
|
||||||
curl -fsSL "$URL" | tar -xz -C "$DEST" && export PATH="$DEST:$PATH" \
|
curl -fsSL "$URL" | tar -xz -C "$DEST"
|
||||||
|| echo "cargo-llvm-cov download failed"
|
export PATH="$DEST:$PATH"
|
||||||
fi
|
|
||||||
if command -v cargo-llvm-cov >/dev/null 2>&1; then
|
|
||||||
PCT=$(bash ci/coverage.sh --summary-only 2>/dev/null \
|
|
||||||
| awk '/^TOTAL/{gsub(/%/,"",$10); print $10}')
|
|
||||||
if [ -n "$PCT" ]; then
|
|
||||||
echo "pct=${PCT}" >> "$GITHUB_OUTPUT"
|
|
||||||
echo "line coverage (tests + self-test): ${PCT}%"
|
|
||||||
else
|
|
||||||
echo "coverage report produced no TOTAL line; badge left as committed"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "cargo-llvm-cov unavailable; coverage badge left as committed"
|
|
||||||
fi
|
fi
|
||||||
|
command -v cargo-llvm-cov >/dev/null
|
||||||
|
PCT=$(bash ci/coverage.sh --summary-only \
|
||||||
|
| awk '/^TOTAL/{gsub(/%/,"",$10); print $10}')
|
||||||
|
[ -n "$PCT" ] || { echo "coverage report produced no TOTAL line" >&2; exit 1; }
|
||||||
|
echo "pct=${PCT}" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "line coverage (tests + self-test): ${PCT}%"
|
||||||
|
|
||||||
- name: Microbenchmark coverage
|
- name: Microbenchmark coverage
|
||||||
id: benchcov
|
id: benchcov
|
||||||
run: |
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
command -v cargo-llvm-cov >/dev/null
|
command -v cargo-llvm-cov >/dev/null
|
||||||
PCT=$(bash ci/bench-coverage.sh --summary-only \
|
PCT=$(bash ci/bench-coverage.sh --summary-only \
|
||||||
| awk '/^TOTAL/{gsub(/%/,"",$10); print $10}')
|
| awk '/^TOTAL/{gsub(/%/,"",$10); print $10}')
|
||||||
@@ -162,38 +154,24 @@ jobs:
|
|||||||
echo "pct=${PCT}" >> "$GITHUB_OUTPUT"
|
echo "pct=${PCT}" >> "$GITHUB_OUTPUT"
|
||||||
echo "microbenchmark line coverage: ${PCT}%"
|
echo "microbenchmark line coverage: ${PCT}%"
|
||||||
|
|
||||||
# Refresh the committed README badges from live metrics and push any change
|
- name: Generate measured badges
|
||||||
# back to main. Best-effort: a locked-down runner that can't push must not
|
|
||||||
# fail the release. The badge-only commit skips CI to prevent a loop.
|
|
||||||
- name: Refresh badges
|
|
||||||
if: steps.ver.outputs.release == 'true'
|
|
||||||
continue-on-error: true
|
|
||||||
run: |
|
run: |
|
||||||
PASS=$(cargo test -p alkane-gui --offline 2>&1 \
|
set -euo pipefail
|
||||||
| grep -hoE '[0-9]+ passed' | grep -oE '[0-9]+' | awk '{s+=$1} END{print s+0}')
|
PASS=$(grep -E '^test result: ' tests-current.txt \
|
||||||
# Update the coverage badge only when the coverage step produced a number;
|
| grep -oE '[0-9]+ passed' | grep -oE '[0-9]+' \
|
||||||
# otherwise leave the committed coverage.svg untouched.
|
| awk '{s+=$1} END{print s+0}')
|
||||||
COV="${{ steps.cov.outputs.pct }}"
|
[ "$PASS" -gt 0 ] || { echo "no passing tests counted" >&2; exit 1; }
|
||||||
BENCH_COV="${{ steps.benchcov.outputs.pct }}"
|
|
||||||
COV_ARG=""
|
|
||||||
[ -n "$COV" ] && COV_ARG="--coverage $COV"
|
|
||||||
# Weighted-average microbench delta vs the previous release (round 19 #1).
|
|
||||||
# bench-badge.py also rewrites badges/bench-baseline.json, which is
|
|
||||||
# committed below with the SVGs (badges/* does not trip a release bump).
|
|
||||||
BENCH_DELTA=$(python3 ci/bench-badge.py --current bench-current.txt \
|
BENCH_DELTA=$(python3 ci/bench-badge.py --current bench-current.txt \
|
||||||
--baseline badges/bench-baseline.json 2>/dev/null || echo NEW)
|
--baseline badges/bench-baseline.json --no-write)
|
||||||
python3 ci/gen-badges.py --tests "${PASS:-0}" $COV_ARG \
|
python3 ci/gen-badges.py --tests "$PASS" \
|
||||||
--bench-coverage "$BENCH_COV" \
|
--coverage "${{ steps.cov.outputs.pct }}" \
|
||||||
--bench-delta "${BENCH_DELTA:-NEW}" --bench "row-render + scan-parse"
|
--bench-coverage "${{ steps.benchcov.outputs.pct }}" \
|
||||||
if [ -n "$(git status --porcelain badges)" ]; then
|
--bench-delta "$BENCH_DELTA"
|
||||||
git config user.name "alkane-ci"
|
|
||||||
git config user.email "ci@bluefla.re"
|
- name: Publish measured badges
|
||||||
git add badges
|
env:
|
||||||
git commit -m "ci: refresh README badges [skip ci]"
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
git push origin "HEAD:main" || echo "badge push skipped"
|
run: python3 ci/publish-metrics.py
|
||||||
else
|
|
||||||
echo "badges unchanged"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Package artifact
|
- name: Package artifact
|
||||||
if: steps.ver.outputs.release == 'true'
|
if: steps.ver.outputs.release == 'true'
|
||||||
|
|||||||
@@ -1,22 +1,22 @@
|
|||||||
# alkane-toolkit
|
# alkane-toolkit
|
||||||
|
|
||||||
[](https://gitea.bluefla.re/blueflare/alkane-toolkit/actions)
|
[](https://gitea.bluefla.re/blueflare/alkane-toolkit/actions)
|
||||||

|

|
||||||

|

|
||||||

|

|
||||||

|

|
||||||

|

|
||||||

|

|
||||||

|

|
||||||

|

|
||||||
|
|
||||||
The CI badge shows the last completed attempt for this branch while newer
|
The CI badge shows the last completed attempt for this branch while newer
|
||||||
runs are queued. Its SVG is stored in a private, machine-maintained branch.
|
runs are queued. Badge SVGs are stored in a private, machine-maintained branch.
|
||||||
|
|
||||||
A cross-platform desktop toolkit for discovering, monitoring, and re-flashing
|
A cross-platform desktop toolkit for discovering, monitoring, and re-flashing
|
||||||
ASIC miners. It scans a fleet over the network, shows live health and hashrate
|
ASIC miners. It scans a fleet over the network, shows live health and hashrate
|
||||||
in a sortable table, and installs **stock** or **alkaneOS** firmware onto a
|
in a sortable table. The install path is under development for **stock** and
|
||||||
control board whatever it currently runs (stock, VNish/AnthillOS, Braiins OS+,
|
**alkaneOS** firmware on boards running stock, VNish/AnthillOS, Braiins OS+,
|
||||||
LuxOS, ePIC, HiveOn, BixBit, WardenOS).
|
LuxOS, ePIC, HiveOn, BixBit, WardenOS).
|
||||||
|
|
||||||
The core and UI are pure Rust; the native window is wxWidgets driven through a
|
The core and UI are pure Rust; the native window is wxWidgets driven through a
|
||||||
|
|||||||
+3
-1
@@ -21,8 +21,10 @@ need_xvfb() { command -v xvfb-run >/dev/null 2>&1; }
|
|||||||
|
|
||||||
cargo llvm-cov clean --workspace
|
cargo llvm-cov clean --workspace
|
||||||
|
|
||||||
# 1. Unit tests.
|
# 1. Unit tests for the GUI and the artifact/flash/CLI crates.
|
||||||
cargo llvm-cov --no-report "${CARGO_FLAGS[@]}" -p alkane-gui --bin alkane-toolkit
|
cargo llvm-cov --no-report "${CARGO_FLAGS[@]}" -p alkane-gui --bin alkane-toolkit
|
||||||
|
cargo llvm-cov --no-report "${CARGO_FLAGS[@]}" \
|
||||||
|
-p alkane-artifacts -p alkane-flash -p alkane-cli
|
||||||
|
|
||||||
# 2. Headless UI self-test, under the same instrumentation, its coverage appended.
|
# 2. Headless UI self-test, under the same instrumentation, its coverage appended.
|
||||||
if need_xvfb; then
|
if need_xvfb; then
|
||||||
|
|||||||
+2
-4
@@ -1,10 +1,8 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
"""Generate self-contained shields-style SVG badges into badges/.
|
"""Generate self-contained shields-style SVG badges into badges/.
|
||||||
|
|
||||||
Self-hosted Gitea renders a README's relative image links straight from the
|
Main CI regenerates SVGs from measured metrics and publishes them to the
|
||||||
repo, so committing the SVGs (rather than depending on an external badge
|
private ci-badges branch. The README loads those authenticated raw artifacts.
|
||||||
service that would have to reach a possibly-private Gitea) is the robust choice.
|
|
||||||
CI regenerates them from live metrics and commits any changes back.
|
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
gen-badges.py --tests N --coverage PCT --bench "label" [--out badges]
|
gen-badges.py --tests N --coverage PCT --bench "label" [--out badges]
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
"""Publish measured toolkit badges to the private Gitea badge branch."""
|
||||||
|
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from badge_store import publish_file
|
||||||
|
|
||||||
|
ROOT = Path(__file__).resolve().parents[1]
|
||||||
|
NAMES = ("tests", "coverage", "bench", "bench-coverage", "loc",
|
||||||
|
"dependencies", "quality", "license")
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
api = os.environ["GITHUB_API_URL"].rstrip("/")
|
||||||
|
repo = os.environ["GITHUB_REPOSITORY"]
|
||||||
|
token = os.environ["GITEA_TOKEN"]
|
||||||
|
for name in NAMES:
|
||||||
|
data = (ROOT / "badges" / f"{name}.svg").read_bytes()
|
||||||
|
if not data.lstrip().startswith(b"<svg"):
|
||||||
|
raise ValueError(f"invalid {name} SVG")
|
||||||
|
publish_file(api, repo, f"badges/{name}.svg", data, token,
|
||||||
|
f"Update measured {name} badge")
|
||||||
|
print(f"Published {len(NAMES)} measured badge SVGs")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Reference in New Issue
Block a user