Repository navigation
fix(ci): create workflow labels idempotently instead of searching first - #431
Conversation
The reconciler's validation step looked a label up with `gh label list --search` and created it when the search found nothing. GitHub's label search is not always consistent, so on 2026-12-04 it missed an existing label, `gh label create` failed with "already exists", and the whole scheduled run failed before it compared anything. Create each label with `--force`, which creates or updates it, in the reconciler's two label helpers and the weekly header check, and pin that with a test over every workflow. Assisted-by: AI
Jesswinters
left a comment
There was a problem hiding this comment.
LGTM. I found no P0 or P1 problems. gh label create --force creates the label or updates it, so it removes the list-then-create race in all three places it occurred. The new test guards against the pattern coming back. actionlint, lint & typecheck, and the @coder/docs-site tests pass. axe accessibility pass was still running and deploy preview was waiting when I approved.
Optional nits:
- Header comment is now slightly stale.
.github/workflows/reconcile-versions.ymllines 35-36 say the label "is created when it is absent". It is now created or updated on every run. Something like "created, or its colour and description reset, on every run" would match the new behavior. --forcereverts manual label edits. Anyone who changes the colour or description ofdocs-archive-drift,code-server-pin-behind, orsecurity-header-driftin the GitHub UI will see the change undone on the next run. That is fine, but a short comment byensure_label("the workflow owns these labels' colour and description") would save someone a confusing moment.- The test reads one line at a time. In
apps/docs/scripts/workflow-labels.test.mjs:- Line 22: a
gh label createthat is split with\and has--forceon the next line fails the test even though it is correct. This fails safe, so it only matters if someone wraps the command. - Line 29: it only catches
gh label list ... --searchon one line. A check such asgh label list | grep -qxwithout--searchis the same race and would pass. Matchinggh label listalone may be stricter than you want, so this is your call. - Line 7: it scans only
.github/workflows. If composite actions under.github/actionsever create labels, they are not covered.
- Line 22: a
- "daily" vs "twice a day". The label description and the file header say "daily reconciler", but the schedule runs at 06:17 and 12:17 UTC. Since
--forcenow rewrites the live description anyway, this is a good time to make it accurate if you care.
Coder Agents generated this review for @Jesswinters.
Update the reconcile workflow's header comment for labels that are created or reset on every run, note beside `ensure_label` that `--force` resets a label edited by hand, and call the reconciler "twice-daily" in the label description to match its 06:17 and 12:17 UTC schedule. Assisted-by: AI
|
Applied nits 1, 2 and 4 in 3052477: the header comment now says labels are created or reset on every run, a line by 🤖 Built with AI assistance. |
|
@Jesswinters thanks for the review. Here is what I did with each nit. Nits 1, 2 and 4 are in 3052477: the header comment now says labels are created or reset on every run, a line by I did not change the test for nit 3, for three reasons. The wrapped 🤖 Built with AI assistance. |
Docs preview deploymentRendered with docs-engine 352f389 from coder/coder at 2d87c26121435613bc421e4d18154ff83f43d3b9: https://coder-docs-m6qk5y92h.coderite.app The preview is behind Vercel authentication; sign in with your Coder Vercel account. |
Merge order
Independent of every other open PR.
Summary
The scheduled
reconcile-versionsrun at 12:28 UTC on 2026-12-04 failed in its "Validate the publishing configuration" step:label with name "docs-archive-drift" already exists; use --force to update its color and description. The step checks for each tracking label withgh label list --searchand creates it only when the search finds nothing. The label does exist (created 2026-09-21), and the same search returns it now, so the search missed it once. GitHub's search is not strongly consistent. The failed step stopped the run before it compared GitHub with the manifest, so that run reconciled nothing and the next scheduled run is the next chance, about 18 hours later at twice a day.Fix
Create each label with
gh label create ... --force, which creates it or updates its colour and description, and so cannot fail on a label that exists. This replaces the search-then-create check in the reconciler'sensure_labelandnote_onhelpers and in the weekly header check insecurity.yml, which had the same pattern.--forcealso rewrites the livedocs-archive-driftdescription from "hourly reconciler" to the text in the workflow ("twice-daily reconciler"), which is harmless.workflow-labels.test.mjsfails on any workflow that creates a label without--forceor searches for one before creating it. It fails onmainand passes here.QA
Nothing to see on the site. After this merges, the next
reconcile-versionsrun should pass its "Validate the publishing configuration" step: https://github.com/coder/docs-engine/actions/workflows/reconcile-versions.ymlPages to compare
Testing
node --test scripts/workflow-labels.test.mjs scripts/workflow-secrets.test.mjsinapps/docs: 13 pass. actionlint is not installed here, so CI's run is the check.Upstream
No. This is this repository's own workflow glue.
🤖 Built with AI assistance.