Skip to content

Commit d9fcbcb

Browse files
zmdavisweb-flow
andauthored
Add skip_draft_prs configuration option (#18)
* Add skip_draft_prs configuration option - Add new skip_draft_prs input parameter to action.yml - Implement draft PR checking in shouldSkip() method - Add comprehensive tests for draft PR functionality - Update documentation in README.md and CONFIGURATION.md - Update advanced usage example to demonstrate the feature This feature allows users to configure Felix to skip processing draft PRs entirely by setting skip_draft_prs: true, providing more control over when automatic fixes are applied. * Add test workflow for draft PR skip functionality * 🤖 Fix-it Felix: Auto-fix formatting issues * Remove test workflow - dogfooding test completed successfully --------- Co-authored-by: zmdavis <[email protected]> Co-authored-by: Fix-it Felix[bot] <[email protected]>
1 parent d91f335 commit d9fcbcb

File tree

12 files changed

+280
-9
lines changed

12 files changed

+280
-9
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- 🛡️ **Safety First**: Built-in safeguards against infinite loops
1414
- 🔍 **Dry-run Mode**: Preview changes without committing
1515
- 🚫 **Skip Control**: Label-based opt-out mechanism
16+
- 📄 **Draft PR Control**: Optionally skip draft PRs
1617
- 🍴 **Fork Friendly**: Handles forked PRs gracefully
1718

1819
## 🚀 Quick Start
@@ -70,6 +71,7 @@ jobs:
7071
| `config_path` | Path to Felix configuration file | No | `.felixrc.json` |
7172
| `dry_run` | Run in dry-run mode (comment instead of commit) | No | `false` |
7273
| `skip_label` | PR label that skips Felix processing | No | `skip-felix` |
74+
| `skip_draft_prs` | Skip processing draft pull requests | No | `false` |
7375
| `allowed_bots` | Comma-separated list of bot names Felix should run against | No | `` |
7476
| `paths` | Comma-separated list of paths to run fixers on | No | `.` |
7577

@@ -176,9 +178,27 @@ Use your own npm scripts instead of built-in commands:
176178
- Skips processing (cannot commit to forks with default token)
177179
- Logs appropriate messages
178180

181+
### Draft PR Handling
182+
183+
By default, Felix processes draft PRs just like regular PRs. You can configure Felix to skip draft PRs entirely:
184+
185+
```yaml
186+
- name: Run Fix-it Felix
187+
uses: launchdarkly/fix-it-felix-action@v1
188+
with:
189+
skip_draft_prs: true
190+
```
191+
192+
This is useful when you want to:
193+
194+
- Prevent commits on work-in-progress PRs
195+
- Let developers refine their changes before auto-fixing
196+
- Reduce action runs during development
197+
179198
### Skip Mechanisms
180199

181200
- **Label-based**: Add `skip-felix` label to PR
201+
- **Draft PRs**: Set `skip_draft_prs: true` to skip draft PRs
182202
- **Configuration**: Set `fixers: []` in `.felixrc.json`
183203
- **Event-based**: Only runs on specific PR events
184204

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ inputs:
4949
required: false
5050
default: 'false'
5151

52+
skip_draft_prs:
53+
description: 'Skip processing draft pull requests'
54+
required: false
55+
default: 'false'
56+
5257
outputs:
5358
fixes_applied:
5459
description: 'Whether any fixes were applied'

dist/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30182,8 +30182,13 @@ class FixitFelix {
3018230182
core.info('Not a pull request event');
3018330183
return true;
3018430184
}
30185-
// Skip if PR has skip label
3018630185
const pr = this.context.payload.pull_request;
30186+
// Skip if draft PR and skipDraftPrs is enabled
30187+
if (this.inputs.skipDraftPrs && pr?.draft) {
30188+
core.info('PR is a draft and skip_draft_prs is enabled');
30189+
return true;
30190+
}
30191+
// Skip if PR has skip label
3018730192
if (pr?.labels?.some((label) => label.name === this.inputs.skipLabel)) {
3018830193
core.info(`PR has skip label: ${this.inputs.skipLabel}`);
3018930194
return true;
@@ -31426,7 +31431,8 @@ async function run() {
3142631431
allowedBots: core.getInput('allowed_bots'),
3142731432
paths: core.getInput('paths'),
3142831433
personalAccessToken: core.getInput('personal_access_token'),
31429-
debug: core.getBooleanInput('debug')
31434+
debug: core.getBooleanInput('debug'),
31435+
skipDraftPrs: core.getBooleanInput('skip_draft_prs')
3143031436
};
3143131437
const felix = new felix_1.FixitFelix(inputs, github.context);
3143231438
const result = await felix.run();

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/CONFIGURATION.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Configure Felix behavior through GitHub Action inputs:
4040
| `config_path` | Path to Felix configuration file | `.felixrc.json` |
4141
| `dry_run` | Run in dry-run mode (comment instead of commit) | `false` |
4242
| `skip_label` | PR label that skips Felix processing | `skip-felix` |
43+
| `skip_draft_prs` | Skip processing draft pull requests | `false` |
4344
| `allowed_bots` | Comma-separated list of bot names Felix should run against | (empty) |
4445

4546
### Example
@@ -68,6 +69,7 @@ steps:
6869
config_path: '.custom-felix.json'
6970
dry_run: false
7071
skip_label: 'no-autofix'
72+
skip_draft_prs: true
7173
allowed_bots: 'dependabot,renovate'
7274
```
7375

examples/advanced-usage.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ jobs:
3434
commit_message: '🤖 Fix-it Felix: Automated code quality improvements'
3535
config_path: '.felixrc.json'
3636
skip_label: 'no-autofix'
37+
skip_draft_prs: true
3738
env:
3839
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3940

src/felix.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,15 @@ export class FixitFelix {
135135
return true
136136
}
137137

138-
// Skip if PR has skip label
139138
const pr = this.context.payload.pull_request
139+
140+
// Skip if draft PR and skipDraftPrs is enabled
141+
if (this.inputs.skipDraftPrs && pr?.draft) {
142+
core.info('PR is a draft and skip_draft_prs is enabled')
143+
return true
144+
}
145+
146+
// Skip if PR has skip label
140147
if (pr?.labels?.some((label: any) => label.name === this.inputs.skipLabel)) {
141148
core.info(`PR has skip label: ${this.inputs.skipLabel}`)
142149
return true

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ async function run(): Promise<void> {
1313
allowedBots: core.getInput('allowed_bots'),
1414
paths: core.getInput('paths'),
1515
personalAccessToken: core.getInput('personal_access_token'),
16-
debug: core.getBooleanInput('debug')
16+
debug: core.getBooleanInput('debug'),
17+
skipDraftPrs: core.getBooleanInput('skip_draft_prs')
1718
}
1819

1920
const felix = new FixitFelix(inputs, github.context)

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export interface FelixInputs {
88
paths: string
99
personalAccessToken?: string
1010
debug: boolean
11+
skipDraftPrs: boolean
1112
}
1213

1314
export interface FelixConfig {

tests/config.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ describe('ConfigManager', () => {
1616
allowedBots: '',
1717
paths: '',
1818
personalAccessToken: '',
19-
debug: false
19+
debug: false,
20+
skipDraftPrs: false
2021
}
2122

2223
beforeEach(() => {

0 commit comments

Comments
 (0)