chore: The checker does not validate templates/, only actions #43
Labels
No labels
priority/P0
priority/P1
priority/P2
priority/P3
size/L
size/M
size/S
size/XL
size/XS
state/done
state/in-progress
state/in-review
state/needs-refinement
state/ready
type/bug
type/chore
type/feature
type/refactor
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
amtronics/platform-actions#43
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
.forgejo/scripts/check-actions.pywalks*/action.ymland validates each composite action:the fields it needs, and
bash -nover everyrun:body with${{ }}expressions replaced.templates/release.ymlis not an action, so none of it is checked — not the YAML, not theshell.
That is the wrong file to leave unvalidated. An action is used through a moving
v3tag, soa mistake in one is caught the first time any pipeline runs it. A template is copied: a
broken
run:body is duplicated into an application repository, possibly several, beforeanything executes it, and each copy then has to be fixed separately. The blast radius is
larger and the feedback is later.
Found while adding a
docker loginstep to the template (#37, PR #41). Its shell was correct,but only because it was checked by hand with the checker's own technique — 7 run steps,
0 invalid. Nothing in CI would have objected to a missing
fi.Scope
run:bodies of files undertemplates/.themselves, which are already covered.
Acceptance criteria
run:body, when the checker runs, then it fails and names the file, the job and the step.Notes
The workflow shape differs from an action's:
jobs.<id>.steps[]rather thanruns.steps[], and a template legitimately contains<PLACEHOLDER>text that is not validanything. The expression substitution the checker already applies handles
${{ }}, but a bare<OWNER>/<APP>inside arun:body would need the same treatment or an explicit exemption —worth checking whether any current template has one before choosing which.
Keep it in the same checker rather than a second script. Two scripts that both nearly validate
workflows is how the copies in this repository drifted in the first place.
Taking this. Two files:
check-actions.pygains template checking, andtest-check-actions.pygains the cases for it.A workflow is not an action, so the existing walk does not transfer. An action's bodies live at
runs.steps[]; a workflow's atjobs.<id>.steps[]. The expression substitution andbash -nare identical, so those are reused rather than reimplemented — what is new is the traversal and the reporting, which must name the job as well as the step, since a template has several jobs and "step 3" alone would not locate it.The placeholder question this issue raised, answered by measuring. I worried a bare
<OWNER>/<APP>inside arun:body would need substituting or exempting. There are none:templates/release.ymlhas 7 run bodies and every placeholder in the file sits inuses:,with:orenv:values, which are not shell. So no exemption today — but the checker should fail loudly rather than mysteriously if one appears, andbash -non<OWNER>reports a syntax error naming the line, which is the right behaviour.One detail the test fixtures force.
main()exits 1 with "No action.yml found" when the tree has none, so a temp tree containing only a template would fail for the wrong reason and a case asserting on the exit code would pass while testing nothing. Each template fixture gets a validaction.ymlalongside it, so the exit code reflects the template alone.Verification. The four criteria as cases in the committed suite — that is what the fourth asks for, and unlike the last three changes here it will run again. Each case written so it fails against the unfixed checker first: a suite that only ever ran against the fixed version would record four passes and prove nothing, which is the defect this repository keeps producing.