Merge pull request 'Trigger Alkane OS badge updates on CI completion' (#1) from ci/completion-badge into main
main-release-gate / verify-and-release (push) Failing after 5m18s
main-release-gate / verify-and-release (push) Failing after 5m18s
This commit was merged in pull request #1.
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
name: public-benchmark-pages
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '*/15 * * * *'
|
||||
workflow_run:
|
||||
workflows: [main-release-gate]
|
||||
types: [completed]
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
name: completed-ci-badge
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '*/15 * * * *'
|
||||
workflow_run:
|
||||
workflows: [main-release-gate, next-build]
|
||||
types: [completed]
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
@@ -11,7 +12,7 @@ concurrency:
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: alkane-ci
|
||||
runs-on: alkane-fast
|
||||
permissions:
|
||||
actions: read
|
||||
contents: write
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
name: source-pr
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [main, next]
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: alkane-os-source-pr-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
source:
|
||||
runs-on: alkane-fast
|
||||
env:
|
||||
CARGO_TARGET_DIR: target
|
||||
CARGO_BUILD_JOBS: 2
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Check source
|
||||
run: |
|
||||
rustup component add rustfmt
|
||||
cargo fmt --check
|
||||
cargo test --locked
|
||||
- name: Clean generated source check
|
||||
if: always()
|
||||
run: python3 ci/cleanup-generated.py
|
||||
@@ -10,9 +10,10 @@ concurrency:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: alkane-ci
|
||||
runs-on: alkane-fast
|
||||
env:
|
||||
CARGO_TARGET_DIR: target
|
||||
CARGO_BUILD_JOBS: 2
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
|
||||
@@ -55,8 +55,8 @@ def publish(api: str, repo: str, branch: str, data: bytes, token: str) -> None:
|
||||
|
||||
|
||||
def main() -> None:
|
||||
if os.environ["GITHUB_EVENT_NAME"] not in ("schedule", "workflow_dispatch"):
|
||||
raise RuntimeError("badge publisher must run on a timer or manual dispatch")
|
||||
if os.environ["GITHUB_EVENT_NAME"] not in ("workflow_run", "workflow_dispatch"):
|
||||
raise RuntimeError("badge publisher must follow CI completion or manual dispatch")
|
||||
if os.environ["GITHUB_REF"] != "refs/heads/main":
|
||||
raise RuntimeError("badge publisher must use the main branch")
|
||||
repo = os.environ["GITHUB_REPOSITORY"]
|
||||
|
||||
@@ -36,7 +36,7 @@ assert b">fail</text>" in svg
|
||||
assert b"#d1242f" in svg
|
||||
assert b">pass</text>" in module.badge("next", "success", 108)
|
||||
environment = {
|
||||
"GITHUB_EVENT_NAME": "schedule",
|
||||
"GITHUB_EVENT_NAME": "workflow_run",
|
||||
"GITHUB_REF": "refs/heads/main",
|
||||
"GITHUB_REPOSITORY": "owner/repo",
|
||||
"GITHUB_API_URL": "https://example.invalid/api/v1",
|
||||
@@ -49,13 +49,19 @@ with patch.dict(os.environ, environment), \
|
||||
module.main()
|
||||
assert latest.call_count == 2
|
||||
assert [call.args[2] for call in published.call_args_list] == ["main", "next"]
|
||||
with patch.dict(os.environ, {**environment, "GITHUB_EVENT_NAME": "workflow_run"}):
|
||||
with patch.dict(os.environ, {**environment, "GITHUB_EVENT_NAME": "workflow_dispatch"}), \
|
||||
patch.object(module, "latest_completed", side_effect=[(201, "success"),
|
||||
(202, "failure")]), \
|
||||
patch.object(module, "publish") as published:
|
||||
module.main()
|
||||
assert published.call_count == 2
|
||||
with patch.dict(os.environ, {**environment, "GITHUB_EVENT_NAME": "schedule"}):
|
||||
try:
|
||||
module.main()
|
||||
except RuntimeError as error:
|
||||
assert "timer or manual dispatch" in str(error)
|
||||
assert "CI completion or manual dispatch" in str(error)
|
||||
else:
|
||||
raise AssertionError("workflow_run event entered badge publisher")
|
||||
raise AssertionError("scheduled event entered badge publisher")
|
||||
for invalid in ("", "/main.svg", "../main.svg", "badges//main.svg"):
|
||||
try:
|
||||
publish_file("https://example.invalid/api/v1", "owner/repo", invalid,
|
||||
|
||||
Reference in New Issue
Block a user