Skip to content

Commit f9da7d3

Browse files
justin808claude
andcommitted
Refactor full-ci label implementation and fix code review issues
- Remove cleanup workflow: Preserve full-ci label on merged PRs as historical record - Reduce code duplication: Create reusable composite action for label checking - Fix label addition timing: Add label within main workflow step with better error handling - Improve UX: Add permissions note to welcome message and clarify label persistence - Better error handling: Use core.setFailed() instead of throw in stop workflow 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent aac7121 commit f9da7d3

File tree

11 files changed

+57
-144
lines changed

11 files changed

+57
-144
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Check for full-ci label
2+
description: Checks if the PR has the full-ci label to enable full CI mode
3+
outputs:
4+
result:
5+
description: 'Whether the full-ci label is present (string: "true" or "false")'
6+
value: ${{ steps.check.outputs.result }}
7+
runs:
8+
using: composite
9+
steps:
10+
- name: Check for full-ci label
11+
id: check
12+
uses: actions/github-script@v7
13+
with:
14+
result-encoding: string
15+
script: |
16+
// Only check labels on pull requests
17+
if (!context.payload.pull_request) {
18+
return 'false';
19+
}
20+
21+
const { data: labels } = await github.rest.issues.listLabelsOnIssue({
22+
owner: context.repo.owner,
23+
repo: context.repo.repo,
24+
issue_number: context.payload.pull_request.number
25+
});
26+
27+
const hasLabel = labels.some(label => label.name === 'full-ci');
28+
console.log(`full-ci label present: ${hasLabel}`);
29+
return hasLabel ? 'true' : 'false';

.github/workflows/cleanup-full-ci-label.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

.github/workflows/examples.yml

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,7 @@ jobs:
3838
persist-credentials: false
3939
- name: Check for full-ci label
4040
id: check-label
41-
uses: actions/github-script@v7
42-
with:
43-
result-encoding: string
44-
script: |
45-
// Only check labels on pull requests
46-
if (!context.payload.pull_request) {
47-
return 'false';
48-
}
49-
50-
const { data: labels } = await github.rest.issues.listLabelsOnIssue({
51-
owner: context.repo.owner,
52-
repo: context.repo.repo,
53-
issue_number: context.payload.pull_request.number
54-
});
55-
56-
const hasLabel = labels.some(label => label.name === 'full-ci');
57-
console.log(`full-ci label present: ${hasLabel}`);
58-
return hasLabel ? 'true' : 'false';
41+
uses: ./.github/actions/check-full-ci-label
5942
- name: Detect relevant changes
6043
id: detect
6144
run: |

.github/workflows/main.yml

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,7 @@ jobs:
3838
persist-credentials: false
3939
- name: Check for full-ci label
4040
id: check-label
41-
uses: actions/github-script@v7
42-
with:
43-
result-encoding: string
44-
script: |
45-
// Only check labels on pull requests
46-
if (!context.payload.pull_request) {
47-
return 'false';
48-
}
49-
50-
const { data: labels } = await github.rest.issues.listLabelsOnIssue({
51-
owner: context.repo.owner,
52-
repo: context.repo.repo,
53-
issue_number: context.payload.pull_request.number
54-
});
55-
56-
const hasLabel = labels.some(label => label.name === 'full-ci');
57-
console.log(`full-ci label present: ${hasLabel}`);
58-
return hasLabel ? 'true' : 'false';
41+
uses: ./.github/actions/check-full-ci-label
5942
- name: Detect relevant changes
6043
id: detect
6144
run: |

.github/workflows/pr-welcome-message.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ jobs:
3030
' - Removes the `full-ci` label',
3131
' - Future commits will only run tests for changed files',
3232
'',
33-
'💡 **Note:** The `full-ci` label will be automatically removed when this PR is merged.',
33+
'**Note:**',
34+
'- These commands require write access to the repository',
35+
'- The `full-ci` label is preserved on merged PRs as a historical record',
3436
'',
3537
'View CI progress in the [Actions tab](${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions).'
3638
].join('\n');

.github/workflows/pro-integration-tests.yml

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,7 @@ jobs:
3232
persist-credentials: false
3333
- name: Check for full-ci label
3434
id: check-label
35-
uses: actions/github-script@v7
36-
with:
37-
result-encoding: string
38-
script: |
39-
// Only check labels on pull requests
40-
if (!context.payload.pull_request) {
41-
return 'false';
42-
}
43-
44-
const { data: labels } = await github.rest.issues.listLabelsOnIssue({
45-
owner: context.repo.owner,
46-
repo: context.repo.repo,
47-
issue_number: context.payload.pull_request.number
48-
});
49-
50-
const hasLabel = labels.some(label => label.name === 'full-ci');
51-
console.log(`full-ci label present: ${hasLabel}`);
52-
return hasLabel ? 'true' : 'false';
35+
uses: ./.github/actions/check-full-ci-label
5336
- name: Detect relevant changes
5437
id: detect
5538
working-directory: .

