Skip to content

TsukiNi22/ai-utils / skills/git/ci-cd

CI and CD of a GitHub repository in Tsukini's way - the CI (build check, unit tests, style check with xstyle, coverage) and the CD (GitHub releases from the CHANGELOG, RPM/DEB packages and their gh-pages repository, container images on ghcr.io, PyPI, docs on gh-pages, dispatch to other repositories), always asking first what to run, runs the jobs in the user's Docker images (ghcr.io/tsukini22 ci / unit-tests / package / git from the docker-image repository) or else the smallest official image that has what is needed, follows his conventions (names, vars.RUNNER, ccache, set -euo pipefail, annotations, dispatch keywords), and when one of his images misses a tool, adds it to the docker-image repository (Dockerfile, version, CHANGELOG, README) with a local commit only. Used by the project setup skills (cpp-project, python-project) when the project is a GitHub repository. Use whenever the user wants a CI, a CD, a release / deployment / publication pipeline, a GitHub workflow / action, or to change one.

FileKindSize
SKILL.mdskill md9.8 KB
requires.txtmarkdown16 B
scripts/check_workflows.pyexecutablescript5.1 KB
templates/container.ymlconfig1.7 KB
templates/dispatch-repository.ymlconfig877 B
templates/pypi.ymlconfig885 B
templates/python.ymlconfig984 B
templates/release.ymlconfig1.6 KB
templates/style.ymlconfig1.2 KB

scripts/check_workflows.py

View on GitHub
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

 ██╗  ██╗ █████╗ ██████╗ ████████╗ █████╗ ███╗   ██╗██╗ █████╗
 ╚██╗██╔╝██╔══██╗██╔══██╗╚══██╔══╝██╔══██╗████╗  ██║██║██╔══██╗
  ╚███╔╝ ███████║██████╔╝   ██║   ███████║██╔██╗ ██║██║███████║
  ██╔██╗ ██╔══██║██╔══██╗   ██║   ██╔══██║██║╚██╗██║██║██╔══██║
 ██╔╝ ██╗██║  ██║██║  ██║   ██║   ██║  ██║██║ ╚████║██║██║  ██║
 ╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝   ╚═╝   ╚═╝  ╚═╝╚═╝  ╚═══╝╚═╝╚═╝  ╚═╝

Edition:
##  06/10/2026 by Tsukini

File Name:
##  check_workflows.py

File Description:
##  Check GitHub workflows: YAML syntax (actionlint when installed) and the user's conventions
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

##### Import #####
# Import that can't be in the try
from sys import argv, exit, stderr

# Import that can be checked
try:
    from pathlib import Path # Used to find the workflows
    from shutil import which # Used to find actionlint
    import subprocess # Used to run actionlint
    import yaml # Used to parse the workflows
    import re # Used for the conventions
except ImportError as e:
    stderr.write(f"Import Error ({__file__}): {e}\n")
    exit(255)

# Check if the program is call and not imported
if __name__ != "__main__":
    stderr.write(f"The {__file__} can only be executed and not imported!\n")
    exit(255)

##### Const #####
NAME = re.compile(r"^.+ - .+|^.+ \((CI|CD|CI/CD)\)$") # Name - Kind [(CI|CD)] / Name (CI|CD) (as in the user's workflows)
IMAGES = re.compile(r"^ghcr\.io/tsukini22/(ci|unit-tests|package|git)(:|$)")

##### Tools #####
def check(path: Path) -> list[str]:
    problems = []
    try:
        workflow = yaml.safe_load(path.read_text(encoding="utf-8"))
    except yaml.YAMLError as e:
        return [f"YAML error: {e}"]
    if not isinstance(workflow, dict):
        return ["not a workflow (no mapping at the root)"]
    if not NAME.match(str(workflow.get("name", ""))):
        problems.append(f"name '{workflow.get('name')}' is not 'Name - Kind (CI|CD)' / 'Name (CI|CD)'")
    jobs = workflow.get("jobs")
    if not isinstance(jobs, dict):
        return problems + ["no jobs (a mapping of jobs is expected)"]
    for job_id, job in jobs.items():
        if not isinstance(job, dict):
            problems.append(f"job {job_id}: not a mapping")
            continue
        runs_on = str(job.get("runs-on", ""))
        if "vars.RUNNER" not in runs_on:
            problems.append(f"job {job_id}: runs-on '{runs_on}' (convention: ${{{{ vars.RUNNER }}}})")
        image = (job.get("container") or {}).get("image", "") if isinstance(job.get("container"), dict) else str(job.get("container") or "")
        if image and not IMAGES.match(image) and "slim" not in image and "alpine" not in image:
            problems.append(f"job {job_id}: image '{image}' (ghcr.io/tsukini22/* first, else a slim / alpine image)")
        for step in job.get("steps") or []:
            if not isinstance(step, dict):
                problems.append(f"job {job_id}: a step is not a mapping")
                continue
            run = str(step.get("run") or "")
            commands = [line for line in run.strip().splitlines() if line.strip() and not line.rstrip().endswith("\\") and not line.strip().startswith("#")]
            if len(commands) > 1 and "set -e" not in run and "set -uo" not in run:
                problems.append(f"job {job_id}, step '{step.get('name', '?')}': multi-line run without set -euo pipefail")
            if "run" in step and "name" not in step and "\n" in run.strip():
                problems.append(f"job {job_id}: multi-line step without name")
    return problems

##### Program #####
if any(arg in ("-h", "--help") for arg in argv[1:]):
    print("Usage: check_workflows.py [workflow.yml ...]   (default: .github/workflows/*.yml of the current folder)\n"
        "Checks the YAML, actionlint when installed, and the conventions (name, runner, images, set -euo pipefail, step names)")
    exit(0)
paths = [Path(p) for p in argv[1:]] or sorted(Path(".github/workflows").glob("*.y*ml"))
missing = [str(path) for path in paths if not path.is_file()]
if missing:
    stderr.write(f"Error: not found: {', '.join(missing)}\n")
    exit(1)
if not paths:
    stderr.write("Error: no workflow (give the files or run from the repository root)\n")
    exit(1)
status = 0
if which("actionlint"):
    status = subprocess.run(["actionlint", *map(str, paths)]).returncode
for path in paths:
    problems = check(path)
    for problem in problems:
        print(f"{path}: {problem}")
    status = status or (1 if problems else 0)
print("ok" if status == 0 else "problems found")
exit(status)
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 322kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 322kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 322kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 197kUpdated Claude CodeCodexVerifiedInstall