aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / scripts / workflow_files_check.sh
| 1 | #!/bin/sh |
| 2 | # SPDX-License-Identifier: Apache-2.0 |
| 3 | # Copyright 2026 Drake Stapleton (AIEN / aien-dev) |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | # Fail when GitHub refused any workflow file on a commit. |
| 18 | # |
| 19 | # A workflow file GitHub cannot parse (for example an unquoted ": " inside a |
| 20 | # step name) produces a run that is recorded as "failure" with zero jobs, and |
| 21 | # that run never appears in a pull request's checks list, so the job it was |
| 22 | # supposed to run silently never runs. 2026-10-12: .github/workflows/ |
| 23 | # ck-kernel.yml was in that state for four hours (aienos#318). This script |
| 24 | # runs from an always-on workflow and turns that silence into a red check. |
| 25 | # |
| 26 | # scripts/workflow_files_check.sh <commit sha> |
| 27 | # Needs: gh with a token that can read Actions (GITHUB_TOKEN in CI), and |
| 28 | # GITHUB_REPOSITORY (owner/name; defaults to aien-dev/aienux). POSIX sh, no |
| 29 | # Python. Exit 0 when every workflow run on the commit has at least one job, |
| 30 | # 1 when one does not, 2 on usage or API error. |
| 31 | set -eu |
| 32 | sha="${1:-}" |
| 33 | [ -n "$sha" ] || { echo "usage: $0 <commit sha>" >&2; exit 2; } |
| 34 | repo="${GITHUB_REPOSITORY:-aien-dev/aienux}" |
| 35 | settle="${WORKFLOW_FILES_SETTLE_SECONDS:-20}" |
| 36 | [ "$settle" -gt 0 ] && sleep "$settle" # let GitHub record the push-event runs |
| 37 | runs=$(gh api "repos/$repo/actions/runs?head_sha=$sha&per_page=100" \ |
| 38 | --jq '.workflow_runs[] | select(.conclusion == "failure") | "\(.id) \(.path)"') \ |
| 39 | || { echo "WORKFLOW_FILES: ERROR cannot list runs for $sha" >&2; exit 2; } |
| 40 | bad=0 |
| 41 | for id in $(printf '%s\n' "$runs" | awk 'NF {print $1}'); do |
| 42 | path=$(printf '%s\n' "$runs" | awk -v i="$id" '$1 == i {print $2}') |
| 43 | n=$(gh api "repos/$repo/actions/runs/$id/jobs" --jq '.total_count') \ |
| 44 | || { echo "WORKFLOW_FILES: ERROR cannot read jobs of run $id" >&2; exit 2; } |
| 45 | if [ "$n" = 0 ]; then |
| 46 | echo "WORKFLOW_FILES: REFUSED $path (run $id failed with no jobs: GitHub did not accept the file)" |
| 47 | bad=1 |
| 48 | fi |
| 49 | done |
| 50 | [ "$bad" = 0 ] && echo "WORKFLOW_FILES: OK (every workflow run on $sha has jobs)" |
| 51 | exit "$bad" |