This page is generated from
README.md. Changes made here are overwritten the next time the wiki is published.
English · Dansk · Bahasa Melayu
TirSystem GitHub Actions
A collection of reusable Gitea Actions workflows for DevOps professionals and software engineers working on TirSystem projects.
Overview
This repository is the central collection of reusable automation for TirSystem repositories. The primary repository lives at git.tirsystem.com (Gitea) and is push-mirrored to GitHub.
It contains eight workflows: the scoped CI (a credential scan first, then the validation of the workflow files, an OpenGrep scan and the changelog check) and the scoped CD (the release, the publishing of accepted milestones, the wiki pages and the description and topics of the GitHub mirror, each only for its own paths), the reusable shared quality checks for Python and shell, for C and C++ and for C#, code metrics and coverage badges, a check that comments are in English, and the repository's own validation. They are listed with their purpose and a diagram under Workflows.
Workflows
When a repository should use each workflow in its SQA and QC is set out in the adoption rules.
Eight workflows live in this repository. A scoped workflow is delivered by the instance to every repository of the TirSystem organizations and needs nothing in the repository; a reusable workflow is called by a repository with uses:; the others run only here. The diagrams are PlantUML source.
| Workflow | File | Kind | Starts on | Purpose |
|---|---|---|---|---|
| CI | ci.yml |
Scoped | pull request, push to main, manual |
The checking half of the pipeline: secret-scan first (Gitleaks, a finding fails the run and skips the rest), then validate, opengrep and release-check side by side; the statuses are CI / <job> (<event>). They replace the six scoped workflows of the versions before 4.0.0 (ADR-0019) |
| CD | cd.yml |
Scoped | push to main, daily 03:17 UTC, manual (the milestone sync is a dry run by default) |
The publishing half of the pipeline: changes reads the paths of the push, wait-for-ci waits for the four CI statuses of the commit, then release, sync-milestones, publish-wiki and sync-metadata run for their own paths. The statuses are CD / <job> (<event>). They replace the six scoped workflows of the versions before 4.0.0 (ADR-0019) |
| Quality checks | quality-checks.yml |
Reusable (workflow_call) |
a call from another repository | Runs ruff, mypy, shellcheck and shfmt on the tracked files and changes nothing |
| Quality checks C++ | quality-checks-cpp.yml |
Reusable (workflow_call) |
a call from another repository | Runs clang-format and clang-tidy at exact versions on the tracked C and C++ files and changes nothing |
| Quality checks C# | quality-checks-csharp.yml |
Reusable (workflow_call) |
a call from another repository | Runs dotnet format and dotnet build on an exact .NET SDK 10 or later and changes nothing |
| Code metrics | code-metrics.yml |
Reusable (workflow_call) |
a call from another repository | Counts the code files and the lines of code (without comment and blank lines), reads a Cobertura coverage report and commits three SVG badges to a badges branch |
| English comments | english-comments.yml |
Reusable (workflow_call) |
a call from another repository, on a pull request | Judges the language of the comments and docstrings a pull request adds, fails the run when one is not English and writes one comment on the pull request that mentions the author |
| Validate workflows | validate-workflows.yml |
This repository only | pull request, push to main, manual |
Parses every workflow and runs the offline tests |
Quality checks
A reusable workflow for Python and shell, called with uses: TirSystem/git-workflows/.gitea/workflows/quality-checks.yml@v1 (see the guide).
Workflow
@startuml
title Shared quality checks (reusable workflow)
autonumber
actor "Calling repository\nuses: ...quality-checks.yml@v1" as Caller
participant "Gitea Actions\nquality-checks" as Workflow
participant "PyPI" as PyPI
Caller -> Workflow: workflow_call with languages,\nworking-directory and tool versions
activate Workflow
Workflow -> Workflow: Validate the inputs
alt languages or working-directory is invalid
Workflow --> Caller: Fail with [configuration]
end
Workflow -> Workflow: Check out the calling repository
Workflow -> PyPI: Install the pinned tools in a virtual environment\n(ruff, mypy, shellcheck-py, shfmt-py as selected)
PyPI --> Workflow: Tools installed
loop for each selected language
Workflow -> Workflow: List tracked files
alt no files of that language
Workflow -> Workflow: Notice: nothing was checked
else
Workflow -> Workflow: Run every tool and record PASS or FAIL
end
end
alt any tool failed
Workflow --> Caller: Fail and list the failed tools
else
Workflow --> Caller: All selected checks passed
end
deactivate Workflow
@enduml
Quality checks C++
A reusable workflow for C and C++, called with uses: TirSystem/git-workflows/.gitea/workflows/quality-checks-cpp.yml@v1 (ADR-0008). The repository needs a .clang-format; a .clang-tidy and a compile database are optional.
Workflow
@startuml
title Shared quality checks for C and C++ (reusable workflow)
autonumber
actor "Calling repository\nuses: ...quality-checks-cpp.yml@v1" as Caller
participant "Gitea Actions\nquality-checks-cpp" as Workflow
participant "PyPI" as PyPI
Caller -> Workflow: workflow_call with working-directory, std,\ncompile-commands-dir and tool versions
activate Workflow
Workflow -> Workflow: Check out the caller and the shared script
Workflow -> Workflow: Validate the inputs
alt an input is invalid or a version is not exact
Workflow --> Caller: Fail with [configuration]
end
Workflow -> PyPI: Install clang-format and clang-tidy at the exact versions
PyPI --> Workflow: Tools installed
alt no C or C++ file is tracked
Workflow --> Caller: Notice: nothing was checked, pass
else no .clang-format, or compile-commands-dir\nwithout compile_commands.json
Workflow --> Caller: Fail with [configuration]
else
Workflow -> Workflow: clang-format --dry-run -Werror on all files
Workflow -> Workflow: clang-tidy on the C++ files (-std=std)\nand on the C files (or with the compile database)
alt any tool failed
Workflow --> Caller: Fail with tool, file and line in the log
else
Workflow --> Caller: All selected checks passed
end
end
deactivate Workflow
@enduml
Quality checks C#
A reusable workflow for C#, called with uses: TirSystem/git-workflows/.gitea/workflows/quality-checks-csharp.yml@v1 (ADR-0008). It installs the exact .NET SDK given by dotnet-sdk-version (10 or later) and needs the network for the package restore.
Workflow
@startuml
title Shared quality checks for C# (reusable workflow)
autonumber
actor "Calling repository\nuses: ...quality-checks-csharp.yml@v1" as Caller
participant "Gitea Actions\nquality-checks-csharp" as Workflow
participant "dot.net\n(dotnet-install.sh)" as DotNet
Caller -> Workflow: workflow_call with working-directory,\nproject and dotnet-sdk-version
activate Workflow
Workflow -> Workflow: Check out the caller and the shared script
Workflow -> Workflow: Validate the inputs
alt an input is invalid or the SDK is not an exact\nstable version 10 or later
Workflow --> Caller: Fail with [configuration]
end
Workflow -> DotNet: Install the exact .NET SDK version
DotNet --> Workflow: SDK installed
alt no C# file is tracked
Workflow --> Caller: Notice: nothing was checked, pass
else no solution or project, or several without the project input
Workflow --> Caller: Fail with [configuration] that names them
else
Workflow -> Workflow: dotnet format --verify-no-changes
Workflow -> Workflow: dotnet build -warnaserror\n(package restore needs the network)
alt any tool failed
Workflow --> Caller: Fail with tool, file and line in the log
else
Workflow --> Caller: All selected checks passed
end
end
deactivate Workflow
@enduml
Code metrics
A reusable workflow that counts the code files and the lines of code (without comment and blank lines) of a repository and publishes them, with the test coverage, as three SVG badges on a badges branch, called with uses: TirSystem/git-workflows/.gitea/workflows/code-metrics.yml@v2 (ADR-0010). It needs contents: write and runs no test: an earlier job of the caller produces a Cobertura XML coverage report and uploads it as an artifact (guide).
Workflow
@startuml
title Code metrics and coverage badges (reusable workflow)
autonumber
actor "Calling repository\nuses: ...code-metrics.yml@v2" as Caller
participant "Gitea Actions\ncode-metrics" as Workflow
participant "Branch badges\nof the caller" as Branch
Caller -> Workflow: workflow_call with working-directory, exclude,\ncoverage-report and thresholds
activate Workflow
Workflow -> Workflow: Check out the caller and the shared scripts
Workflow -> Workflow: Validate the inputs
alt an input is invalid
Workflow --> Caller: Fail with [configuration]
end
Workflow -> Workflow: Download the coverage artifact (when given)
Workflow -> Workflow: Count code files and lines of code
alt a coverage report is given but missing or malformed
Workflow --> Caller: Fail with [configuration] that names the file
else
Workflow -> Workflow: Write code-files.svg, code-lines.svg\nand coverage.svg
end
Workflow -> Branch: Compare with the files of the branch
alt no badge changed
Workflow --> Caller: Notice: nothing to commit, pass
else
Workflow -> Branch: One commit with [skip ci]
Workflow --> Caller: Badges published
end
deactivate Workflow
@enduml
English comments
A reusable workflow that checks that the comments and docstrings a pull request adds are written in English, fails the run when one is not, and writes one comment on the pull request that mentions the author. It changes no file and sends no source text outside the instance; marking the check as required in the branch protection is what blocks the merge (guide, ADR-0012).
Workflow
@startuml
title English comments check (reusable workflow)
autonumber
actor "Pull request\nuses: ...english-comments.yml@v2" as Caller
participant "Gitea Actions\nenglish-comments" as Workflow
participant "Gitea REST API" as Gitea
Caller -> Workflow: workflow_call with scope, exclude,\nallowed-words-file, threshold and min-words
activate Workflow
Workflow -> Workflow: Check out the full history and the shared scripts
Workflow -> Workflow: Install the pinned language detector
Workflow -> Workflow: Read the comments on the added lines
Workflow -> Workflow: Remove paths, options, identifiers and allowed words
Workflow -> Workflow: Judge the language of each comment block
alt a block is not English
Workflow -> Gitea: Create or update one comment that mentions the author
Workflow --> Caller: run failed (the required check blocks the merge)
else all blocks are English
Workflow -> Gitea: Mark an earlier comment resolved
Workflow --> Caller: run passed
end
deactivate Workflow
@enduml
CI
A scoped workflow, the checking half of the pipeline of ADR-0019. The first job, secret-scan, reads the commits the change adds (a pull request, a push, or the whole history on a manual start) with a pinned, checksum-verified Gitleaks binary and fails when it finds a credential, naming the rule, the file and the line and never the value. When it is red the three other jobs are skipped; when it is green validate, opengrep and release-check run side by side, each needing only secret-scan, and keep the behaviour of the workflows they replace. The statuses are CI / secret-scan, CI / validate, CI / opengrep and CI / release-check, each with the event in brackets. Every job has permissions: contents: read and a timeout; no job has a secret. It replaces the scoped workflows validate.yml, opengrep.yml and the changelog check of release.yml of the versions before 4.0.0 (ADR-0019).
Workflow
@startuml
title CI (scoped workflow)
autonumber
actor "Pull request or push\nto main" as Event
participant "Gitea Actions\nsecret-scan" as Scan
participant "Gitea Actions\nvalidate, opengrep,\nrelease-check" as Checks
Event -> Scan: Start in every repository
activate Scan
Scan -> Scan: Install Gitleaks and read the commits of the change
alt a credential is found
Scan --> Event: run failed with rule, file and line, no value
note right of Checks: the three other jobs are skipped
else no credential
Scan -> Checks: Start the three jobs side by side
activate Checks
Checks --> Event: one status each, red jobs do not hide each other
deactivate Checks
end
deactivate Scan
@enduml
CD
A scoped workflow, the publishing half of the pipeline of ADR-0019. changes reads the paths the push changed; wait-for-ci polls the commit status until CI / secret-scan, CI / validate, CI / opengrep and CI / release-check of the same commit are green (the instance gives no event that starts a scoped workflow after another one), up to 600 seconds, which a repository may change with the variable CD_CI_WAIT_SECONDS. A red status stops the CD at once; a status still pending after the wait stops it, and so does a missing one on a push, while a schedule or a manual start goes on without a missing one. Then release (when CHANGELOG.md changed), sync-milestones (docs/milestones/** or docs/sqa/reviews/**), publish-wiki (docs/wiki/**) and sync-metadata (every push) run for their own paths, or all of them on the schedule or a manual start. They keep the scripts, the secrets and the opt-ins of the workflows they replace; the milestone sync is a dry run on a manual start unless dry_run is turned off. The statuses are CD / <job> (<event>); the CD is not a required check. It replaces the scoped workflows release.yml, sync-milestones.yml, publish-wiki-pages.yml and sync-github-metadata.yml of the versions before 4.0.0 (ADR-0019).
Workflow
@startuml
title CD (scoped workflow)
autonumber
actor "Push to main,\nschedule or\nmanual start" as Event
participant "Gitea Actions\nchanges, wait-for-ci" as Gate
participant "Gitea Actions\nrelease, sync-milestones,\npublish-wiki, sync-metadata" as Jobs
participant "Gitea commit status" as Status
Event -> Gate: Start in every repository
activate Gate
Gate -> Gate: Read the paths of the push
Gate -> Status: Poll CI / secret-scan, validate, opengrep, release-check
alt a CI status is red, or still pending or missing at the limit
Gate --> Event: run failed, nothing is released or published
else all four are green
Gate -> Jobs: Start the jobs whose paths changed
activate Jobs
Jobs --> Event: one status each
deactivate Jobs
end
deactivate Gate
@enduml
Validate workflows
The repository's own validation: the offline tests that gate every pull request.
Workflow
@startuml
title Validate workflows (this repository's own checks)
autonumber
actor "Pull request,\npush to main, or manual trigger" as Trigger
participant "Gitea Actions\nvalidate-workflows" as Workflow
Trigger -> Workflow: Start workflow
activate Workflow
Workflow -> Workflow: Check out the repository
Workflow -> Workflow: Create a virtual environment and\ninstall tests/requirements.txt
Workflow -> Workflow: Run pytest on tests/ under coverage (offline, no secrets):\nworkflows parse as YAML, no embedded Python,\nscripts compile, wiki pages and translations are current,\nsync, publish and release flows against a fake API
alt a test fails
Workflow --> Trigger: Workflow fails (the pull request is not ready)
else
Workflow --> Trigger: Workflow succeeds
end
deactivate Workflow
@enduml
Requirements
- A Gitea instance with Actions enabled and a runner providing
ubuntu-latestwithpython3 - A configured GitHub push mirror on the Gitea repository (at most one; repositories without a mirror are skipped successfully)
- Repository secrets:
TOKEN_FOR_GITEA_REPO: Gitea API token (the token only, no JSON)TOKEN_FOR_GITHUB_REPO: a GitHub personal access token allowed to edit the mirror repository (the token only, no JSON)TOKEN_FOR_GITEA_WIKI(only for repositories that publish a wiki, see the onboarding guide): a Gitea token that can write the wiki, stored as a secret of the repository's organization; there is no fallback toTOKEN_FOR_GITEA_REPO
Setup
No dependencies need to be installed; the workflow uses only the Python standard library.
- Clone the repository:
git clone ssh://git@git.tirsystem.com:10022/TirSystem/git-workflows.git - Add the secrets listed under Requirements to the repository settings in Gitea.
- Configure the GitHub push mirror in the repository settings.
Run
Workflows run automatically on push to main and on the daily schedule. To run manually, trigger CD (the job sync-metadata syncs the description and topics) via workflow_dispatch from the Actions tab in Gitea.
Tests
The workflow files and the scripts in tools/ are validated by offline tests that need no network access and no secrets:
python3 -m venv .venv
source .venv/bin/activate # Windows PowerShell: .venv\Scripts\Activate.ps1
python -m pip install -r tests/requirements.txt
python -m coverage run -m pytest -q tests
python -m coverage report
The same checks run on every pull request and push to main through validate-workflows.yml. They parse every workflow as YAML, check that none embeds Python, compile the scripts in tools/, require explicit job permissions, and test credential parsing, push mirror address parsing and the sync and publish flows against a fake API. The run fails when the line and branch coverage of tools/ falls below 95% (.coveragerc).
After a change to the metadata sync, also trigger CD manually in Gitea and compare the description and topics on the GitHub mirror.