FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: exempt team members from compliance cleanup · litui/opencode@1268f86 · GitHub

Repository navigation

Commit 1268f86

Browse files
authored
fix: exempt team members from compliance cleanup
1 parent 39e7ff9 commit 1268f86

6 files changed

Lines changed: 56 additions & 31 deletions

File tree

‎.github/workflows/compliance-close.yml‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,25 @@ jobs:
3434
3535
const now = Date.now();
3636
const twoHours = 2 * 60 * 60 * 1000;
37+
const teamAssociations = ['OWNER', 'MEMBER', 'COLLABORATOR'];
3738
3839
for (const item of items) {
3940
const isPR = !!item.pull_request;
4041
const kind = isPR ? 'PR' : 'issue';
4142
43+
if (teamAssociations.includes(item.author_association)) {
44+
core.info(`Skipping ${kind} #${item.number}: author association is ${item.author_association}`);
45+
try {
46+
await github.rest.issues.removeLabel({
47+
owner: context.repo.owner,
48+
repo: context.repo.repo,
49+
issue_number: item.number,
50+
name: 'needs:compliance',
51+
});
52+
} catch (e) {}
53+
continue;
54+
}
55+
4256
const { data: comments } = await github.rest.issues.listComments({
4357
owner: context.repo.owner,
4458
repo: context.repo.repo,

‎.github/workflows/duplicate-issues.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66

77
jobs:
88
check-duplicates:
9-
if: github.event.action == 'opened'
9+
if: github.event.action == 'opened' && !contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.issue.author_association)
1010
runs-on: blacksmith-4vcpu-ubuntu-2404
1111
permissions:
1212
contents: read
@@ -118,7 +118,7 @@ jobs:
118118
Remember: post at most ONE comment combining all findings. If everything is fine, post nothing."
119119
120120
recheck-compliance:
121-
if: github.event.action == 'edited' && contains(github.event.issue.labels.*.name, 'needs:compliance')
121+
if: github.event.action == 'edited' && contains(github.event.issue.labels.*.name, 'needs:compliance') && !contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.issue.author_association)
122122
runs-on: blacksmith-4vcpu-ubuntu-2404
123123
permissions:
124124
contents: read

‎.github/workflows/pr-management.yml‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,25 @@ jobs:
1111
contents: read
1212
pull-requests: write
1313
steps:
14-
- name: Checkout repository
15-
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
16-
with:
17-
fetch-depth: 1
18-
1914
- name: Check team membership
2015
id: team-check
2116
run: |
2217
LOGIN="${{ github.event.pull_request.user.login }}"
23-
if [ "$LOGIN" = "opencode-agent[bot]" ] || grep -qxF "$LOGIN" .github/TEAM_MEMBERS; then
18+
ASSOCIATION="${{ github.event.pull_request.author_association }}"
19+
if [ "$LOGIN" = "opencode-agent[bot]" ] || [ "$ASSOCIATION" = "OWNER" ] || [ "$ASSOCIATION" = "MEMBER" ] || [ "$ASSOCIATION" = "COLLABORATOR" ]; then
2420
echo "is_team=true" >> "$GITHUB_OUTPUT"
2521
echo "Skipping: $LOGIN is a team member or bot"
2622
else
2723
echo "is_team=false" >> "$GITHUB_OUTPUT"
2824
fi
2925
26+
- name: Checkout repository
27+
if: steps.team-check.outputs.is_team != 'true'
28+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
29+
with:
30+
fetch-depth: 1
31+
ref: ${{ github.event.pull_request.base.sha }}
32+
3033
- name: Setup Bun
3134
if: steps.team-check.outputs.is_team != 'true'
3235
uses: ./.github/actions/setup-bun

‎.github/workflows/pr-standards.yml‎

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,9 @@ jobs:
2828
2929
// Check if author is a team member or bot
3030
if (login === 'opencode-agent[bot]') return;
31-
const { data: file } = await github.rest.repos.getContent({
32-
owner: context.repo.owner,
33-
repo: context.repo.repo,
34-
path: '.github/TEAM_MEMBERS',
35-
ref: 'dev'
36-
});
37-
const members = Buffer.from(file.content, 'base64').toString().split('\n').map(l => l.trim()).filter(Boolean);
38-
if (members.includes(login)) {
39-
console.log(`Skipping: ${login} is a team member`);
31+
const teamAssociations = ['OWNER', 'MEMBER', 'COLLABORATOR'];
32+
if (teamAssociations.includes(pr.author_association)) {
33+
console.log(`Skipping: ${login} has author association ${pr.author_association}`);
4034
return;
4135
}
4236
@@ -175,15 +169,9 @@ jobs:
175169
176170
// Check if author is a team member or bot
177171
if (login === 'opencode-agent[bot]') return;
178-
const { data: file } = await github.rest.repos.getContent({
179-
owner: context.repo.owner,
180-
repo: context.repo.repo,
181-
path: '.github/TEAM_MEMBERS',
182-
ref: 'dev'
183-
});
184-
const members = Buffer.from(file.content, 'base64').toString().split('\n').map(l => l.trim()).filter(Boolean);
185-
if (members.includes(login)) {
186-
console.log(`Skipping: ${login} is a team member`);
172+
const teamAssociations = ['OWNER', 'MEMBER', 'COLLABORATOR'];
173+
if (teamAssociations.includes(pr.author_association)) {
174+
console.log(`Skipping: ${login} has author association ${pr.author_association}`);
187175
return;
188176
}
189177

‎script/github/close-issues.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@ const cutoff = new Date(Date.now() - days * 24 * 60 * 60 * 1000)
1515
type Issue = {
1616
number: number
1717
updated_at: string
18+
author_association: string
1819
}
1920

21+
const teamAssociations = new Set(["OWNER", "MEMBER", "COLLABORATOR"])
22+
2023
const headers = {
2124
Authorization: `Bearer ${token}`,
2225
"Content-Type": "application/json",
@@ -63,6 +66,10 @@ async function main() {
6366
for (const i of all) {
6467
const updated = new Date(i.updated_at)
6568
if (updated < cutoff) {
69+
if (teamAssociations.has(i.author_association)) {
70+
console.log(`Skipping #${i.number}: author association is ${i.author_association}`)
71+
continue
72+
}
6673
stale.push(i.number)
6774
} else {
6875
console.log(`\nFound fresh issue #${i.number}, stopping`)

‎script/github/close-prs.ts‎

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ const maxClose =
6969
const sleepMs = requireNonNegativeInteger("sleep-ms", values["sleep-ms"])
7070
const printLimit = requireNonNegativeInteger("print-limit", values["print-limit"])
7171
const cutoff = subtractMonths(new Date(), ageMonths)
72+
const teamAssociations = new Set(["OWNER", "MEMBER", "COLLABORATOR"])
7273

7374
const headers = {
7475
Authorization: `Bearer ${token}`,
@@ -82,6 +83,7 @@ type PullRequest = {
8283
title: string
8384
url: string
8485
createdAt: string
86+
authorAssociation: string
8587
reactionGroups: Array<{
8688
content: string
8789
users: {
@@ -145,19 +147,25 @@ async function main() {
145147
console.log(`Threshold: fewer than ${threshold} positive reactions`)
146148

147149
const prs = await fetchOpenPullRequests()
148-
const recentCount = prs.filter((pr) => new Date(pr.createdAt) >= cutoff).length
149-
const matching = prs
150-
.map((pr) => ({ ...pr, positiveReactions: positiveReactionCount(pr) }))
151-
.filter((pr) => new Date(pr.createdAt) < cutoff && pr.positiveReactions < threshold)
150+
const scored = prs.map((pr) => ({ ...pr, positiveReactions: positiveReactionCount(pr) }))
151+
const recentCount = scored.filter((pr) => new Date(pr.createdAt) >= cutoff).length
152+
const teamCount = scored.filter((pr) => isTeamMember(pr)).length
153+
const matching = scored.filter(
154+
(pr) => !isTeamMember(pr) && new Date(pr.createdAt) < cutoff && pr.positiveReactions < threshold,
155+
)
152156
const candidates = matching.filter((pr) => !hasPriorCleanup(pr))
153157
const selected = maxClose === undefined ? candidates : candidates.slice(0, maxClose)
154158

155159
console.log(`Fetched ${prs.length} open PRs`)
156160
console.log(`Matching cleanup criteria: ${matching.length}`)
157161
console.log(`Skipped previously cleaned PRs: ${matching.length - candidates.length}`)
162+
console.log(`Team member PRs untouched: ${teamCount}`)
158163
console.log(`Recent PRs untouched: ${recentCount}`)
159164
console.log(
160-
`Older PRs with at least ${threshold} positive reactions untouched: ${prs.length - matching.length - recentCount}`,
165+
`Older PRs with at least ${threshold} positive reactions untouched: ${
166+
scored.filter((pr) => !isTeamMember(pr) && new Date(pr.createdAt) < cutoff && pr.positiveReactions >= threshold)
167+
.length
168+
}`,
161169
)
162170

163171
if (selected.length === 0) return
@@ -205,6 +213,7 @@ async function fetchOpenPullRequests() {
205213
title
206214
url
207215
createdAt
216+
authorAssociation
208217
reactionGroups {
209218
content
210219
users {
@@ -335,6 +344,10 @@ function hasPriorCleanup(pr: PullRequest) {
335344
return pr.labels.nodes.some((label) => label.name === cleanupLabel)
336345
}
337346

347+
function isTeamMember(pr: PullRequest) {
348+
return teamAssociations.has(pr.authorAssociation)
349+
}
350+
338351
function requireRepo(value: string | undefined) {
339352
if (!value) throw new Error("repo is required")
340353
const [owner, name] = value.split("/")

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL