aien-sovereign-core-mv
AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.
Brought by drakestapleton
aien-sovereign-core-mv / scripts / test-dry-run-workflow.sh
| 1 | #!/usr/bin/env bash |
| 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 | # Static guard: .github/workflows/release-dry-run.yml (pull_request or manual workflow_dispatch) must not be able to publish. |
| 18 | # It may read the repository and run the offline release checks; nothing else. |
| 19 | # scripts/test-dry-run-workflow.sh [workflow-file] |
| 20 | # Mutation note: adding a `gh release`, `secrets.` reference, `contents: write` or an upload step to the workflow |
| 21 | # makes this fail; the self-checks below prove each pattern fires on a mutated copy. |
| 22 | set -euo pipefail |
| 23 | ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" |
| 24 | F="${1:-$ROOT/.github/workflows/release-dry-run.yml}" |
| 25 | [[ -f "$F" ]] || { echo "FAIL: $F missing" >&2; exit 1; } |
| 26 | BAD='gh release|gh api|secrets\.|GH_TOKEN|GITHUB_TOKEN|contents: *write|id-token|packages: *write|upload-artifact|upload-release|action-gh-release|ssh-keygen|release create|workflow_run|pull_request_target' |
| 27 | violations() { grep -nE "$BAD" "$1" | grep -vE '^[0-9]+:[[:space:]]*#' || true; } |
| 28 | v="$(violations "$F")" |
| 29 | [[ -z "$v" ]] || { echo "FAIL: dry-run workflow contains publish or secret patterns:" >&2; echo "$v" >&2; exit 1; } |
| 30 | grep -qE '^permissions:' "$F" && grep -qE '^[[:space:]]+contents: read$' "$F" || { echo "FAIL: workflow must declare permissions contents: read" >&2; exit 1; } |
| 31 | # Triggers: since Phase 3 (#671) the hosted workflow is manual (workflow_dispatch); the Spark judge runs this guard. |
| 32 | # The workflow may be triggered only by pull_request or workflow_dispatch, never by push, schedule or anything that |
| 33 | # runs with write power; it must declare at least one of the two. |
| 34 | grep -qE '^[[:space:]]*(pull_request|workflow_dispatch):' "$F" || { echo "FAIL: workflow must run on pull_request or workflow_dispatch" >&2; exit 1; } |
| 35 | trig="$(awk '/^on:/{f=1;next} f&&/^[^[:space:]#]/{f=0} f&&/^ [A-Za-z_]+:/{sub(/:.*/,"");gsub(/ /,"");print}' "$F")" |
| 36 | for t in $trig; do |
| 37 | case "$t" in pull_request|workflow_dispatch) ;; *) echo "FAIL: workflow trigger not allowed: $t" >&2; exit 1 ;; esac |
| 38 | done |
| 39 | M="$(mktemp)"; trap 'rm -f "$M"' EXIT |
| 40 | for bad in 'run: gh release create v1' 'x: ${{ secrets.AIEN_RELEASE_SIGNING_KEY }}' 'contents: write' 'uses: actions/upload-artifact@v4'; do |
| 41 | { cat "$F"; echo " $bad"; } > "$M" |
| 42 | [[ -n "$(violations "$M")" ]] || { echo "FAIL: guard does not catch: $bad" >&2; exit 1; } |
| 43 | done |
| 44 | for trigger in push: schedule: workflow_run:; do |
| 45 | awk -v t="$trigger" '{print} /^on:/{print " " t}' "$F" > "$M" |
| 46 | bash "${BASH_SOURCE[0]}" "$M" >/dev/null 2>&1 && { echo "FAIL: guard does not catch trigger: $trigger" >&2; exit 1; } |
| 47 | done |
| 48 | echo "ok: dry-run workflow has no publish, secrets, signing or upload, and only contents: read" |