A composite action that runs CircuitTwin test suites on the CircuitTwin server and fails the job when a case does not pass. It uploads the JUnit XML and the JSON report as a workflow artifact, writes a job summary, annotates the cases that did not pass, and can post one review on the pull request.
It runs on Linux x86-64 runners (GitHub-hosted ubuntu-* or self-hosted). The steps use sh, curl,
tar and sha256sum; the pull request review and the annotations also use jq and curl, which
GitHub-hosted runners include.
name: CircuitTwin tests
on:
push:
pull_request:
permissions:
contents: read
pull-requests: write # only for comment-on-pr
jobs:
circuittwin:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Build firmware
run: make firmware # writes build/firmware.elf
- uses: OWNER/REPO/integrations/github-action@REF # pin to a tag or a commit
with:
suite: ct/suite.yaml
token: ${{ secrets.CIRCUITTWIN_TOKEN }}
ct-release: 0.1.0-287d49a4a6b9 # optional; blank uses latest/manifest.json
ct-version: 0.1.0
comment-on-pr: 'true'A copy-paste version that passes actionlint is in ../examples/github-workflow.yml.
The example suite is ../examples/ct/suite.yaml.
CIRCUITTWIN_TOKEN: a CircuitTwin access token (ctk_...). Create it in Settings of the
CircuitTwin organization whose boards the suite uses, with the scopes runs (firmware upload) and
suites (submit and read suites). Add it under the repository's Settings, Secrets and variables,
Actions. The action passes it to ct in the environment; it is never put on a command line or printed.
Secrets are not available to workflows triggered by pull requests from forks: the action skips those
(see skip-forks).
| Input | Required | Default | Meaning |
|---|---|---|---|
suite |
one of suite / matrix |
Suite file to run, or several files, one per line. Firmware paths in a suite are relative to the suite file. | |
matrix |
one of suite / matrix |
Test-matrix file (ct.test-matrix/1), or several, one per line. See Test matrices below. |
|
token |
yes | CircuitTwin access token. Pass a secret. | |
server |
no | https://app.circuittwin.ai |
Server origin. HTTP is accepted only for a loopback address. |
ct-release |
no | (latest) | Release id from https://circuittwindownloads.blob.core.windows.net/cli (for example 0.1.0-287d49a4a6b9). When ct-url and ct-path are empty, blank installs the latest published release from latest/manifest.json and checks the archive SHA-256 against the manifest. |
ct-version |
no | Version ct --version must report; any other version fails the job. |
|
ct-url |
no | Optional https URL of a pinned ct Linux download (a .tar.gz holding ct, or the binary). Overrides the official downloads manifest. |
|
ct-sha256 |
with ct-url |
SHA-256 of that download. Required with ct-url; optional with ct-release / latest (enforced if set). A different file is refused before it is extracted. |
|
ct-path |
no | An already-installed ct to use instead of a download. |
|
cosign-public-key |
no | Release public key (PEM text). When set, the download must also verify against its cosign bundle. | |
ct-signature-url |
no | ct-url + .sigstore.json |
Where the cosign bundle is. |
allow-insecure-http |
no | false |
Permit an http ct-url (a mirror on a private network). The checksum still applies. |
timeout-seconds |
no | 1800 |
Wait bound per suite. On timeout the suite's queued cases are cancelled and the job fails. |
comment-on-pr |
no | false |
Post one review on the pull request with the report (event COMMENT), replacing the previous run's. Needs pull-requests: write. Not posted for forks. |
github-token |
no | github.token |
Used only for that review. |
baseline |
no | auto |
auto: a pull request is compared with the newest completed suite on its base branch; none: never; or a suite id or latest-on-ref:REF. |
ref |
no | Git ref recorded on each suite. Empty: the workflow run's ref name. | |
skip-forks |
no | true |
Skip pull requests from forks with a notice instead of failing on the missing token. |
results-dir |
no | circuittwin-results |
Where results are written. |
upload-artifacts |
no | true |
Upload the results directory. |
artifact-name |
no | circuittwin-test-results |
Name of the artifact. |
unmodelled-policy |
no | allow or behavioural: list the accesses the twin does not model (top 10 by count) in the summary and comment. strict: also fail the job when any is listed. Empty: list them, no gate. Each case's own verdict policy is the suite's limits.unmodelled. Needs jq. |
|
coverage-format |
no | lcov or cobertura: run ct compliance coverage on each matrix result, keep the files in the results artifact and show the line percentage. Provisional. Empty: no coverage. |
JUnit XML is always written (<results-dir>/<n>-<name>/junit.xml) and uploaded; there is no input to
switch it off. The summary and comment gain an "Unmodelled accesses" table, a "Coverage" line and a
"Timing band" line only when the reports hold that data. The optional sections are produced by
scripts/report-extras.sh.
| Output | Meaning |
|---|---|
result |
passed, failed (a case did not pass or regressed), error (the suite could not run) or skipped (a pull request from a fork). |
coverage-percent |
Line coverage percentage (lcov LF/LH, or the Cobertura line-rate), empty without coverage. |
unmodelled-accesses |
Distinct unmodelled register or address entries found in the reports. |
exit-code |
0 every case passed (and nothing regressed), 1 a case failed, errored, was inconclusive or regressed, 2 invalid suite or credentials, 3 service error or timeout. |
results-dir |
The results directory. |
suite-url |
Link to the last suite in the CircuitTwin app. |
regressions |
Cases that passed in the baseline and do not pass now (needs jq). |
For each suite N named NAME, circuittwin-results/N-NAME/ holds junit.xml, report.json
(the ct.suite-report/1 document), summary.md and result.json (what ct printed, including the
link to the app, which opens its Runs page). circuittwin-results/summary.md joins the summaries. The same table
goes to the job summary.
source.txt (the suite file) is written beside them; scripts/annotate.sh uses it to print one
::error file=...,line=... annotation per case that did not pass (at the line of its id:, at most 10
per step), marking a regression against the baseline in the title.
With comment-on-pr: 'true' on a pull_request run, scripts/review-pr.sh posts the report as ONE
review per run (POST /repos/{owner}/{repo}/pulls/{n}/reviews, event COMMENT, never an approval and
never a change request) with the workflow's GITHUB_TOKEN, then supersedes the review the previous run
posted (found by the <!-- circuittwin-ci-report --> marker and a bot author): its body is replaced
by a one-line note, or, when that edit is refused, it is minimized as outdated. A failed call is a
warning, never a change of the verdict.
Needs permissions: pull-requests: write on the job, nothing else. Pull requests from forks are skipped
with a notice (no secrets, read-only token): the Check the pull request step sets result to skipped.
baseline: auto compares a pull request with the newest completed suite recorded on its base branch
(--baseline latest-on-ref:BASE; the suite records the workflow's ref name, or ref), so also run
the workflow on pushes to the base branch. The report then has a Regressions table and the job fails on a
regression. When the base branch has no completed suite yet, the suite runs once without a baseline
and the report says so.
To see what would be sent without a repository: CT_DRY_RUN=1 PR_NUMBER=7 GITHUB_REPOSITORY=o/r SUMMARY_FILE=circuittwin-results/summary.md sh scripts/review-pr.sh prints each request (stderr) and
sends nothing; CT_DRY_RUN_REVIEWS=reviews.json supplies the existing reviews.
matrix: runs ct.test-matrix/1 files (ADR-0181) on the server with ct test matrix run --cloud:
firmware versions × boards × fault sets × seeds, each distinct cell once, failures grouped by
cause. Give it alone or beside suite:.
- uses: CircuitTwin/action@v1
with:
matrix: ct/power-monitor.matrix.yaml
token: ${{ secrets.CIRCUITTWIN_TOKEN }}
ct-release: 0.1.0-287d49a4a6b9
# Optional: show the failure groups in code scanning (needs security-events: write).
- uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: circuittwin-resultsEach matrix writes junit.xml, report.sarif, report.json, evidence.json and summary.md
(the board × fault-set grid and the failure groups) under results-dir. The exit code follows the
CLI: 1 when a cell failed, errored, was inconclusive, unsupported or not run.
Every matrix counts against the workspace's weekly allowance of test runs (by plan, Monday 00:00
UTC; ADR-0181 decision 8). Cells answered from earlier results do not count. A matrix that needs
more test runs than are left is refused before anything runs: the step fails with the reason in its
log (429 matrix_allowance, for example "This matrix needs 340 test runs; your plan has 120 left
this week"). ct test matrix status <id> --server URL prints what is left.
Publishing: the matrix input is in this repository's copy; the published CircuitTwin/action
gets it with the next tagged release of the action (a separate step).
The action never runs a ct it has not checked. By default it downloads the signed Linux release
manifest from https://circuittwindownloads.blob.core.windows.net/cli/latest/manifest.json (or
releases/<ct-release>/manifest.json when ct-release is set), fetches the archive for the runner's
architecture (x86_64 or aarch64), and verifies its SHA-256 against the manifest before
extracting. For strict supply-chain pinning, pass ct-release with ct-sha256 (or an explicit
ct-url and ct-sha256), and set cosign-public-key to verify the Sigstore bundles with cosign
3.1.3 (itself checked against a pinned digest). You can also build or bake ct into the runner and
pass ct-path.