Skip to content

Commit 30689f8

Browse files
committed
fix(ci): map the recurring unmapped scopes and add area/dx
Over the full PR history a set of scopes recurring three or more times still fell through to area/uncategorized. Most of them have an obvious home and were only missing a row. Subsystem names such as `networking` or `storage` are now accepted as the scope of their own area, since contributors reach for those as often as for a package name. `dx`, `hack` and `cozypkg` describe developer tooling, which no existing area covers: area/build is image builds, area/testing is tests. They get a new area/dx rather than being filed under either. The contract test also pins that every map target exists in labels.yml, since the label sync workflow creates only what that file defines, and that no key is written twice, since a repeated key silently overrides the earlier one. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <[email protected]>
1 parent a8c3eb5 commit 30689f8

3 files changed

Lines changed: 131 additions & 0 deletions

File tree

‎.github/labels.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,10 @@
190190
color: 'bfd4f2'
191191
description: Dependency bumps (Renovate, go.mod); scope `deps`
192192

193+
- name: area/dx
194+
color: 'bfd4f2'
195+
description: Issues or PRs related to developer tooling (hack/ scripts, package Makefiles, cozypkg)
196+
193197
- name: area/dashboard
194198
color: 'bfd4f2'
195199
description: Issues or PRs related to the dashboard / UI

‎.github/workflows/pr-labeler.yaml‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ jobs:
4141
// area/api
4242
'api': 'area/api',
4343
'cozystack-api': 'area/api',
44+
'registry': 'area/api',
4445
4546
// area/ai
4647
'agents': 'area/ai',
@@ -51,14 +52,24 @@ jobs:
5152
5253
// area/ci
5354
'ci': 'area/ci',
55+
'workflows': 'area/ci',
56+
'labeler': 'area/ci',
5457
5558
// area/dependencies — Renovate uses scope `deps` (see .github/renovate.json)
5659
'deps': 'area/dependencies',
60+
'dependencies': 'area/dependencies',
61+
'renovate': 'area/dependencies',
62+
63+
// area/dx — developer tooling: hack/, package Makefiles, cozypkg
64+
'dx': 'area/dx',
65+
'hack': 'area/dx',
66+
'cozypkg': 'area/dx',
5767
5868
// area/dashboard
5969
'dashboard': 'area/dashboard',
6070
'cozystack-ui': 'area/dashboard',
6171
'console': 'area/dashboard',
72+
'dashboard-controller': 'area/dashboard',
6273
6374
// area/database
6475
'postgres': 'area/database',
@@ -75,6 +86,10 @@ jobs:
7586
'nats': 'area/database',
7687
'qdrant': 'area/database',
7788
'foundationdb': 'area/database',
89+
'database': 'area/database',
90+
'etcd-operator': 'area/database',
91+
'opensearch': 'area/database',
92+
'opensearch-operator': 'area/database',
7893
7994
// area/extra
8095
'extra': 'area/extra',
@@ -84,6 +99,7 @@ jobs:
8499
85100
// area/keycloak
86101
'keycloak': 'area/keycloak',
102+
'keycloak-configure': 'area/keycloak',
87103
88104
// area/kubernetes
89105
'kubernetes': 'area/kubernetes',
@@ -97,6 +113,7 @@ jobs:
97113
'vmstack': 'area/monitoring',
98114
'grafana': 'area/monitoring',
99115
'workloadmonitor': 'area/monitoring',
116+
'monitoring-agents': 'area/monitoring',
100117
101118
// area/networking
102119
'ingress': 'area/networking',
@@ -110,6 +127,12 @@ jobs:
110127
'tcp-balancer': 'area/networking',
111128
'securitygroups': 'area/networking',
112129
'cozy-proxy': 'area/networking',
130+
'networking': 'area/networking',
131+
'kubeovn': 'area/networking',
132+
'multus': 'area/networking',
133+
'kilo': 'area/networking',
134+
'hetzner-robotlb': 'area/networking',
135+
'ouroboros': 'area/networking',
113136
114137
// area/cilium
115138
'cilium': 'area/cilium',
@@ -131,10 +154,24 @@ jobs:
131154
'cozyctl': 'area/platform',
132155
'cozystack-engine': 'area/platform',
133156
'cozy-lib': 'area/platform',
157+
'operator': 'area/platform',
158+
'cozystack-operator': 'area/platform',
159+
'controller': 'area/platform',
160+
'cozystack-controller': 'area/platform',
161+
'cozystack-basics': 'area/platform',
162+
'flux-shard-operator': 'area/platform',
163+
'lineage': 'area/platform',
164+
'migrations': 'area/platform',
165+
'scheduler': 'area/platform',
166+
'cozystack-scheduler': 'area/platform',
167+
'reloader': 'area/platform',
168+
'bootbox': 'area/platform',
134169
135170
// area/release
136171
'backport': 'area/release',
137172
'release': 'area/release',
173+
'changelog': 'area/release',
174+
'changelogs': 'area/release',
138175
139176
// area/storage
140177
'seaweedfs': 'area/storage',
@@ -146,13 +183,17 @@ jobs:
146183
'harbor': 'area/storage',
147184
'backups': 'area/storage',
148185
'csi': 'area/storage',
186+
'storage': 'area/storage',
187+
'piraeus-operator': 'area/storage',
188+
'backupstrategy-controller': 'area/storage',
149189
150190
// area/tenant
151191
'tenant': 'area/tenant',
152192
153193
// area/testing
154194
'tests': 'area/testing',
155195
'e2e': 'area/testing',
196+
'testing': 'area/testing',
156197
157198
// area/virtualization
158199
'kubevirt': 'area/virtualization',
@@ -165,6 +206,11 @@ jobs:
165206
'virtual-machine': 'area/virtualization',
166207
'hami': 'area/virtualization',
167208
'gpu-operator': 'area/virtualization',
209+
'virtualization': 'area/virtualization',
210+
'vm': 'area/virtualization',
211+
'kubevirt-operator': 'area/virtualization',
212+
'kubevirt-cdi': 'area/virtualization',
213+
'kubevirt-instancetypes': 'area/virtualization',
168214
};
169215
170216
const pr = context.payload.pull_request;

