Skip to content

Commit f1b6deb

Browse files
authored
Merge branch 'main' into tolk-docs
2 parents 4bf4b3b + 591ad18 commit f1b6deb

File tree

10 files changed

+128
-130
lines changed

10 files changed

+128
-130
lines changed

.github/workflows/bouncer.yml

Lines changed: 20 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@ env:
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

1412
on:
1513
pull_request_target: # do NOT use actions/checkout!
@@ -49,57 +47,6 @@ jobs:
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
@@ -121,9 +68,8 @@ jobs:
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');
@@ -142,7 +88,6 @@ jobs:
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: |

.github/workflows/linter.yml

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
files: |
4747
**.md
4848
**.mdx
49-
separator: ":"
49+
separator: " "
5050

5151
- name: Check formatting of MDX and Markdown files
5252
id: check-fmt
@@ -55,7 +55,8 @@ jobs:
5555
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
5656
with:
5757
script: |
58-
const files = (process.env.ALL_CHANGED_FILES ?? '').trim().split(':').filter(Boolean);
58+
const files = (process.env.ALL_CHANGED_FILES ?? '')
59+
.trim().split(' ').filter(Boolean).filter((it) => it.match(/\.mdx?$/) !== null);
5960
if (files.length === 0) {
6061
console.log('\nNo such files affected!');
6162
process.exit(0);
@@ -64,57 +65,52 @@ jobs:
6465
for (const file of files) {
6566
console.log(`- ${file}`);
6667
}
67-
const filesQuoted = files.map((it) => '"' + it + '"');
6868
try {
69-
await exec.exec('npm', ['run', 'check:fmt:some', '--', ...filesQuoted], {
69+
await exec.exec('npm', ['run', 'check:fmt:some', '--', ...files], {
7070
silent: true, // >/dev/null 2>&1
7171
});
7272
} catch (_) {
7373
// Comment right in the actions output
74-
const filesJoined = filesQuoted.join(' ');
7574
console.log('\n\x1b[31mError:\x1b[0m Some files are not properly formatted!');
7675
console.log('1. Install necessary dependencies: \x1b[31mnpm ci\x1b[0m');
77-
console.log(`2. Run this command to fix the issues: \x1b[31mnpm run fmt:some -- ${filesJoined}\x1b[0m`);
78-
79-
// Prepare a comment on the PR
80-
const comment = [
81-
'To fix the **formatting** issues:\n',
82-
'1. Install necessary dependencises: `npm ci`',
83-
'2. Then, run this command:',
84-
'```shell',
85-
`npm run fmt:some -- ${filesJoined}`,
86-
'```',
87-
].join('\n');
88-
89-
// Set environment variable for subsequent steps
90-
core.exportVariable('COMMENT', comment);
76+
console.log(`2. Run this command to fix the issues: \x1b[31mnpm run fmt:some -- ${files.join(' ')}\x1b[0m`);
9177
9278
// Rethrow the exit code of the failed formatting check
9379
core.setFailed('Some files are not properly formatted!');
9480
process.exit(1);
9581
}
9682
9783
- name: Hide prior PR comments and issue a new one in case of failure
98-
if: ${{ !cancelled() && github.event_name == 'pull_request' && github.event_name != 'pull_request_target' }}
84+
if: |
85+
(
86+
!cancelled() &&
87+
steps.changed-files.conclusion == 'success' &&
88+
github.event_name == 'pull_request' &&
89+
github.event_name != 'pull_request_target'
90+
)
9991
env:
100-
COMMENT: ${{ env.COMMENT }}
92+
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
10193
SUCCESS: ${{ steps.check-fmt.conclusion == 'failure' && 'false' || 'true' }}
10294
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
10395
with:
10496
script: |
10597
const { hidePriorCommentsWithPrefix, createComment } = await import('${{ github.workspace }}/.github/scripts/common.mjs');
10698
const success = JSON.parse(process.env.SUCCESS ?? 'false');
107-
const rawCommentText = process.env.COMMENT ?? '';
108-
if (!success && rawCommentText === '') {
109-
console.log('There was a formatting error, but no comment was given, skipping...');
110-
process.exit(0);
111-
}
112-
const prefix = rawCommentText.slice(1, 30);
99+
const files = (process.env.ALL_CHANGED_FILES ?? '')
100+
.trim().split(' ').filter(Boolean).filter((it) => it.match(/\.mdx?$/) !== null);
101+
const comment = [
102+
'To fix the **formatting** issues:\n',
103+
'1. Install necessary dependencises: `npm ci`',
104+
'2. Then, run this command:',
105+
'```shell',
106+
`npm run fmt:some -- ${files.join(' ')}`,
107+
'```',
108+
].join('\n');
109+
const prefix = comment.slice(0, 30);
113110
await hidePriorCommentsWithPrefix({ github, context, exec, prefix, resolved: success });
114-
// Create a new comment in case of a new failure
111+
// Create a new PR comment in case of a new failure
115112
if (!success) {
116-
const body = rawCommentText.slice(1, -1).replace(/\\n/g, '\n');
117-
await createComment({ github, context, exec, body });
113+
await createComment({ github, context, exec, body: comment });
118114
}
119115
120116
spell-check:

package-lock.json

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"unist-util-visit-parents": "^6.0.2"
3939
},
4040
"engines": {
41-
"node": ">=20.0",
41+
"node": ">=20.17",
4242
"npm": ">=9"
4343
},
4444
"packageManager": "[email protected]"

0 commit comments

Comments
 (0)