Repository navigation
feat: keep the organisation's labels in a file - #61
Conversation
Add labels/labels.yml (the label set, temporary ecp-wp4 labels and the repositories to sync) and labels/sync.sh, which creates missing labels and aligns colours and descriptions with gh, never deletes, and reports labels beyond the file. Tested with a stubbed gh in CI; documented in the README. Closes #60 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideData structuresDefine the shared and temporary label data and the default repository set that the sync script consumes.
ImplementationAdd the script that checks and synchronizes repository labels from the shared definition without deleting unlisted labels.
UIAssign the triage status label by default on each issue form.
ConfigurationRun the label validation and synchronization tests in the CI test job.
DocumentationDocument the label source of truth, synchronization workflow, and label-handling guidance for maintainers.
TestsValidate the label definition and exercise sync, check-only, default-repository, and failure behavior using a stubbed GitHub CLI.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 7 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="labels/sync.sh" line_range="78-79" />
<code_context>
+ while IFS=$'\t' read -r name _; do
+ [[ -z "$name" ]] && continue
+ if ! printf '%s\n' "${WANTED[@]}" | cut -f1 | grep -Fx -- "$name" >/dev/null; then
+ echo "$repo: unlisted '$name' (not changed)"
+ fi
+ done <<<"$current"
+done
</code_context>
<issue_to_address>
**Drift checks exit successfully**
When a repository has unlisted labels but all configured labels match, the unlisted-label branch prints the extra labels without incrementing `differences`, so the final `--check` condition exits 0 despite the reported drift.
Increment `differences` when an unlisted label is found.
</issue_to_address>
### Comment 2
<location path="labels/labels.yml" line_range="87" />
<code_context>
+ - name: 'priority: medium'
+ color: "7213b2"
+ description: Medium priority
+ - name: 'status: abandoned'
+ color: "d32869"
+ description: This will not be worked on
</code_context>
<issue_to_address>
**New issues miss status labels**
When a user submits an issue form in a repository synced from this file, `labels/sync.sh` builds its wanted set from `labels` and `temporary`, which omit `status: new`, so it never creates that label; new issues miss their configured initial status, and the label is reported as unlisted when present.
Add `status: new` to the managed labels.
Also at `labels/labels.yml:99-100`.
</issue_to_address>
### Comment 3
<location path="labels/sync.sh" line_range="43-44" />
<code_context>
+fi
+
+if $ALL; then
+ mapfile -t REPOS < <(gh repo list "$ORG" --limit 1000 --no-archived --source \
+ --json name --jq '.[].name' | sort)
+elif ((${#REPOS[@]} == 0)); then
+ mapfile -t REPOS < <(yq '.repositories // [] | .[]' "$FILE")
</code_context>
<issue_to_address>
**Later repositories remain unsynced**
When the organisation has more than 1,000 eligible repositories visible to `gh`, `gh repo list --limit 1000` returns at most 1,000 repositories, so `--all` skips the rest and reports success after syncing only the returned subset.
Enumerate all eligible repositories instead of limiting the list to 1,000.
</issue_to_address>
### Comment 4
<location path="labels/sync.sh" line_range="35-36" />
<code_context>
+done
+
+# Wanted labels as "name<TAB>color<TAB>description", from both lists
+mapfile -t WANTED < <(yq -o=json '(.labels // []) + (.temporary // [])' "$FILE" \
+ | jq -r '.[] | [.name, (.color | ascii_downcase), (.description // "")] | @tsv')
+if ((${#WANTED[@]} == 0)); then
+ echo "no labels in $FILE" >&2
</code_context>
<issue_to_address>
**Partial input is treated as complete**
When a `yq`, `jq`, or `gh repo list` producer emits some output and then exits nonzero, `mapfile` does not check the process-substitution producer's exit status, so a partial label or repository list is processed as complete and the script can report success with labels or repositories unsynced.
Capture and check each producer's exit status before using the resulting arrays.
Also at `labels/sync.sh:43-44`.
</issue_to_address>
### Comment 5
<location path="labels/sync.sh" line_range="43-44" />
<code_context>
+fi
+
+if $ALL; then
+ mapfile -t REPOS < <(gh repo list "$ORG" --limit 1000 --no-archived --source \
+ --json name --jq '.[].name' | sort)
+elif ((${#REPOS[@]} == 0)); then
+ mapfile -t REPOS < <(yq '.repositories // [] | .[]' "$FILE")
</code_context>
<issue_to_address>
**Include every repository**
The issue asks for --all to cover every repository of the organisation. This query excludes archived repositories and forks, so those repositories are not covered.
</issue_to_address>
### Comment 6
<location path="labels/sync.sh" line_range="70-71" />
<code_context>
+ echo "$repo: differs '$name'"
+ fi
+ if ! $CHECK; then
+ gh label create "$name" --repo "$ORG/$repo" --color "$color" \
+ --description "$description" --force >/dev/null
+ fi
+ done
</code_context>
<issue_to_address>
**Older sync overwrites newer labels**
When two maintainers run the script from different revisions and the older run writes after the newer run, `gh label create --force` applies each run's values without checking whether its source file is stale, so an older run can overwrite values from a newer run and leave the repository inconsistent with the current label file even though both runs succeed.
Reject runs based on an outdated source revision and coordinate concurrent syncs so older definitions cannot be applied last.
</issue_to_address>
### Comment 7
<location path="tests/labels/test.sh" line_range="49" />
<code_context>
+ "label list")
+ printf '%s\t%s\t%s\n' "type: bug" "0075ca" "Something isn't working" \
+ "type: docs" "ffffff" "Docs" "python" "2b67c6" "" ;;
+ "label create") printf '%s\n' "$*" >>"$GH_LOG" ;;
+ *) echo "unexpected: $*" >&2; exit 3 ;;
+esac
</code_context>
<issue_to_address>
**Updates can fail unnoticed**
When `labels/sync.sh` stops passing `--force` when creating a label that already exists, the `sync` test in `tests/labels/test.sh` still passes if an update to the existing `type: docs` label omits `--force`: the stub at line 49 records any `gh label create` arguments, and lines 72–76 do not check for that flag. Real `gh` then refuses to update the label, so synchronization fails despite CI passing.
Assert that the recorded update command for `type: docs` includes `--force`.
</issue_to_address>Linked issues
#60 feat: keep the organisation's labels in one file · 3 of 5 met · 1 to check by hand
| # | Requirement | Status | Notes |
|---|---|---|---|
| 1 | Keep the 36 shared labels, 12 temporary labels, and 15 default repositories in labels/labels.yml. | ✅ Met | |
| 2 | Create missing labels, align colours and descriptions, never delete labels, and report labels beyond the file. | ✅ Met | |
| 3 | Provide --check for report-only mode and --all for every repository of the organisation. | 🟡 Partly met | --check is implemented, but --all excludes archived repositories and forks. |
| 4 | Put the file and script in main, test them in CI, and document them. | ✅ Met | The file and script are added, the label tests are wired into CI, and the README documents the workflow. |
| 5 | Have --check report no differences for the 15 repositories. | 👀 Check by hand (external system) | Run labels/sync.sh --check against the organisation's 15 maintained repositories and verify it reports no differences. |
Sourcery assessment
Needs a human reviewer. 7 findings to address first, and the sync can create labels and change existing labels’ colours and descriptions across the selected repositories. Those changes persist after reverting the code; correcting them requires another sync, and any labels created by mistake may need manual cleanup, but the script does not delete labels or change issue assignments.
Blocking findings: labels/sync.sh:79, labels/labels.yml:87, labels/sync.sh:44, labels/sync.sh:36, labels/sync.sh:44, and 2 more
Issue forms assign status: triage (status: new was renamed). --check also fails on unlisted labels; failing yq, jq or gh stop the script instead of leaving partial lists; --all lists up to 10000 repositories; the test checks that updates pass --force. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
Keeps the organisation's labels in one reviewed file and adds a script that syncs them to the repositories.
labels/labels.yml:labels: the 36 labels, matching the organisation's default repository labels;temporary: the 12ecp-wp4:milestones and deliverables;repositories: the 15 maintained repositories.labels/sync.sh:--checkreports only (exit status 1 on differences),--allcovers every repository of the organisation.tests/labels/test.sh, run in CI'sTestjob: checks that the file is well-formed and runs the script against a stubbedgh..github/ISSUE_TEMPLATE/): they assignstatus: triage, asstatus: newwas renamed org-wide.Closes #60
Verification
bash tests/labels/test.sh: all six checks pass (file,--check, sync, default repositories, unlisted labels, failing producers).--all-files(shellcheck, actionlint, markdownlint, schemas): passed locally. gitleaks didn't build locally, so it only runs in CI.type: dependenciesandflag: nice to have. A second run with--checkthen reported no differences and no unlisted labels. After the review fixes,labels/sync.sh --check(default repositories) exits 0.Declined review findings
mainrepairs any stale write, so locking isn't worth it.Lane
Light lane: a maintenance script with tests and docs, with no change to secrets, permissions or the release workflow. I reviewed the diff myself.
🤖 Generated with Claude Code