55 # additions only
66 MAX_ADDITIONS_FORKS : 500
77 # on rare occasions maintainers need to edit a lot of things at once
8- MAX_ADDITIONS_DIRECT_BRANCHES : 800
8+ MAX_ADDITIONS_DIRECT_BRANCHES : 1000
99 # many target issues usually mean bigger pull requests
1010 MAX_ISSUES_PER_PR : 3
11- # the name of this workflow file wrapped in backticks
12- MSG_PREFIX : " `bouncer.yml`"
1311
1412on :
1513 pull_request_target : # do NOT use actions/checkout!
4947 with :
5048 script : core.exportVariable('MAX_ADDITIONS', '${{ env.MAX_ADDITIONS_DIRECT_BRANCHES }}')
5149
52- - name : Remove prior comments by their common prefix
53- if : github.event.action == 'synchronize'
54- uses : actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
55- with :
56- # This JavaScript code cannot be moved to a separate file because
57- # this workflow must NOT checkout the repository for security reasons
58- #
59- # The same note applies to all JS code in this file
60- script : |
61- await exec.exec('sleep 0.5s');
62- const comments = await github.rest.issues.listComments({
63- owner: context.repo.owner,
64- repo: context.repo.repo,
65- issue_number: context.payload.pull_request.number,
66- });
67- for (const comment of comments.data) {
68- await exec.exec('sleep 0.5s');
69- const isHidden = (await github.graphql(`
70- query($nodeId: ID!) {
71- node(id: $nodeId) {
72- ... on IssueComment {
73- isMinimized
74- }
75- }
76- }
77- `, { nodeId: comment.node_id }))?.node?.isMinimized;
78- if (isHidden) { continue; }
79- if (
80- comment.user.login === 'github-actions[bot]' &&
81- comment.body.startsWith('${{ env.MSG_PREFIX }}')
82- ) {
83- console.log('Comment node_id:', comment.node_id);
84- await exec.exec('sleep 0.5s');
85- console.log(await github.graphql(`
86- mutation($subjectId: ID!) {
87- minimizeComment(input: {
88- subjectId: $subjectId,
89- classifier: OUTDATED
90- }) {
91- minimizedComment {
92- isMinimized
93- minimizedReason
94- }
95- }
96- }
97- `, {
98- subjectId: comment.node_id,
99- }));
100- }
101- }
102-
10350 - name : Check if a number of additions modulo filtered files is within the threshold
10451 id : stats
10552 uses : actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
12168 'ecosystem/api/toncenter/v3.yaml',
12269 'ecosystem/api/toncenter/smc-index.json',
12370 'tvm/instructions.mdx',
124- ].includes(f.filename) && !f.filename.endsWith('.py'),
71+ ].includes(f.filename) && !f.filename.endsWith('.py') && !f.filename.startsWith('snippets') ,
12572 );
126- // NOTE: consider looking for .changes
12773 const additions = filtered.reduce((acc, it) => acc + it.additions, 0);
12874 if (additions > maxAdditions) {
12975 core.setOutput('trigger', 'true');
14288 repo: context.repo.repo,
14389 issue_number: context.payload.pull_request.number,
14490 body: [
145- '${{ env.MSG_PREFIX }}',
14691 'Thank you for the contribution!',
14792 [
14893 'Unfortunately, it is too large, with over ${{ env.MAX_ADDITIONS }} added lines,',
@@ -154,7 +99,10 @@ jobs:
15499 'reverting any unrelated changes, writing less, or approaching',
155100 'the problem in the issue from a different angle.',
156101 ].join(' '),
157- 'I look forward to your next submissions. If you still intend to proceed as is, then you are at the mercy of the reviewers.',
102+ [
103+ 'I look forward to your next submissions.',
104+ 'If you still intend to proceed as is, then you are at the mercy of the reviewers.',
105+ ].join(' '),
158106 ].join('\n\n'),
159107 });
160108 process.exit(1);
@@ -164,25 +112,21 @@ jobs:
164112 uses : actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
165113 with :
166114 script : |
167- await exec.exec('sleep 0.5s');
168- await github.rest.issues.createComment({
169- owner: context.repo.owner,
170- repo: context.repo.repo,
171- issue_number: context.payload.pull_request.number,
172- body: [
173- '${{ env.MSG_PREFIX }}',
174- [
175- 'The most recent commit has made this PR go over ${{ env.MAX_ADDITIONS }} added lines.',
176- 'Please, decrease the size of this pull request or consider splitting it into several smaller requests.'
177- ].join(' '),
178- 'Until then, the CI will be marked as failed.',
179- ].join('\n\n'),
180- });
115+ core.setFailed([
116+ [
117+ 'This pull request has gotten over ${{ env.MAX_ADDITIONS }} added lines,',
118+ 'which can be challenging to review and iterate on',
119+ 'Please, decrease the size of this PR or consider splitting it into several smaller requests.'
120+ ].join(' '),
121+ [
122+ 'Until then, the CI will be soft-marked as failed.',
123+ 'If you still intend to proceed as is, then you are at the mercy of the reviewers.',
124+ ].join(' '),
125+ ].join('\n\n'));
181126 process.exit(1);
182127
183128 enforce-better-descriptions :
184129 name : " Title and description"
185- if : github.event.action == 'opened' || github.event.action == 'edited'
186130 runs-on : ubuntu-latest
187131 steps :
188132 # pr title check
@@ -192,7 +136,8 @@ jobs:
192136 with :
193137 script : |
194138 const title = context.payload.pull_request.title;
195- const pattern = /^(revert: )?(feat|fix|chore|refactor|test)(?:\/(feat|fix|chore|refactor|test))?!?(\(.+?\))?!?: [a-z].{1,200}/;
139+ const types = 'feat|fix|chore|refactor|test';
140+ const pattern = new RegExp(`^(revert: )?(${types})(?:\\/(${types}))?!?(\\([^\\)]+\\))?!?: [a-zA-Z].{1,200}`);
196141 const matches = title.match(pattern) !== null;
197142 if (!matches) {
198143 core.setFailed([
@@ -205,7 +150,7 @@ jobs:
205150
206151 # pr close issue limits
207152 - name : " Check that there is no more than ${{ env.MAX_ISSUES_PER_PR }} linked issues"
208- if : ${{ !cancelled() }}
153+ if : ${{ !cancelled() && github.event.pull_request.user.login != 'dependabot[bot]' }}
209154 uses : actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
210155 with :
211156 script : |
0 commit comments