GeezerVison is showing github.com — ci: "fix: exempt team members from compliance cleanup" (#28865) · Integralist/opencode@8596967
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: .github/workflows/compliance-close.yml -14Lines changed: 0 additions & 14 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -34,25 +34,11 @@ jobs: | 34 | 34 |
| 35 | 35 | const now = Date.now(); | 36 | 36 | const twoHours = 2 * 60 * 60 * 1000; | 37 | | - const teamAssociations = ['OWNER', 'MEMBER', 'COLLABORATOR']; | 38 | 37 |
| 39 | 38 | for (const item of items) { | 40 | 39 | const isPR = !!item.pull_request; | 41 | 40 | const kind = isPR ? 'PR' : 'issue'; | 42 | 41 |
| 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 | | -
| 56 | 42 | const { data: comments } = await github.rest.issues.listComments({ | 57 | 43 | owner: context.repo.owner, | 58 | 44 | repo: context.repo.repo, | |
Collapse file Copy file name to clipboardExpand all lines: .github/workflows/duplicate-issues.yml +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 6 | 6 |
| 7 | 7 | jobs: | 8 | 8 | check-duplicates: | 9 | | - if: github.event.action == 'opened' && !contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.issue.author_association) | | 9 | + if: github.event.action == 'opened' | 10 | 10 | runs-on: blacksmith-4vcpu-ubuntu-2404 | 11 | 11 | permissions: | 12 | 12 | contents: read | @@ -118,7 +118,7 @@ jobs: | 118 | 118 | Remember: post at most ONE comment combining all findings. If everything is fine, post nothing." | 119 | 119 |
| 120 | 120 | recheck-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) | | 121 | + if: github.event.action == 'edited' && contains(github.event.issue.labels.*.name, 'needs:compliance') | 122 | 122 | runs-on: blacksmith-4vcpu-ubuntu-2404 | 123 | 123 | permissions: | 124 | 124 | contents: read | |
Collapse file Copy file name to clipboardExpand all lines: .github/workflows/pr-management.yml +6-9Lines changed: 6 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -11,25 +11,22 @@ jobs: | 11 | 11 | contents: read | 12 | 12 | pull-requests: write | 13 | 13 | steps: | | 14 | + - name: Checkout repository | | 15 | + uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 | | 16 | + with: | | 17 | + fetch-depth: 1 | | 18 | + | 14 | 19 | - name: Check team membership | 15 | 20 | id: team-check | 16 | 21 | run: | | 17 | 22 | LOGIN="${{ github.event.pull_request.user.login }}" | 18 | | - ASSOCIATION="${{ github.event.pull_request.author_association }}" | 19 | | - if [ "$LOGIN" = "opencode-agent[bot]" ] || [ "$ASSOCIATION" = "OWNER" ] || [ "$ASSOCIATION" = "MEMBER" ] || [ "$ASSOCIATION" = "COLLABORATOR" ]; then | | 23 | + if [ "$LOGIN" = "opencode-agent[bot]" ] || grep -qxF "$LOGIN" .github/TEAM_MEMBERS; then | 20 | 24 | echo "is_team=true" >> "$GITHUB_OUTPUT" | 21 | 25 | echo "Skipping: $LOGIN is a team member or bot" | 22 | 26 | else | 23 | 27 | echo "is_team=false" >> "$GITHUB_OUTPUT" | 24 | 28 | fi | 25 | 29 |
| 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 | | - | 33 | 30 | - name: Setup Bun | 34 | 31 | if: steps.team-check.outputs.is_team != 'true' | 35 | 32 | uses: ./.github/actions/setup-bun | |
Collapse file Copy file name to clipboardExpand all lines: .github/workflows/pr-standards.yml +18-6Lines changed: 18 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 28 | 28 |
| 29 | 29 | // Check if author is a team member or bot | 30 | 30 | if (login === 'opencode-agent[bot]') return; | 31 | | - const teamAssociations = ['OWNER', 'MEMBER', 'COLLABORATOR']; | 32 | | - if (teamAssociations.includes(pr.author_association)) { | 33 | | - console.log(`Skipping: ${login} has author association ${pr.author_association}`); | | 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`); | 34 | 40 | return; | 35 | 41 | } | 36 | 42 |
| @@ -169,9 +175,15 @@ jobs: | 169 | 175 |
| 170 | 176 | // Check if author is a team member or bot | 171 | 177 | if (login === 'opencode-agent[bot]') return; | 172 | | - const teamAssociations = ['OWNER', 'MEMBER', 'COLLABORATOR']; | 173 | | - if (teamAssociations.includes(pr.author_association)) { | 174 | | - console.log(`Skipping: ${login} has author association ${pr.author_association}`); | | 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`); | 175 | 187 | return; | 176 | 188 | } | 177 | 189 |
| |
Collapse file Copy file name to clipboardExpand all lines: script/github/close-issues.ts -7Lines changed: 0 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -15,11 +15,8 @@ const cutoff = new Date(Date.now() - days * 24 * 60 * 60 * 1000) | 15 | 15 | type Issue = { | 16 | 16 | number: number | 17 | 17 | updated_at: string | 18 | | - author_association: string | 19 | 18 | } | 20 | 19 |
| 21 | | -const teamAssociations = new Set(["OWNER", "MEMBER", "COLLABORATOR"]) | 22 | | - | 23 | 20 | const headers = { | 24 | 21 | Authorization: `Bearer ${token}`, | 25 | 22 | "Content-Type": "application/json", | @@ -66,10 +63,6 @@ async function main() { | 66 | 63 | for (const i of all) { | 67 | 64 | const updated = new Date(i.updated_at) | 68 | 65 | 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 | | - } | 73 | 66 | stale.push(i.number) | 74 | 67 | } else { | 75 | 68 | console.log(`\nFound fresh issue #${i.number}, stopping`) | |
Collapse file Copy file name to clipboardExpand all lines: script/github/close-prs.ts +5-18Lines changed: 5 additions & 18 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -69,7 +69,6 @@ const maxClose = | 69 | 69 | const sleepMs = requireNonNegativeInteger("sleep-ms", values["sleep-ms"]) | 70 | 70 | const printLimit = requireNonNegativeInteger("print-limit", values["print-limit"]) | 71 | 71 | const cutoff = subtractMonths(new Date(), ageMonths) | 72 | | -const teamAssociations = new Set(["OWNER", "MEMBER", "COLLABORATOR"]) | 73 | 72 |
| 74 | 73 | const headers = { | 75 | 74 | Authorization: `Bearer ${token}`, | @@ -83,7 +82,6 @@ type PullRequest = { | 83 | 82 | title: string | 84 | 83 | url: string | 85 | 84 | createdAt: string | 86 | | - authorAssociation: string | 87 | 85 | reactionGroups: Array<{ | 88 | 86 | content: string | 89 | 87 | users: { | @@ -147,25 +145,19 @@ async function main() { | 147 | 145 | console.log(`Threshold: fewer than ${threshold} positive reactions`) | 148 | 146 |
| 149 | 147 | const prs = await fetchOpenPullRequests() | 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 | | - ) | | 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) | 156 | 152 | const candidates = matching.filter((pr) => !hasPriorCleanup(pr)) | 157 | 153 | const selected = maxClose === undefined ? candidates : candidates.slice(0, maxClose) | 158 | 154 |
| 159 | 155 | console.log(`Fetched ${prs.length} open PRs`) | 160 | 156 | console.log(`Matching cleanup criteria: ${matching.length}`) | 161 | 157 | console.log(`Skipped previously cleaned PRs: ${matching.length - candidates.length}`) | 162 | | - console.log(`Team member PRs untouched: ${teamCount}`) | 163 | 158 | console.log(`Recent PRs untouched: ${recentCount}`) | 164 | 159 | console.log( | 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 | | - }`, | | 160 | + `Older PRs with at least ${threshold} positive reactions untouched: ${prs.length - matching.length - recentCount}`, | 169 | 161 | ) | 170 | 162 |
| 171 | 163 | if (selected.length === 0) return | @@ -213,7 +205,6 @@ async function fetchOpenPullRequests() { | 213 | 205 | title | 214 | 206 | url | 215 | 207 | createdAt | 216 | | - authorAssociation | 217 | 208 | reactionGroups { | 218 | 209 | content | 219 | 210 | users { | @@ -344,10 +335,6 @@ function hasPriorCleanup(pr: PullRequest) { | 344 | 335 | return pr.labels.nodes.some((label) => label.name === cleanupLabel) | 345 | 336 | } | 346 | 337 |
| 347 | | -function isTeamMember(pr: PullRequest) { | 348 | | - return teamAssociations.has(pr.authorAssociation) | 349 | | -} | 350 | | - | 351 | 338 | function requireRepo(value: string | undefined) { | 352 | 339 | if (!value) throw new Error("repo is required") | 353 | 340 | const [owner, name] = value.split("/") | |
|