Skip to content

test: narrow the runner-shape guards to runs-on values and local steps - #37

Merged
cristiangirlea merged 2 commits into
mainfrom
test/narrow-runner-guards
Oct 15, 2026
Merged

cristiangirlea merged 2 commits into
mainfrom
test/narrow-runner-guards

Conversation

@cristiangirlea

Copy link
Copy Markdown
Owner

Why

The runner-shape guards in tests/python/test_workflows.py were broader than the rule they hold (closes #22): a regex for self-hosted over the whole file failed on a harmless comment, and an assertion that no .github/actions directory exists failed on a checkout with untracked leftovers.

What changed

  • tests/python/test_workflows.py: the self-hosted check reads only runs-on lines, and compares every runs-on line in the file with runs-on: ubuntu-latest, so a block form or a job the parser skipped cannot hide a label. The local-action check reads the steps of each job for a uses: of a ./ path, with or without the leading dash (a step whose first key is name:) and with or without quotes, instead of checking that a directory is absent.

Tests run

  • docker compose -f docker/compose.yaml run --rm --no-deps python-tests: passes on both commits.
  • Red check by hand on tests.yml, both commits: fails for runs-on: self-hosted, a block-form self-hosted list, a first job with a commented header and a block-form list, - uses: ./..., name: then uses: ./..., a double-quoted path, and extra spaces with a single-quoted path; passes unchanged and when a comment says "self-hosted".

Review

Independent review of the first commit. Blocking: a step written as name: then uses: loses its dash once the parser strips the line, so the local-action check missed it, and a quoted path too; fixed in the second commit, which also folds in the reviewer's hardening of the runs-on check (every line file-wide, independent of the parser). Non-blocking, filed as #36: the job parser drops header lines it does not recognise without failing.

The guard against a self-hosted runner read the whole workflow text, so
a comment saying "self-hosted" failed it; it now reads only runs-on
values. The guard against the Compose install action checked that no
.github/actions directory exists, which also failed on a checkout with
leftover untracked files; it now checks that no step uses a local path.
The review found that a step written as name: then uses: loses its dash
once the parser strips the line, so the local-action check missed it,
as it missed a quoted path. The runs-on check now compares every
runs-on line in the file with the expected value, so a block form or a
job the parser skipped cannot hide a self-hosted label.
@cristiangirlea
cristiangirlea merged commit 80cb8eb into main Oct 15, 2026
6 checks passed
@cristiangirlea
cristiangirlea deleted the test/narrow-runner-guards branch October 15, 2026 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: narrow the runner-shape guards in test_workflows.py

1 participant