Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f89f220f3e | ||
|
|
c18a37eebc | ||
|
|
d3a06d682f | ||
|
|
4d530721dc | ||
|
|
0b691ca943 | ||
|
|
ed0f781851 |
@@ -0,0 +1,19 @@
|
|||||||
|
name: completed-ci-badge
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_run:
|
||||||
|
workflows: [build-test-release, next-build]
|
||||||
|
types: [completed]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish:
|
||||||
|
runs-on: alkane-ci
|
||||||
|
permissions:
|
||||||
|
actions: read
|
||||||
|
contents: write
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Publish last completed attempt
|
||||||
|
env:
|
||||||
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
|
run: python3 ci/last-attempt-badge.py
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
name: next-build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [next]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
candidate:
|
||||||
|
runs-on: alkane-ci
|
||||||
|
env:
|
||||||
|
WX_PREFIX: /root/.cache/wx-3.3.3-linux
|
||||||
|
WX_RS_WXCONFIG: /root/.cache/wx-3.3.3-linux/bin/wx-config
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- name: Install build dependencies
|
||||||
|
run: |
|
||||||
|
apt-get update -qq
|
||||||
|
apt-get install -y -qq --no-install-recommends libssl-dev pkg-config ca-certificates
|
||||||
|
- uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: /root/.cache/wx-3.3.3-linux
|
||||||
|
key: wx-3.3.3-${{ runner.os }}-${{ hashFiles('thirdparty/wx-rs/VERSION') }}
|
||||||
|
- name: Build wxWidgets
|
||||||
|
run: |
|
||||||
|
if [ ! -x "$WX_PREFIX/bin/wx-config" ]; then
|
||||||
|
bash scripts/build-wx-linux.sh
|
||||||
|
fi
|
||||||
|
- name: Build release candidate
|
||||||
|
run: cargo build --release -p alkane-gui --offline
|
||||||
|
- name: Select candidate version
|
||||||
|
id: version
|
||||||
|
run: bash ci/compute-rc-version.sh >> "$GITHUB_OUTPUT"
|
||||||
|
- name: Package candidate
|
||||||
|
if: steps.version.outputs.release == 'true'
|
||||||
|
run: |
|
||||||
|
mkdir -p dist
|
||||||
|
cp target/release/alkane-toolkit dist/
|
||||||
|
tar -C dist -czf "dist/alkane-toolkit-${{ steps.version.outputs.version }}-linux-x86_64.tar.gz" alkane-toolkit
|
||||||
|
- name: Create private prerelease
|
||||||
|
if: steps.version.outputs.release == 'true'
|
||||||
|
env:
|
||||||
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
|
run: python3 ci/release-rc.py "${{ steps.version.outputs.tag }}" true "dist/alkane-toolkit-${{ steps.version.outputs.version }}-linux-x86_64.tar.gz"
|
||||||
@@ -6,6 +6,10 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
actions: read
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
runs-on: alkane-ci
|
runs-on: alkane-ci
|
||||||
@@ -25,11 +29,12 @@ jobs:
|
|||||||
run: bash ci/compute-version.sh | tee -a "$GITHUB_OUTPUT"
|
run: bash ci/compute-version.sh | tee -a "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Test version logic
|
- name: Test version logic
|
||||||
if: steps.ver.outputs.release == 'true'
|
|
||||||
run: bash ci/test-compute-version.sh
|
run: bash ci/test-compute-version.sh
|
||||||
|
|
||||||
|
- name: Last-attempt badge checks
|
||||||
|
run: python3 ci/test-last-attempt-badge.py
|
||||||
|
|
||||||
- name: Install build dependencies
|
- name: Install build dependencies
|
||||||
if: steps.ver.outputs.release == 'true'
|
|
||||||
run: |
|
run: |
|
||||||
apt-get update -qq
|
apt-get update -qq
|
||||||
apt-get install -y -qq --no-install-recommends \
|
apt-get install -y -qq --no-install-recommends \
|
||||||
@@ -37,14 +42,12 @@ jobs:
|
|||||||
echo "libssl-dev + pkg-config installed (openssl-sys needs them)"
|
echo "libssl-dev + pkg-config installed (openssl-sys needs them)"
|
||||||
|
|
||||||
- name: Cache vendored wxWidgets build
|
- name: Cache vendored wxWidgets build
|
||||||
if: steps.ver.outputs.release == 'true'
|
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: /root/.cache/wx-3.3.3-linux
|
path: /root/.cache/wx-3.3.3-linux
|
||||||
key: wx-3.3.3-${{ runner.os }}-${{ hashFiles('thirdparty/wx-rs/VERSION') }}
|
key: wx-3.3.3-${{ runner.os }}-${{ hashFiles('thirdparty/wx-rs/VERSION') }}
|
||||||
|
|
||||||
- name: Build wxWidgets (once, then cached)
|
- name: Build wxWidgets (once, then cached)
|
||||||
if: steps.ver.outputs.release == 'true'
|
|
||||||
run: |
|
run: |
|
||||||
if [ ! -x "$WX_PREFIX/bin/wx-config" ]; then
|
if [ ! -x "$WX_PREFIX/bin/wx-config" ]; then
|
||||||
bash scripts/build-wx-linux.sh
|
bash scripts/build-wx-linux.sh
|
||||||
@@ -53,7 +56,6 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Clippy (our crate, warnings are errors)
|
- name: Clippy (our crate, warnings are errors)
|
||||||
if: steps.ver.outputs.release == 'true'
|
|
||||||
run: |
|
run: |
|
||||||
rustup component add clippy >/dev/null 2>&1 || true
|
rustup component add clippy >/dev/null 2>&1 || true
|
||||||
cargo clippy -p alkane-gui --no-deps --release --bins --offline -- -D warnings
|
cargo clippy -p alkane-gui --no-deps --release --bins --offline -- -D warnings
|
||||||
@@ -65,17 +67,14 @@ jobs:
|
|||||||
grep -m1 '^version' Cargo.toml
|
grep -m1 '^version' Cargo.toml
|
||||||
|
|
||||||
- name: Build release
|
- name: Build release
|
||||||
if: steps.ver.outputs.release == 'true'
|
|
||||||
run: |
|
run: |
|
||||||
cargo build --release -p alkane-gui --offline
|
cargo build --release -p alkane-gui --offline
|
||||||
|
|
||||||
- name: Unit tests
|
- name: Unit tests
|
||||||
if: steps.ver.outputs.release == 'true'
|
|
||||||
run: |
|
run: |
|
||||||
cargo test -p alkane-gui --offline
|
cargo test -p alkane-gui --offline
|
||||||
|
|
||||||
- name: Microbenchmarks
|
- name: Microbenchmarks
|
||||||
if: steps.ver.outputs.release == 'true'
|
|
||||||
run: |
|
run: |
|
||||||
# Capture the bench stdout for the weighted-average delta badge (round 19
|
# Capture the bench stdout for the weighted-average delta badge (round 19
|
||||||
# #1) while keeping the step a hard gate: pipefail preserves cargo's exit
|
# #1) while keeping the step a hard gate: pipefail preserves cargo's exit
|
||||||
@@ -85,7 +84,6 @@ jobs:
|
|||||||
| tee bench-current.txt
|
| tee bench-current.txt
|
||||||
|
|
||||||
- name: Headless UI self-test
|
- name: Headless UI self-test
|
||||||
if: steps.ver.outputs.release == 'true'
|
|
||||||
run: |
|
run: |
|
||||||
apt-get update -qq && apt-get install -y -qq --no-install-recommends \
|
apt-get update -qq && apt-get install -y -qq --no-install-recommends \
|
||||||
xvfb xauth dbus-x11 fonts-dejavu-core >/dev/null
|
xvfb xauth dbus-x11 fonts-dejavu-core >/dev/null
|
||||||
@@ -93,7 +91,6 @@ jobs:
|
|||||||
xvfb-run -a env GDK_BACKEND=x11 ALKANE_SELFTEST=1 "$BIN"
|
xvfb-run -a env GDK_BACKEND=x11 ALKANE_SELFTEST=1 "$BIN"
|
||||||
|
|
||||||
- name: Dependency audit (best-effort)
|
- name: Dependency audit (best-effort)
|
||||||
if: steps.ver.outputs.release == 'true'
|
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
run: |
|
run: |
|
||||||
if command -v cargo-audit >/dev/null 2>&1; then
|
if command -v cargo-audit >/dev/null 2>&1; then
|
||||||
@@ -111,7 +108,6 @@ jobs:
|
|||||||
# already installed by the self-test step above.
|
# already installed by the self-test step above.
|
||||||
- name: Coverage (best-effort)
|
- name: Coverage (best-effort)
|
||||||
id: cov
|
id: cov
|
||||||
if: steps.ver.outputs.release == 'true'
|
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
run: |
|
run: |
|
||||||
rustup component add llvm-tools-preview >/dev/null 2>&1 || true
|
rustup component add llvm-tools-preview >/dev/null 2>&1 || true
|
||||||
@@ -136,21 +132,29 @@ jobs:
|
|||||||
echo "cargo-llvm-cov unavailable; coverage badge left as committed"
|
echo "cargo-llvm-cov unavailable; coverage badge left as committed"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
- name: Microbenchmark coverage
|
||||||
|
id: benchcov
|
||||||
|
run: |
|
||||||
|
command -v cargo-llvm-cov >/dev/null
|
||||||
|
PCT=$(bash ci/bench-coverage.sh --summary-only \
|
||||||
|
| awk '/^TOTAL/{gsub(/%/,"",$10); print $10}')
|
||||||
|
[ -n "$PCT" ] || { echo "microbenchmark coverage unavailable" >&2; exit 1; }
|
||||||
|
echo "pct=${PCT}" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "microbenchmark line coverage: ${PCT}%"
|
||||||
|
|
||||||
# Refresh the committed README badges from live metrics and push any change
|
# Refresh the committed README badges from live metrics and push any change
|
||||||
# back to main. Best-effort: a locked-down runner that can't push must not
|
# back to main. Best-effort: a locked-down runner that can't push must not
|
||||||
# fail the release. A badges-only push does not bump the version (see
|
# fail the release. The badge-only commit skips CI to prevent a loop.
|
||||||
# compute-version.sh), so it does not loop back into another release.
|
|
||||||
- name: Refresh badges
|
- name: Refresh badges
|
||||||
if: steps.ver.outputs.release == 'true'
|
if: steps.ver.outputs.release == 'true'
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
env:
|
|
||||||
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
run: |
|
run: |
|
||||||
PASS=$(cargo test -p alkane-gui --offline 2>&1 \
|
PASS=$(cargo test -p alkane-gui --offline 2>&1 \
|
||||||
| grep -hoE '[0-9]+ passed' | grep -oE '[0-9]+' | awk '{s+=$1} END{print s+0}')
|
| grep -hoE '[0-9]+ passed' | grep -oE '[0-9]+' | awk '{s+=$1} END{print s+0}')
|
||||||
# Update the coverage badge only when the coverage step produced a number;
|
# Update the coverage badge only when the coverage step produced a number;
|
||||||
# otherwise leave the committed coverage.svg untouched.
|
# otherwise leave the committed coverage.svg untouched.
|
||||||
COV="${{ steps.cov.outputs.pct }}"
|
COV="${{ steps.cov.outputs.pct }}"
|
||||||
|
BENCH_COV="${{ steps.benchcov.outputs.pct }}"
|
||||||
COV_ARG=""
|
COV_ARG=""
|
||||||
[ -n "$COV" ] && COV_ARG="--coverage $COV"
|
[ -n "$COV" ] && COV_ARG="--coverage $COV"
|
||||||
# Weighted-average microbench delta vs the previous release (round 19 #1).
|
# Weighted-average microbench delta vs the previous release (round 19 #1).
|
||||||
@@ -159,16 +163,14 @@ jobs:
|
|||||||
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 2>/dev/null || echo NEW)
|
||||||
python3 ci/gen-badges.py --tests "${PASS:-0}" $COV_ARG \
|
python3 ci/gen-badges.py --tests "${PASS:-0}" $COV_ARG \
|
||||||
|
--bench-coverage "$BENCH_COV" \
|
||||||
--bench-delta "${BENCH_DELTA:-NEW}" --bench "row-render + scan-parse"
|
--bench-delta "${BENCH_DELTA:-NEW}" --bench "row-render + scan-parse"
|
||||||
if [ -n "$(git status --porcelain badges)" ]; then
|
if [ -n "$(git status --porcelain badges)" ]; then
|
||||||
git config user.name "alkane-ci"
|
git config user.name "alkane-ci"
|
||||||
git config user.email "ci@bluefla.re"
|
git config user.email "ci@bluefla.re"
|
||||||
git add badges
|
git add badges
|
||||||
git commit -m "ci: refresh README badges [skip release]"
|
git commit -m "ci: refresh README badges [skip ci]"
|
||||||
API="${GITHUB_API_URL:-https://gitea.bluefla.re/api/v1}"
|
git push origin "HEAD:main" || echo "badge push skipped"
|
||||||
HOST="${API%/api/v1}"
|
|
||||||
git -c http.extraheader="Authorization: token ${TOKEN}" \
|
|
||||||
push "${HOST}/${GITHUB_REPOSITORY}.git" "HEAD:main" || echo "badge push skipped"
|
|
||||||
else
|
else
|
||||||
echo "badges unchanged"
|
echo "badges unchanged"
|
||||||
fi
|
fi
|
||||||
@@ -197,21 +199,8 @@ jobs:
|
|||||||
- name: Create Gitea release + upload artifact
|
- name: Create Gitea release + upload artifact
|
||||||
if: steps.ver.outputs.release == 'true'
|
if: steps.ver.outputs.release == 'true'
|
||||||
env:
|
env:
|
||||||
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
run: |
|
run: python3 ci/release-rc.py "${{ steps.ver.outputs.tag }}" false "${{ steps.pkg.outputs.asset }}"
|
||||||
TAG="${{ steps.ver.outputs.tag }}"
|
|
||||||
API="${GITHUB_API_URL:-https://gitea.bluefla.re/api/v1}"
|
|
||||||
REPO="${GITHUB_REPOSITORY}"
|
|
||||||
body="Automated ${{ steps.ver.outputs.bump }} release from ${GITHUB_SHA}."
|
|
||||||
rel=$(curl -sS -X POST -H "Authorization: token ${TOKEN}" -H "Content-Type: application/json" \
|
|
||||||
"${API}/repos/${REPO}/releases" \
|
|
||||||
-d "{\"tag_name\":\"${TAG}\",\"target_commitish\":\"${GITHUB_SHA}\",\"name\":\"${TAG}\",\"body\":\"${body}\"}")
|
|
||||||
id=$(echo "$rel" | grep -oE '"id":[0-9]+' | head -1 | cut -d: -f2)
|
|
||||||
if [ -z "$id" ]; then echo "release create failed: $rel"; exit 1; fi
|
|
||||||
curl -sS -X POST -H "Authorization: token ${TOKEN}" -H "Content-Type: application/gzip" \
|
|
||||||
"${API}/repos/${REPO}/releases/${id}/assets?name=${{ steps.pkg.outputs.assetname }}" \
|
|
||||||
--data-binary @"${{ steps.pkg.outputs.asset }}" | grep -oE '"browser_download_url":"[^"]+"' || true
|
|
||||||
echo "Released ${TAG}"
|
|
||||||
|
|
||||||
- name: No release needed
|
- name: No release needed
|
||||||
if: steps.ver.outputs.release != 'true'
|
if: steps.ver.outputs.release != 'true'
|
||||||
|
|||||||
@@ -6,8 +6,9 @@ name: verify
|
|||||||
# these checks before it cuts a release -- so no work is duplicated on main).
|
# these checks before it cuts a release -- so no work is duplicated on main).
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
|
branches-ignore: [next]
|
||||||
push:
|
push:
|
||||||
branches-ignore: [main]
|
branches-ignore: [main, next]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
verify:
|
verify:
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
/target
|
/target
|
||||||
**/target
|
**/target
|
||||||
.claude/
|
.claude/
|
||||||
|
__pycache__/
|
||||||
|
|||||||
@@ -1,14 +1,18 @@
|
|||||||
# 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
|
||||||
|
runs are queued. Its SVG is 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, and installs **stock** or **alkaneOS** firmware onto a
|
||||||
@@ -82,11 +86,12 @@ xvfb-run -a env ALKANE_SELFTEST=1 \
|
|||||||
ci/coverage.sh --summary-only # coverage (tests + self-test)
|
ci/coverage.sh --summary-only # coverage (tests + self-test)
|
||||||
```
|
```
|
||||||
|
|
||||||
CI mirrors these: `verify.yml` runs the lint, tests, benchmarks, self-test, and
|
CI mirrors these: `verify.yml` runs lint, tests, benchmarks, the self-test, and
|
||||||
a best-effort dependency audit on every pull request and branch push;
|
a dependency audit on development branches. `release.yml` runs the full gate
|
||||||
`release.yml` repeats them on `main` and cuts an `X.Y.Z` release with the built
|
on every `main` push and cuts an `X.Y.Z` release when the change warrants it.
|
||||||
binary attached when the change warrants it. Dependencies are vendored under
|
`next.yml` builds release candidates with little testing and publishes `-rc`
|
||||||
`vendor/`, so builds never touch the network.
|
releases. Dependencies are vendored under `vendor/`, so builds never touch the
|
||||||
|
network.
|
||||||
|
|
||||||
## Architecture
|
## Architecture
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
{
|
{
|
||||||
"bench_parse_line_near_max_addrs": 6024293.0,
|
"bench_parse_line_near_max_addrs": 807160.0,
|
||||||
"bench_parse_targets_many_ranges_near_cap": 222610900.0,
|
"bench_parse_targets_many_ranges_near_cap": 54465485.0,
|
||||||
"bench_render_cells": 20214728.0,
|
"bench_render_cells": 3503112.0,
|
||||||
"bench_sort_by_each_column": 4018989.0,
|
"bench_sort_by_each_column": 486975.0,
|
||||||
"bench_targets_to_cidrs_large_range": 3617810.0,
|
"bench_targets_to_cidrs_large_range": 482167.0,
|
||||||
"bench_upsert_cold_start_population": 57182111.0,
|
"bench_upsert_cold_start_population": 8315814.0,
|
||||||
"bench_view_pipeline": 901801.0,
|
"bench_view_pipeline": 191794.0,
|
||||||
"bench_view_pipeline_default_sort": 2044453.0,
|
"bench_view_pipeline_default_sort": 193214.0,
|
||||||
"bench_view_pipeline_with_filter": 2139556.0
|
"bench_view_pipeline_with_filter": 253085.0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="128.0" height="20" role="img" aria-label="bench coverage: 7%">
|
||||||
|
<title>bench coverage: 7%</title>
|
||||||
|
<linearGradient id="s" x2="0" y2="100%">
|
||||||
|
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
||||||
|
<stop offset="1" stop-opacity=".1"/>
|
||||||
|
</linearGradient>
|
||||||
|
<clipPath id="r"><rect width="128.0" height="20" rx="3" fill="#fff"/></clipPath>
|
||||||
|
<g clip-path="url(#r)">
|
||||||
|
<rect width="103.0" height="20" fill="#555"/>
|
||||||
|
<rect x="103.0" width="25.0" height="20" fill="#e05d44"/>
|
||||||
|
<rect width="128.0" height="20" fill="url(#s)"/>
|
||||||
|
</g>
|
||||||
|
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="11">
|
||||||
|
<text x="51.5" y="15" fill="#010101" fill-opacity=".3">bench coverage</text>
|
||||||
|
<text x="51.5" y="14">bench coverage</text>
|
||||||
|
<text x="115.5" y="15" fill="#010101" fill-opacity=".3">7%</text>
|
||||||
|
<text x="115.5" y="14">7%</text>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 946 B |
@@ -1,19 +1,19 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="147.5" height="20" role="img" aria-label="bench: -25.6% vs prev">
|
<svg xmlns="http://www.w3.org/2000/svg" width="141.0" height="20" role="img" aria-label="bench: +7.4% vs prev">
|
||||||
<title>bench: -25.6% vs prev</title>
|
<title>bench: +7.4% vs prev</title>
|
||||||
<linearGradient id="s" x2="0" y2="100%">
|
<linearGradient id="s" x2="0" y2="100%">
|
||||||
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
||||||
<stop offset="1" stop-opacity=".1"/>
|
<stop offset="1" stop-opacity=".1"/>
|
||||||
</linearGradient>
|
</linearGradient>
|
||||||
<clipPath id="r"><rect width="147.5" height="20" rx="3" fill="#fff"/></clipPath>
|
<clipPath id="r"><rect width="141.0" height="20" rx="3" fill="#fff"/></clipPath>
|
||||||
<g clip-path="url(#r)">
|
<g clip-path="url(#r)">
|
||||||
<rect width="44.5" height="20" fill="#555"/>
|
<rect width="44.5" height="20" fill="#555"/>
|
||||||
<rect x="44.5" width="103.0" height="20" fill="#4c1"/>
|
<rect x="44.5" width="96.5" height="20" fill="#dfb317"/>
|
||||||
<rect width="147.5" height="20" fill="url(#s)"/>
|
<rect width="141.0" height="20" fill="url(#s)"/>
|
||||||
</g>
|
</g>
|
||||||
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="11">
|
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="11">
|
||||||
<text x="22.2" y="15" fill="#010101" fill-opacity=".3">bench</text>
|
<text x="22.2" y="15" fill="#010101" fill-opacity=".3">bench</text>
|
||||||
<text x="22.2" y="14">bench</text>
|
<text x="22.2" y="14">bench</text>
|
||||||
<text x="96.0" y="15" fill="#010101" fill-opacity=".3">-25.6% vs prev</text>
|
<text x="92.8" y="15" fill="#010101" fill-opacity=".3">+7.4% vs prev</text>
|
||||||
<text x="96.0" y="14">-25.6% vs prev</text>
|
<text x="92.8" y="14">+7.4% vs prev</text>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 952 B After Width: | Height: | Size: 950 B |
@@ -1,5 +1,5 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="141.0" height="20" role="img" aria-label="lines of code: 13.6k">
|
<svg xmlns="http://www.w3.org/2000/svg" width="141.0" height="20" role="img" aria-label="lines of code: 13.7K">
|
||||||
<title>lines of code: 13.6k</title>
|
<title>lines of code: 13.7K</title>
|
||||||
<linearGradient id="s" x2="0" y2="100%">
|
<linearGradient id="s" x2="0" y2="100%">
|
||||||
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
||||||
<stop offset="1" stop-opacity=".1"/>
|
<stop offset="1" stop-opacity=".1"/>
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="11">
|
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="11">
|
||||||
<text x="48.2" y="15" fill="#010101" fill-opacity=".3">lines of code</text>
|
<text x="48.2" y="15" fill="#010101" fill-opacity=".3">lines of code</text>
|
||||||
<text x="48.2" y="14">lines of code</text>
|
<text x="48.2" y="14">lines of code</text>
|
||||||
<text x="118.8" y="15" fill="#010101" fill-opacity=".3">13.6k</text>
|
<text x="118.8" y="15" fill="#010101" fill-opacity=".3">13.7K</text>
|
||||||
<text x="118.8" y="14">13.6k</text>
|
<text x="118.8" y="14">13.7K</text>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 952 B After Width: | Height: | Size: 952 B |
@@ -1,19 +1,19 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="95.5" height="20" role="img" aria-label="clippy: clean">
|
<svg xmlns="http://www.w3.org/2000/svg" width="108.5" height="20" role="img" aria-label="code quality: A">
|
||||||
<title>clippy: clean</title>
|
<title>code quality: A</title>
|
||||||
<linearGradient id="s" x2="0" y2="100%">
|
<linearGradient id="s" x2="0" y2="100%">
|
||||||
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
||||||
<stop offset="1" stop-opacity=".1"/>
|
<stop offset="1" stop-opacity=".1"/>
|
||||||
</linearGradient>
|
</linearGradient>
|
||||||
<clipPath id="r"><rect width="95.5" height="20" rx="3" fill="#fff"/></clipPath>
|
<clipPath id="r"><rect width="108.5" height="20" rx="3" fill="#fff"/></clipPath>
|
||||||
<g clip-path="url(#r)">
|
<g clip-path="url(#r)">
|
||||||
<rect width="51.0" height="20" fill="#555"/>
|
<rect width="90.0" height="20" fill="#555"/>
|
||||||
<rect x="51.0" width="44.5" height="20" fill="#4c1"/>
|
<rect x="90.0" width="18.5" height="20" fill="#4c1"/>
|
||||||
<rect width="95.5" height="20" fill="url(#s)"/>
|
<rect width="108.5" height="20" fill="url(#s)"/>
|
||||||
</g>
|
</g>
|
||||||
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="11">
|
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="11">
|
||||||
<text x="25.5" y="15" fill="#010101" fill-opacity=".3">clippy</text>
|
<text x="45.0" y="15" fill="#010101" fill-opacity=".3">code quality</text>
|
||||||
<text x="25.5" y="14">clippy</text>
|
<text x="45.0" y="14">code quality</text>
|
||||||
<text x="73.2" y="15" fill="#010101" fill-opacity=".3">clean</text>
|
<text x="99.2" y="15" fill="#010101" fill-opacity=".3">A</text>
|
||||||
<text x="73.2" y="14">clean</text>
|
<text x="99.2" y="14">A</text>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 916 B After Width: | Height: | Size: 927 B |
@@ -1,5 +1,5 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="121.5" height="20" role="img" aria-label="tests: 93 passing">
|
<svg xmlns="http://www.w3.org/2000/svg" width="121.5" height="20" role="img" aria-label="tests: 95 passing">
|
||||||
<title>tests: 93 passing</title>
|
<title>tests: 95 passing</title>
|
||||||
<linearGradient id="s" x2="0" y2="100%">
|
<linearGradient id="s" x2="0" y2="100%">
|
||||||
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
||||||
<stop offset="1" stop-opacity=".1"/>
|
<stop offset="1" stop-opacity=".1"/>
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="11">
|
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="11">
|
||||||
<text x="22.2" y="15" fill="#010101" fill-opacity=".3">tests</text>
|
<text x="22.2" y="15" fill="#010101" fill-opacity=".3">tests</text>
|
||||||
<text x="22.2" y="14">tests</text>
|
<text x="22.2" y="14">tests</text>
|
||||||
<text x="83.0" y="15" fill="#010101" fill-opacity=".3">93 passing</text>
|
<text x="83.0" y="15" fill="#010101" fill-opacity=".3">95 passing</text>
|
||||||
<text x="83.0" y="14">93 passing</text>
|
<text x="83.0" y="14">95 passing</text>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 935 B After Width: | Height: | Size: 935 B |
@@ -0,0 +1,8 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Measure only instrumented microbenchmarks, excluding unit and UI tests.
|
||||||
|
set -euo pipefail
|
||||||
|
export WX_RS_WXCONFIG="${WX_RS_WXCONFIG:-$HOME/.cache/wx-3.3.3-linux/bin/wx-config}"
|
||||||
|
cargo llvm-cov clean --workspace
|
||||||
|
cargo llvm-cov --no-report --offline --release -p alkane-gui -- \
|
||||||
|
--ignored --nocapture bench_
|
||||||
|
cargo llvm-cov report --release --ignore-filename-regex '(thirdparty|vendor)/' "$@"
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Convert the next final version into a monotonically numbered prerelease.
|
||||||
|
set -euo pipefail
|
||||||
|
result="$(bash ci/compute-version.sh)"
|
||||||
|
release="$(printf '%s\n' "$result" | sed -n 's/^release=//p')"
|
||||||
|
if [ "$release" != true ]; then
|
||||||
|
echo "release=false"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
version="$(printf '%s\n' "$result" | sed -n 's/^version=//p')"
|
||||||
|
last="$(git tag -l "v${version}-rc.*" | sed -n "s/^v${version//./\.}-rc\.\([0-9][0-9]*\)$/\1/p" | sort -n | tail -1)"
|
||||||
|
next=$(( ${last:-0} + 1 ))
|
||||||
|
echo "release=true"
|
||||||
|
echo "version=${version}-rc.${next}"
|
||||||
|
echo "tag=v${version}-rc.${next}"
|
||||||
@@ -18,7 +18,7 @@ X=0
|
|||||||
[ -f "$x_file" ] && X=$(tr -dc '0-9' < "$x_file")
|
[ -f "$x_file" ] && X=$(tr -dc '0-9' < "$x_file")
|
||||||
X=${X:-0}
|
X=${X:-0}
|
||||||
|
|
||||||
last=$(git tag -l 'v*.*.*' | sort -V | tail -1 || true)
|
last=$(git tag -l 'v*.*.*' | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -1 || true)
|
||||||
if [ -n "$last" ]; then
|
if [ -n "$last" ]; then
|
||||||
v=${last#v}; lx=${v%%.*}; rest=${v#*.}; ly=${rest%%.*}; lz=${rest##*.}
|
v=${last#v}; lx=${v%%.*}; rest=${v#*.}; ly=${rest%%.*}; lz=${rest##*.}
|
||||||
changed=$(git diff --name-only "$last"..HEAD)
|
changed=$(git diff --name-only "$last"..HEAD)
|
||||||
|
|||||||
@@ -133,9 +133,19 @@ def cov_color(pct: float) -> str:
|
|||||||
|
|
||||||
|
|
||||||
def human(n: int) -> str:
|
def human(n: int) -> str:
|
||||||
if n >= 1000:
|
suffixes = ("", "K", "M", "G")
|
||||||
return f"{n / 1000:.1f}k".replace(".0k", "k")
|
value = float(n)
|
||||||
return str(n)
|
index = 0
|
||||||
|
while value >= 999.5 and index < len(suffixes) - 1:
|
||||||
|
value /= 1000
|
||||||
|
index += 1
|
||||||
|
if value >= 100:
|
||||||
|
number = f"{value:.0f}"
|
||||||
|
elif value >= 10:
|
||||||
|
number = f"{value:.1f}".rstrip("0").rstrip(".")
|
||||||
|
else:
|
||||||
|
number = f"{value:.2f}".rstrip("0").rstrip(".")
|
||||||
|
return number + suffixes[index]
|
||||||
|
|
||||||
|
|
||||||
def main() -> int:
|
def main() -> int:
|
||||||
@@ -144,6 +154,7 @@ def main() -> int:
|
|||||||
ap.add_argument("--root", default=".")
|
ap.add_argument("--root", default=".")
|
||||||
ap.add_argument("--tests", type=int, default=None)
|
ap.add_argument("--tests", type=int, default=None)
|
||||||
ap.add_argument("--coverage", type=float, default=None)
|
ap.add_argument("--coverage", type=float, default=None)
|
||||||
|
ap.add_argument("--bench-coverage", type=float, default=None)
|
||||||
ap.add_argument("--bench", default=None)
|
ap.add_argument("--bench", default=None)
|
||||||
# Weighted-average microbench delta vs the previous release, as a signed
|
# Weighted-average microbench delta vs the previous release, as a signed
|
||||||
# percentage string (e.g. "-3.2"), or "NEW"/"" when there is no baseline yet
|
# percentage string (e.g. "-3.2"), or "NEW"/"" when there is no baseline yet
|
||||||
@@ -167,11 +178,15 @@ def main() -> int:
|
|||||||
write("loc", "lines of code", human(loc), loc_color(loc))
|
write("loc", "lines of code", human(loc), loc_color(loc))
|
||||||
write("license", "license", lic, "blue")
|
write("license", "license", lic, "blue")
|
||||||
write("dependencies", "dependencies", str(deps), "blue")
|
write("dependencies", "dependencies", str(deps), "blue")
|
||||||
write("quality", "clippy", args.clippy, "brightgreen" if args.clippy == "clean" else "orange")
|
grade = "A" if args.clippy == "clean" else "F"
|
||||||
|
write("quality", "code quality", grade, "brightgreen" if grade == "A" else "red")
|
||||||
if args.tests is not None:
|
if args.tests is not None:
|
||||||
write("tests", "tests", f"{args.tests} passing", "brightgreen")
|
write("tests", "tests", f"{args.tests} passing", "brightgreen")
|
||||||
if args.coverage is not None:
|
if args.coverage is not None:
|
||||||
write("coverage", "coverage", f"{args.coverage:.0f}%", cov_color(args.coverage))
|
write("coverage", "coverage", f"{args.coverage:.0f}%", cov_color(args.coverage))
|
||||||
|
write("bench-coverage", "bench coverage",
|
||||||
|
f"{args.bench_coverage:.0f}%" if args.bench_coverage is not None else "pending",
|
||||||
|
cov_color(args.bench_coverage) if args.bench_coverage is not None else "lightgrey")
|
||||||
# Bench badge: prefer the weighted-average delta vs the previous release; fall
|
# Bench badge: prefer the weighted-average delta vs the previous release; fall
|
||||||
# back to the static label (first run, or when the delta could not be computed).
|
# back to the static label (first run, or when the delta could not be computed).
|
||||||
delta = None
|
delta = None
|
||||||
|
|||||||
@@ -0,0 +1,115 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
"""Publish the last completed main/next CI result to a private badge branch."""
|
||||||
|
|
||||||
|
import base64
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
from urllib.error import HTTPError
|
||||||
|
from urllib.parse import quote, urlencode
|
||||||
|
from urllib.request import Request, urlopen
|
||||||
|
|
||||||
|
|
||||||
|
WORKFLOWS = {"release.yml": "main", "next.yml": "next"}
|
||||||
|
BADGE_BRANCH = "ci-badges"
|
||||||
|
|
||||||
|
|
||||||
|
def badge(branch: str, conclusion: str, run_id: int) -> bytes:
|
||||||
|
passed = conclusion == "success"
|
||||||
|
word = "pass" if passed else "fail"
|
||||||
|
color = "#2ea043" if passed else "#d1242f"
|
||||||
|
title = f"CI {branch}: last completed attempt {word} (run {run_id})"
|
||||||
|
return (f'<svg xmlns="http://www.w3.org/2000/svg" width="102" height="20" '
|
||||||
|
f'role="img" aria-label="{title}"><title>{title}</title>'
|
||||||
|
'<rect width="102" height="20" rx="3" fill="#555"/>'
|
||||||
|
f'<path d="M39 0h60a3 3 0 0 1 3 3v14a3 3 0 0 1-3 3H39z" fill="{color}"/>'
|
||||||
|
'<text x="20" y="14" fill="#fff" text-anchor="middle" '
|
||||||
|
'font-family="sans-serif" font-size="11">CI</text>'
|
||||||
|
f'<text x="70" y="14" fill="#fff" text-anchor="middle" '
|
||||||
|
f'font-family="sans-serif" font-size="11">{word}</text></svg>\n').encode()
|
||||||
|
|
||||||
|
|
||||||
|
def request_json(url: str, token: str, method: str = "GET",
|
||||||
|
payload: dict | None = None) -> dict:
|
||||||
|
body = None if payload is None else json.dumps(payload).encode()
|
||||||
|
request = Request(url, data=body, method=method,
|
||||||
|
headers={"Authorization": f"token {token}",
|
||||||
|
"Content-Type": "application/json"})
|
||||||
|
with urlopen(request, timeout=20) as response:
|
||||||
|
return json.load(response)
|
||||||
|
|
||||||
|
|
||||||
|
def latest_completed(api: str, repo: str, workflow: str, branch: str,
|
||||||
|
token: str) -> tuple[int, str]:
|
||||||
|
path = quote(workflow, safe="")
|
||||||
|
latest = None
|
||||||
|
for page in range(1, 21):
|
||||||
|
query = urlencode({"branch": branch, "limit": 50, "page": page})
|
||||||
|
url = f"{api}/repos/{repo}/actions/workflows/{path}/runs?{query}"
|
||||||
|
runs = request_json(url, token).get("workflow_runs", [])
|
||||||
|
for run in runs:
|
||||||
|
if run.get("head_branch") != branch or run.get("status") != "completed":
|
||||||
|
continue
|
||||||
|
if run.get("conclusion") not in ("success", "failure"):
|
||||||
|
continue
|
||||||
|
candidate = (int(run["id"]), run["conclusion"])
|
||||||
|
if latest is None or candidate[0] > latest[0]:
|
||||||
|
latest = candidate
|
||||||
|
if len(runs) < 50:
|
||||||
|
break
|
||||||
|
if latest is None:
|
||||||
|
raise RuntimeError(f"no completed {branch} run found for {workflow}")
|
||||||
|
return latest
|
||||||
|
|
||||||
|
|
||||||
|
def publish(api: str, repo: str, branch: str, data: bytes, token: str) -> None:
|
||||||
|
path = f"{api}/repos/{repo}/contents/{branch}.svg"
|
||||||
|
encoded = base64.b64encode(data).decode("ascii")
|
||||||
|
for attempt in range(3):
|
||||||
|
try:
|
||||||
|
current = request_json(path + "?ref=" + BADGE_BRANCH, token)
|
||||||
|
current_data = base64.b64decode(current["content"])
|
||||||
|
if current_data == data:
|
||||||
|
return
|
||||||
|
sha = current["sha"]
|
||||||
|
method = "PUT"
|
||||||
|
except HTTPError as error:
|
||||||
|
if error.code != 404:
|
||||||
|
raise
|
||||||
|
sha = None
|
||||||
|
method = "POST"
|
||||||
|
payload = {"branch": BADGE_BRANCH, "content": encoded,
|
||||||
|
"message": f"Record completed {branch} CI attempt"}
|
||||||
|
if sha is not None:
|
||||||
|
payload["sha"] = sha
|
||||||
|
try:
|
||||||
|
request_json(path, token, method, payload)
|
||||||
|
return
|
||||||
|
except HTTPError as error:
|
||||||
|
if error.code not in (409, 422) or attempt == 2:
|
||||||
|
raise
|
||||||
|
raise RuntimeError("badge write did not complete")
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
event = json.loads(Path(os.environ["GITHUB_EVENT_PATH"]).read_text())
|
||||||
|
if event.get("action") != "completed":
|
||||||
|
raise RuntimeError("expected a completed workflow_run event")
|
||||||
|
run = event["workflow_run"]
|
||||||
|
workflow = run["path"].split("@", 1)[0].rsplit("/", 1)[-1]
|
||||||
|
expected_branch = WORKFLOWS.get(workflow)
|
||||||
|
if expected_branch is None or run.get("head_branch") != expected_branch:
|
||||||
|
raise RuntimeError("unexpected workflow or branch")
|
||||||
|
repo = os.environ["GITHUB_REPOSITORY"]
|
||||||
|
if event["repository"]["full_name"] != repo:
|
||||||
|
raise RuntimeError("repository mismatch")
|
||||||
|
api = os.environ["GITHUB_API_URL"].rstrip("/")
|
||||||
|
token = os.environ["GITEA_TOKEN"]
|
||||||
|
run_id, conclusion = latest_completed(api, repo, workflow, expected_branch, token)
|
||||||
|
publish(api, repo, expected_branch, badge(expected_branch, conclusion, run_id), token)
|
||||||
|
print(f"{expected_branch} badge records completed run {run_id}: {conclusion}")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
"""Create one Gitea release and attach files using the runner's scoped token."""
|
||||||
|
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import pathlib
|
||||||
|
import sys
|
||||||
|
import urllib.error
|
||||||
|
import urllib.parse
|
||||||
|
import urllib.request
|
||||||
|
|
||||||
|
|
||||||
|
def request(url, payload, content_type):
|
||||||
|
headers = {
|
||||||
|
"Authorization": "token " + os.environ["GITEA_TOKEN"],
|
||||||
|
"Content-Type": content_type,
|
||||||
|
}
|
||||||
|
req = urllib.request.Request(url, data=payload, headers=headers, method="POST")
|
||||||
|
with urllib.request.urlopen(req, timeout=60) as response:
|
||||||
|
return json.load(response)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
if len(sys.argv) < 4:
|
||||||
|
sys.exit("usage: release.py TAG PRERELEASE FILE [FILE ...]")
|
||||||
|
tag, prerelease, *files = sys.argv[1:]
|
||||||
|
api = os.environ.get("GITHUB_API_URL", "https://gitea.bluefla.re/api/v1").rstrip("/")
|
||||||
|
repo = os.environ["GITHUB_REPOSITORY"]
|
||||||
|
sha = os.environ["GITHUB_SHA"]
|
||||||
|
body = f"Automated Alkane toolkit build from {sha}."
|
||||||
|
metadata = {
|
||||||
|
"tag_name": tag,
|
||||||
|
"target_commitish": sha,
|
||||||
|
"name": tag,
|
||||||
|
"body": body,
|
||||||
|
"prerelease": prerelease.lower() == "true",
|
||||||
|
}
|
||||||
|
try:
|
||||||
|
release = request(f"{api}/repos/{repo}/releases", json.dumps(metadata).encode(), "application/json")
|
||||||
|
except urllib.error.HTTPError as exc:
|
||||||
|
sys.exit(f"release creation failed: HTTP {exc.code}")
|
||||||
|
release_id = release["id"]
|
||||||
|
for name in files:
|
||||||
|
path = pathlib.Path(name)
|
||||||
|
query = urllib.parse.urlencode({"name": path.name})
|
||||||
|
try:
|
||||||
|
request(f"{api}/repos/{repo}/releases/{release_id}/assets?{query}",
|
||||||
|
path.read_bytes(), "application/octet-stream")
|
||||||
|
except urllib.error.HTTPError as exc:
|
||||||
|
sys.exit(f"asset upload failed for {path.name}: HTTP {exc.code}")
|
||||||
|
print(f"Created {tag} with {len(files)} assets")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
"""Check that queued CI runs do not displace the last completed result."""
|
||||||
|
|
||||||
|
import importlib.util
|
||||||
|
from pathlib import Path
|
||||||
|
from unittest.mock import patch
|
||||||
|
import xml.etree.ElementTree as ET
|
||||||
|
|
||||||
|
path = Path(__file__).with_name("last-attempt-badge.py")
|
||||||
|
spec = importlib.util.spec_from_file_location("last_attempt_badge", path)
|
||||||
|
module = importlib.util.module_from_spec(spec)
|
||||||
|
spec.loader.exec_module(module)
|
||||||
|
|
||||||
|
|
||||||
|
def runs(_url, _token):
|
||||||
|
return {"workflow_runs": [
|
||||||
|
{"id": 105, "head_branch": "main", "status": "completed", "conclusion": "cancelled"},
|
||||||
|
{"id": 104, "head_branch": "main", "status": "queued", "conclusion": None},
|
||||||
|
{"id": 103, "head_branch": "main", "status": "completed", "conclusion": "failure"},
|
||||||
|
{"id": 102, "head_branch": "main", "status": "completed", "conclusion": "success"},
|
||||||
|
]}
|
||||||
|
|
||||||
|
|
||||||
|
with patch.object(module, "request_json", runs):
|
||||||
|
assert module.latest_completed("https://example.invalid/api/v1", "owner/repo",
|
||||||
|
"release.yml", "main", "token") == (103, "failure")
|
||||||
|
|
||||||
|
svg = module.badge("main", "failure", 103)
|
||||||
|
root = ET.fromstring(svg)
|
||||||
|
assert root.attrib["aria-label"] == "CI main: last completed attempt fail (run 103)"
|
||||||
|
assert b">fail</text>" in svg
|
||||||
|
assert b"#d1242f" in svg
|
||||||
|
assert b">pass</text>" in module.badge("next", "success", 108)
|
||||||
|
print("last completed CI badge: queued run ignored, pass/fail SVGs valid")
|
||||||