Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(generated-files-bot): configurable list of PR authors to ignore #1254

Merged
merged 4 commits into from
Dec 16, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/generated-files-bot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ options:
| ---- | ----------- | ---- | ------- |
| `generatedFiles` | An explicit list of files which are considered templates. | `string[]` | `[]` |
| `externalManifests` | List of external manifest files to parse. | `ExternalManifest[]` | `[]` |
| `ignoreAuthors` | List of PR authors to ignore. | `string[]` | `[]` |

External Manifest:

Expand Down
7 changes: 7 additions & 0 deletions packages/generated-files-bot/src/generated-files-bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ interface ExternalManifest {
export interface Configuration {
generatedFiles?: string[];
externalManifests?: ExternalManifest[];
ignoreAuthors?: string[];
}

/**
Expand Down Expand Up @@ -165,6 +166,12 @@ export function handler(app: Application) {
const owner = context.payload.repository.owner.login;
const repo = context.payload.repository.name;
const pullNumber = context.payload.pull_request.number;
const prAuthor = context.payload.pull_request.user.login;

// ignore PRs from a configurable list of authors
if (config.ignoreAuthors && config.ignoreAuthors.includes(prAuthor)) {
chingor13 marked this conversation as resolved.
Show resolved Hide resolved
return;
}

// Read the list of templated files
const templatedFiles = new Set(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
generatedFiles:
- 'file1.txt'
externalManifests:
- type: json
file: 'manifest.json'
jsonpath: '$.key1[*]'
- type: 'yaml'
file: 'manifest.yaml'
jsonpath: '$.key2.key3[*]'
ignoreAuthors:
- testuser2
17 changes: 17 additions & 0 deletions packages/generated-files-bot/test/generated-files-bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,23 @@ describe('generated-files-bot', () => {
});
requests.done();
});

it('ignores PRs from configured autors', async () => {
const validConfig = fs.readFileSync(
resolve(fixturesPath, 'config', 'ignore-authors.yml')
);
requests = requests
.get(
'/repos/testOwner/testRepo/contents/.github%2Fgenerated-files-bot.yml'
)
.reply(200, validConfig);
await probot.receive({
name: 'pull_request',
payload: payload,
id: 'abc123',
});
requests.done();
});
});
});
});