Skip to content

Commit 99ef4a7

Browse files
Merge branch 'master' into remove-stars-complex-mult
2 parents f5ec12d + 21eff8a commit 99ef4a7

File tree

138 files changed

+16344
-893
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+16344
-893
lines changed
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
name: Close stale PRs with failed workflows
2+
3+
on:
4+
schedule:
5+
- cron: '0 3 * * *' # runs daily at 03:00 UTC
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
issues: write
11+
pull-requests: write
12+
13+
jobs:
14+
close-stale:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Close stale PRs
18+
uses: actions/github-script@v7
19+
with:
20+
github-token: ${{ secrets.GITHUB_TOKEN }}
21+
script: |
22+
const mainBranches = ['main', 'master'];
23+
const cutoffDays = 14;
24+
const cutoff = new Date();
25+
cutoff.setDate(cutoff.getDate() - cutoffDays);
26+
27+
console.log(`Checking PRs older than: ${cutoff.toISOString()}`);
28+
29+
try {
30+
const { data: prs } = await github.rest.pulls.list({
31+
owner: context.repo.owner,
32+
repo: context.repo.repo,
33+
state: 'open',
34+
sort: 'updated',
35+
direction: 'asc',
36+
per_page: 100
37+
});
38+
39+
console.log(`Found ${prs.length} open PRs to check`);
40+
41+
for (const pr of prs) {
42+
try {
43+
const updated = new Date(pr.updated_at);
44+
45+
if (updated > cutoff) {
46+
console.log(`⏩ Skipping PR #${pr.number} - updated recently`);
47+
continue;
48+
}
49+
50+
console.log(`🔍 Checking PR #${pr.number}: "${pr.title}"`);
51+
52+
// Get commits
53+
const commits = await github.paginate(github.rest.pulls.listCommits, {
54+
owner: context.repo.owner,
55+
repo: context.repo.repo,
56+
pull_number: pr.number,
57+
per_page: 100
58+
});
59+
60+
const meaningfulCommits = commits.filter(c => {
61+
const msg = c.commit.message.toLowerCase();
62+
const isMergeFromMain = mainBranches.some(branch =>
63+
msg.startsWith(`merge branch '${branch}'`) ||
64+
msg.includes(`merge remote-tracking branch '${branch}'`)
65+
);
66+
return !isMergeFromMain;
67+
});
68+
69+
// Get checks with error handling
70+
let hasFailedChecks = false;
71+
let allChecksCompleted = false;
72+
let hasChecks = false;
73+
74+
try {
75+
const { data: checks } = await github.rest.checks.listForRef({
76+
owner: context.repo.owner,
77+
repo: context.repo.repo,
78+
ref: pr.head.sha
79+
});
80+
81+
hasChecks = checks.check_runs.length > 0;
82+
hasFailedChecks = checks.check_runs.some(c => c.conclusion === 'failure');
83+
allChecksCompleted = checks.check_runs.every(c =>
84+
c.status === 'completed' || c.status === 'skipped'
85+
);
86+
} catch (error) {
87+
console.log(`⚠️ Could not fetch checks for PR #${pr.number}: ${error.message}`);
88+
}
89+
90+
// Get workflow runs with error handling
91+
let hasFailedWorkflows = false;
92+
let allWorkflowsCompleted = false;
93+
let hasWorkflows = false;
94+
95+
try {
96+
const { data: runs } = await github.rest.actions.listWorkflowRuns({
97+
owner: context.repo.owner,
98+
repo: context.repo.repo,
99+
head_sha: pr.head.sha,
100+
per_page: 50
101+
});
102+
103+
hasWorkflows = runs.workflow_runs.length > 0;
104+
hasFailedWorkflows = runs.workflow_runs.some(r => r.conclusion === 'failure');
105+
allWorkflowsCompleted = runs.workflow_runs.every(r =>
106+
['completed', 'skipped', 'cancelled'].includes(r.status)
107+
);
108+
109+
console.log(`PR #${pr.number}: ${runs.workflow_runs.length} workflow runs found`);
110+
111+
} catch (error) {
112+
console.log(`⚠️ Could not fetch workflow runs for PR #${pr.number}: ${error.message}`);
113+
}
114+
115+
console.log(`PR #${pr.number}: ${meaningfulCommits.length} meaningful commits`);
116+
console.log(`Checks - has: ${hasChecks}, failed: ${hasFailedChecks}, completed: ${allChecksCompleted}`);
117+
console.log(`Workflows - has: ${hasWorkflows}, failed: ${hasFailedWorkflows}, completed: ${allWorkflowsCompleted}`);
118+
119+
// Combine conditions - only consider if we actually have checks/workflows
120+
const hasAnyFailure = (hasChecks && hasFailedChecks) || (hasWorkflows && hasFailedWorkflows);
121+
const allCompleted = (!hasChecks || allChecksCompleted) && (!hasWorkflows || allWorkflowsCompleted);
122+
123+
if (meaningfulCommits.length === 0 && hasAnyFailure && allCompleted) {
124+
console.log(`✅ Closing PR #${pr.number} (${pr.title})`);
125+
126+
await github.rest.issues.createComment({
127+
owner: context.repo.owner,
128+
repo: context.repo.repo,
129+
issue_number: pr.number,
130+
body: `This pull request has been automatically closed because its workflows or checks failed and it has been inactive for more than ${cutoffDays} days. Please fix the workflows and reopen if you'd like to continue. Merging from main/master alone does not count as activity.`
131+
});
132+
133+
await github.rest.pulls.update({
134+
owner: context.repo.owner,
135+
repo: context.repo.repo,
136+
pull_number: pr.number,
137+
state: 'closed'
138+
});
139+
140+
console.log(`✅ Successfully closed PR #${pr.number}`);
141+
} else {
142+
console.log(`⏩ Not closing PR #${pr.number} - conditions not met`);
143+
}
144+
145+
} catch (prError) {
146+
console.error(`❌ Error processing PR #${pr.number}: ${prError.message}`);
147+
continue;
148+
}
149+
}
150+
151+
} catch (error) {
152+
console.error(`❌ Fatal error: ${error.message}`);
153+
throw error;
154+
}

.github/workflows/codeql.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ jobs:
3030
distribution: 'temurin'
3131

3232
- name: Initialize CodeQL
33-
uses: github/codeql-action/init@v3
33+
uses: github/codeql-action/init@v4
3434
with:
3535
languages: 'java-kotlin'
3636

3737
- name: Build
3838
run: mvn --batch-mode --update-snapshots verify
3939

4040
- name: Perform CodeQL Analysis
41-
uses: github/codeql-action/analyze@v3
41+
uses: github/codeql-action/analyze@v4
4242
with:
4343
category: "/language:java-kotlin"
4444

@@ -55,12 +55,12 @@ jobs:
5555
uses: actions/checkout@v5
5656

5757
- name: Initialize CodeQL
58-
uses: github/codeql-action/init@v3
58+
uses: github/codeql-action/init@v4
5959
with:
6060
languages: 'actions'
6161

6262
- name: Perform CodeQL Analysis
63-
uses: github/codeql-action/analyze@v3
63+
uses: github/codeql-action/analyze@v4
6464
with:
6565
category: "/language:actions"
6666
...

.gitpod.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM gitpod/workspace-java-21:2025-08-25-18-17-39
1+
FROM gitpod/workspace-java-21:2025-10-06-13-14-25
22

33
ENV LLVM_SCRIPT="tmp_llvm.sh"
44

0 commit comments

Comments
 (0)