‎hack/pr-labeler-contract.bats‎

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
REPO_ROOT="$(cd "$(dirname "${BATS_TEST_FILENAME:-$0}")/.." && pwd)"
1515
WF="$REPO_ROOT/.github/workflows/pr-labeler.yaml"
16+
LABELS="$REPO_ROOT/.github/labels.yml"
1617

1718
need_node() {
1819
command -v node >/dev/null 2>&1 && return 0
@@ -77,8 +78,37 @@ expect_labels() {
7778
}
7879
}
7980

81+
# The scopeToArea literal as JSON pairs, plus a count of the key lines in the
82+
# source, quoted either way or bare. A duplicate key collapses when the literal
83+
# is evaluated, so the two disagree when a key is written twice, as long as each
84+
# key sits on its own line.
85+
scope_map() { # json|keylines
86+
tmp="$(mktemp -d)"
87+
extract_script "$tmp/script.js"
88+
cat > "$tmp/map.js" <<'JS'
89+
const fs = require('fs');
90+
const src = fs.readFileSync(process.argv[2], 'utf8');
91+
const m = src.match(/const scopeToArea = (\{[\s\S]*?\n\};)/);
92+
if (!m) { throw new Error('scopeToArea literal not found'); }
93+
const lines = m[1].split('\n').filter((l) => /^\s*(['"]?)[^'"\s:]+\1\s*:/.test(l));
94+
const map = new Function('return ' + m[1].replace(/;$/, ''))();
95+
if (process.argv[3] === 'keylines') {
96+
fs.writeFileSync(1, lines.length + ' ' + Object.keys(map).length + '\n');
97+
} else {
98+
fs.writeFileSync(1, Object.entries(map).map(([k, v]) => k + '\t' + v).join('\n') + '\n');
99+
}
100+
JS
101+
node "$tmp/map.js" "$tmp/script.js" "$1"
102+
rm -rf "$tmp"
103+
}
104+
105+
area_labels() {
106+
sed -n 's/^- name: \(area\/[^[:space:]]*\)[[:space:]]*$/\1/p' "$LABELS"
107+
}
108+
80109
@test "the workflow under contract exists" {
81110
[ -f "$WF" ]
111+
[ -f "$LABELS" ]
82112
}
83113

84114
# A key inherited from Object.prototype resolves to a function, which is truthy,
@@ -116,3 +146,54 @@ just a sentence area/uncategorized
116146
EOF
117147
}
118148

149+
@test "recurring scopes resolve to their area" {
150+
need_node
151+
expect_labels <<'EOF'
152+
fix(etcd-operator): x area/database,kind/bug
153+
fix(opensearch): x area/database,kind/bug
154+
fix(multus): x area/networking,kind/bug
155+
fix(kubeovn): x area/networking,kind/bug
156+
fix(kubevirt-operator): x area/virtualization,kind/bug
157+
fix(keycloak-configure): x area/keycloak,kind/bug
158+
docs(changelog): x area/release,kind/documentation
159+
fix(lineage): x area/platform,kind/bug
160+
fix(piraeus-operator): x area/storage,kind/bug
161+
fix(monitoring-agents): x area/monitoring,kind/bug
162+
ci(workflows): x area/ci
163+
fix(hack): x area/dx,kind/bug
164+
EOF
165+
}
166+
167+
# Contributors reach for the subsystem name as often as for a package name, so
168+
# every area is reachable by its own name.
169+
@test "every area label is accepted as a scope that maps to itself" {
170+
need_node
171+
map="$(scope_map json)"
172+
missing=""
173+
for a in $(area_labels); do
174+
[ "$a" = "area/uncategorized" ] && continue
175+
printf '%s\n' "$map" | grep -qxF "${a#area/} $a" || missing="$missing ${a#area/}"
176+
done
177+
[ -z "$missing" ] || { echo "scopes missing for their own area:$missing" >&2; return 1; }
178+
}
179+
180+
# A target missing from labels.yml is a label the sync workflow never creates,
181+
# and nothing in a run of the labeler reports it.
182+
@test "every scopeToArea target is an area label defined in labels.yml" {
183+
need_node
184+
defined="$(area_labels)"
185+
[ -n "$defined" ]
186+
bad="$(scope_map json | cut -f2 | sort -u | grep -vxF "$defined" || true)"
187+
[ -z "$bad" ] || { echo "targets not in labels.yml: $bad" >&2; return 1; }
188+
}
189+
190+
# A repeated key silently overrides the earlier value and reads as an ordinary
191+
# added line in review.
192+
@test "no scope key appears twice in scopeToArea" {
193+
need_node
194+
read -r lines keys <<EOF
195+
$(scope_map keylines)
196+
EOF
197+
[ "$lines" -gt 0 ]
198+
[ "$lines" = "$keys" ] || { echo "$lines key lines but $keys distinct keys" >&2; return 1; }
199+
}

0 commit comments

Comments
 (0)