.github/workflows/pro-lint.yml

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,7 @@ jobs:
3232
persist-credentials: false
3333
- name: Check for full-ci label
3434
id: check-label
35-
uses: actions/github-script@v7
36-
with:
37-
result-encoding: string
38-
script: |
39-
// Only check labels on pull requests
40-
if (!context.payload.pull_request) {
41-
return 'false';
42-
}
43-
44-
const { data: labels } = await github.rest.issues.listLabelsOnIssue({
45-
owner: context.repo.owner,
46-
repo: context.repo.repo,
47-
issue_number: context.payload.pull_request.number
48-
});
49-
50-
const hasLabel = labels.some(label => label.name === 'full-ci');
51-
console.log(`full-ci label present: ${hasLabel}`);
52-
return hasLabel ? 'true' : 'false';
35+
uses: ./.github/actions/check-full-ci-label
5336
- name: Detect relevant changes
5437
id: detect
5538
working-directory: .

.github/workflows/pro-package-tests.yml

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,7 @@ jobs:
3232
persist-credentials: false
3333
- name: Check for full-ci label
3434
id: check-label
35-
uses: actions/github-script@v7
36-
with:
37-
result-encoding: string
38-
script: |
39-
// Only check labels on pull requests
40-
if (!context.payload.pull_request) {
41-
return 'false';
42-
}
43-
44-
const { data: labels } = await github.rest.issues.listLabelsOnIssue({
45-
owner: context.repo.owner,
46-
repo: context.repo.repo,
47-
issue_number: context.payload.pull_request.number
48-
});
49-
50-
const hasLabel = labels.some(label => label.name === 'full-ci');
51-
console.log(`full-ci label present: ${hasLabel}`);
52-
return hasLabel ? 'true' : 'false';
35+
uses: ./.github/actions/check-full-ci-label
5336
- name: Detect relevant changes
5437
id: detect
5538
working-directory: .

.github/workflows/run-skipped-ci.yml

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,6 @@ jobs:
8181
sha: pr.data.head.sha
8282
};
8383
84-
- name: Add full-ci label
85-
uses: actions/github-script@v7
86-
with:
87-
script: |
88-
await github.rest.issues.addLabels({
89-
owner: context.repo.owner,
90-
repo: context.repo.repo,
91-
issue_number: context.issue.number,
92-
labels: ['full-ci']
93-
});
94-
console.log('✅ Added full-ci label to PR');
95-
9684
- name: Get skipped checks and trigger workflows
9785
id: trigger_workflows
9886
uses: actions/github-script@v7
@@ -228,19 +216,34 @@ jobs:
228216
const notFoundList = notFound.length > 0 ? `\n\n**Triggered but not yet queued (may still start):**\n${notFound.map(w => `- ⏳ ${w.name}`).join('\n')}` : '';
229217
const failedList = failed.length > 0 ? `\n\n**Failed to trigger:**\n${failed.map(f => `- ❌ ${f.workflow}: ${f.error}`).join('\n')}` : '';
230218
219+
// Add full-ci label only if we actually triggered workflows or if checks are already running
220+
let labelAdded = false;
221+
try {
222+
await github.rest.issues.addLabels({
223+
owner: context.repo.owner,
224+
repo: context.repo.repo,
225+
issue_number: context.issue.number,
226+
labels: ['full-ci']
227+
});
228+
labelAdded = true;
229+
console.log('✅ Added full-ci label to PR');
230+
} catch (error) {
231+
console.error('⚠️ Failed to add label:', error.message);
232+
}
233+
231234
const body = `🚀 **Full CI Mode Enabled**
232235
233236
${status}
234237
${skippedChecksList}
235238
${verifiedList}${notFoundList}${failedList}
236239
237-
${verified.length > 0 ? `\n**Note:** Added the \`full-ci\` label to this PR. All future commits will run the full CI suite (including minimum dependency tests) until the label is removed.
240+
${labelAdded && verified.length > 0 ? `\n**Note:** Added the \`full-ci\` label to this PR. All future commits will run the full CI suite (including minimum dependency tests) until the label is removed.
238241
239242
To disable full CI mode, use the \`/stop-run-skipped-ci\` command.
240243
241244
View progress in the [Actions tab](${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions).` : ''}
242245
243-
${notApplicable.length > 0 ? `\nAll CI checks are already running on this PR. The \`full-ci\` label has been added - future commits will run the full CI suite.` : ''}`;
246+
${labelAdded && notApplicable.length > 0 ? `\nAll CI checks are already running on this PR. Added the \`full-ci\` label - future commits will run the full CI suite.` : ''}`;
244247
245248
// Post the comment
246249
await github.rest.issues.createComment({

.github/workflows/stop-run-skipped-ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ jobs:
120120
issue_number: context.issue.number,
121121
body: errorBody
122122
});
123-
throw error;
123+
// Use core.setFailed instead of throw to properly fail the workflow
124+
core.setFailed(`Failed to remove label: ${error.message}`);
124125
}
125126
}

0 commit comments

Comments
 (0)