Abstract away the required-checks feature (#194)

This commit is contained in:
Patrick Stevens
2024-07-12 21:02:04 +01:00
committed by GitHub
parent 31bd9e22f2
commit 654f760f3a
3 changed files with 4 additions and 48 deletions

View File

@@ -218,15 +218,13 @@ jobs:
run: sh .github/workflows/tag.sh run: sh .github/workflows/tag.sh
all-required-checks-complete: all-required-checks-complete:
if: ${{ always() }}
needs: [check-dotnet-format, check-nix-format, check-accurate-generations, build, build-nix, linkcheck, flake-check, analyzers, nuget-pack, expected-pack, github-release-plugin-dry-run] needs: [check-dotnet-format, check-nix-format, check-accurate-generations, build, build-nix, linkcheck, flake-check, analyzers, nuget-pack, expected-pack, github-release-plugin-dry-run]
if: ${{ always() }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: Smaug123/all-required-checks-complete-action@05b40a8c47ef0b175ea326e9abb09802cb67b44e
- name: Check job statuses with:
env: needs-context: ${{ toJSON(needs) }}
RESULTS: ${{ toJSON(needs) }}
run: python .github/workflows/required_checks.py
attestation-attribute: attestation-attribute:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@@ -2,8 +2,6 @@
name: Weekly Nix Flake Update name: Weekly Nix Flake Update
on: on:
pull_request:
branches: [ main ]
schedule: schedule:
- cron: '0 0 * * 0' # Runs at 00:00 every Sunday - cron: '0 0 * * 0' # Runs at 00:00 every Sunday
workflow_dispatch: # Allows manual triggering workflow_dispatch: # Allows manual triggering

View File

@@ -1,40 +0,0 @@
import os
import json
import sys
from typing import Any
results_json = os.environ.get('RESULTS', '{}') or sys.exit(1)
try:
results = json.loads(results_json)
except json.JSONDecodeError:
print("Error: Unable to parse RESULTS as JSON")
exit(1)
def process_job(job_name: str, job_data: dict[str, Any]) -> int:
"""
Returns 0 on success and 1 on error.
"""
status = job_data['result']
print(f"Processing job: {job_name} with status: {status}")
if status == "success":
print(f"Job {job_name} succeeded.")
return 0
elif status in {"failure", "cancelled"}:
print(f"Job {job_name} failed: status {status}!")
return 1
else:
print(f"Job {job_name} has unknown status: {status}!")
return 1
# Iterate over each job
exit_status = 0
for job_name, job_data in results.items():
if not isinstance(job_data, dict):
print(f"Unexpected shape at key {job_name}: {job_data}")
sys.exit(2)
exit_status += process_job(job_name, job_data)
if exit_status > 0:
sys.exit(3)