Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f89f220f3e | ||
|
|
c18a37eebc |
@@ -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
|
||||||
@@ -4,6 +4,9 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches: [next]
|
branches: [next]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
candidate:
|
candidate:
|
||||||
runs-on: alkane-ci
|
runs-on: alkane-ci
|
||||||
@@ -41,5 +44,5 @@ jobs:
|
|||||||
- name: Create private prerelease
|
- name: Create private prerelease
|
||||||
if: steps.version.outputs.release == 'true'
|
if: steps.version.outputs.release == 'true'
|
||||||
env:
|
env:
|
||||||
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
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"
|
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
|
||||||
@@ -27,6 +31,9 @@ jobs:
|
|||||||
- name: Test version logic
|
- name: Test version logic
|
||||||
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
|
||||||
run: |
|
run: |
|
||||||
apt-get update -qq
|
apt-get update -qq
|
||||||
@@ -137,13 +144,10 @@ jobs:
|
|||||||
|
|
||||||
# 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}')
|
||||||
@@ -165,11 +169,8 @@ jobs:
|
|||||||
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
|
||||||
@@ -198,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'
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# alkane-toolkit
|
# alkane-toolkit
|
||||||
|
|
||||||
[](https://gitea.bluefla.re/blueflare/alkane-toolkit/actions)
|
[](https://gitea.bluefla.re/blueflare/alkane-toolkit/actions)
|
||||||

|

|
||||||

|

|
||||||

|

|
||||||
@@ -10,6 +10,9 @@
|
|||||||

|

|
||||||

|

|
||||||
|
|
||||||
|
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
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
{
|
{
|
||||||
"bench_parse_line_near_max_addrs": 644187.0,
|
"bench_parse_line_near_max_addrs": 807160.0,
|
||||||
"bench_parse_targets_many_ranges_near_cap": 49565223.0,
|
"bench_parse_targets_many_ranges_near_cap": 54465485.0,
|
||||||
"bench_render_cells": 3037944.0,
|
"bench_render_cells": 3503112.0,
|
||||||
"bench_sort_by_each_column": 816884.0,
|
"bench_sort_by_each_column": 486975.0,
|
||||||
"bench_targets_to_cidrs_large_range": 443875.0,
|
"bench_targets_to_cidrs_large_range": 482167.0,
|
||||||
"bench_upsert_cold_start_population": 8871040.0,
|
"bench_upsert_cold_start_population": 8315814.0,
|
||||||
"bench_view_pipeline": 177652.0,
|
"bench_view_pipeline": 191794.0,
|
||||||
"bench_view_pipeline_default_sort": 203830.0,
|
"bench_view_pipeline_default_sort": 193214.0,
|
||||||
"bench_view_pipeline_with_filter": 187371.0
|
"bench_view_pipeline_with_filter": 253085.0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="160.5" height="20" role="img" aria-label="bench coverage: pending">
|
<svg xmlns="http://www.w3.org/2000/svg" width="128.0" height="20" role="img" aria-label="bench coverage: 7%">
|
||||||
<title>bench coverage: pending</title>
|
<title>bench coverage: 7%</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="160.5" height="20" rx="3" fill="#fff"/></clipPath>
|
<clipPath id="r"><rect width="128.0" height="20" rx="3" fill="#fff"/></clipPath>
|
||||||
<g clip-path="url(#r)">
|
<g clip-path="url(#r)">
|
||||||
<rect width="103.0" height="20" fill="#555"/>
|
<rect width="103.0" height="20" fill="#555"/>
|
||||||
<rect x="103.0" width="57.5" height="20" fill="#9f9f9f"/>
|
<rect x="103.0" width="25.0" height="20" fill="#e05d44"/>
|
||||||
<rect width="160.5" height="20" fill="url(#s)"/>
|
<rect width="128.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="51.5" y="15" fill="#010101" fill-opacity=".3">bench coverage</text>
|
<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="51.5" y="14">bench coverage</text>
|
||||||
<text x="131.8" y="15" fill="#010101" fill-opacity=".3">pending</text>
|
<text x="115.5" y="15" fill="#010101" fill-opacity=".3">7%</text>
|
||||||
<text x="131.8" y="14">pending</text>
|
<text x="115.5" y="14">7%</text>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 966 B After Width: | Height: | Size: 946 B |
+7
-7
@@ -1,19 +1,19 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="147.5" height="20" role="img" aria-label="bench: -79.9% 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: -79.9% 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">-79.9% 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">-79.9% 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 |
+4
-4
@@ -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.7k">
|
<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.7k</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.7k</text>
|
<text x="118.8" y="15" fill="#010101" fill-opacity=".3">13.7K</text>
|
||||||
<text x="118.8" y="14">13.7k</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 |
@@ -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()
|
||||||
+2
-1
@@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
"""Create one Gitea release and attach files using the runner's scoped token."""
|
"""Create one Gitea release and attach files using the runner's scoped token."""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
@@ -27,7 +28,7 @@ def main():
|
|||||||
api = os.environ.get("GITHUB_API_URL", "https://gitea.bluefla.re/api/v1").rstrip("/")
|
api = os.environ.get("GITHUB_API_URL", "https://gitea.bluefla.re/api/v1").rstrip("/")
|
||||||
repo = os.environ["GITHUB_REPOSITORY"]
|
repo = os.environ["GITHUB_REPOSITORY"]
|
||||||
sha = os.environ["GITHUB_SHA"]
|
sha = os.environ["GITHUB_SHA"]
|
||||||
body = f"Automated Alkane OS build from {sha}. Conformance results are in the repository."
|
body = f"Automated Alkane toolkit build from {sha}."
|
||||||
metadata = {
|
metadata = {
|
||||||
"tag_name": tag,
|
"tag_name": tag,
|
||||||
"target_commitish": sha,
|
"target_commitish": sha,
|
||||||
|
|||||||
@@ -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")
|
||||||
Reference in New Issue
Block a user