mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 19:01:54 +00:00
Add tests/lint/repository/test_inline_script_block_size.py: scans
roles/, tasks/, playbooks/ and .github/ YAML for literal block scalars
(`|` / `|-` / `|+`) following the keys `shell`, `command`, `script`,
`raw` (Ansible) and `run` (GitHub Actions). Counts logical lines —
trailing-`\` continuations collapse to one line, blank lines are
ignored — and fails when a block exceeds 12.
FOLDED scalars (`>` / `>-` / `>+`) are exempt: they are one shell
statement after YAML folding, even if they span many source lines for
readability.
The walk goes through `utils.cache.files.iter_project_files(...)` per
`docs/agents/action/testing.md` so the shared project-tree cache is
reused across the lint suite.
The fail message tells the author exactly how to fix: Ansible tasks
get the built-in `script:` module (collapses the task to one line);
GitHub Actions workflows extract into `scripts/github/<name>.sh` and
call it via `run: bash scripts/github/<name>.sh` (or
`_helpers/scripts/github/<name>.sh` when the workflow checks out the
repo into `_helpers/`).
Extract the pre-existing literal-block offenders so the new lint
ships green:
Ansible (script: module, file under <role>/files/)
web-app-friendica sync_addon.sh
web-app-fider create_admin_user.sh
web-app-fider configure_oidc_provider.sh
web-app-mediawiki install_or_update.sh
web-app-mediawiki composer_install_extension.sh
web-app-xwiki debug_superadmin.sh
GitHub Actions (scripts/github/)
pick_distro.sh
guard_release.sh
resolve_release_inputs.sh
disk_pressure_report.sh
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
29 lines
775 B
Bash
Executable File
29 lines
775 B
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# Guard the version-release pipeline: only allow when the commit the
|
|
# version tag points at is contained in origin/main. Sets `allowed` on
|
|
# GITHUB_OUTPUT to true / false.
|
|
#
|
|
# Usage:
|
|
# guard_release.sh
|
|
# (reads VERSION_TAG from env; writes to GITHUB_OUTPUT)
|
|
set -euo pipefail
|
|
|
|
if [[ -z "${VERSION_TAG:-}" ]]; then
|
|
echo "allowed=false" >>"$GITHUB_OUTPUT"
|
|
echo "⛔ No version tag detected for this commit"
|
|
exit 0
|
|
fi
|
|
|
|
tag="$VERSION_TAG"
|
|
tag_sha="$(git rev-list -n 1 "$tag")"
|
|
echo "Tag: ${tag} -> ${tag_sha}"
|
|
|
|
if git merge-base --is-ancestor "$tag_sha" "origin/main"; then
|
|
echo "allowed=true" >>"$GITHUB_OUTPUT"
|
|
echo "✅ Tag commit is on origin/main"
|
|
else
|
|
echo "allowed=false" >>"$GITHUB_OUTPUT"
|
|
echo "⛔ Tag commit is NOT on origin/main"
|
|
fi
|