-
Notifications
You must be signed in to change notification settings - Fork 117
51 lines (47 loc) · 2.57 KB
/
threadsafe-check.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
name: Threadsafe Check
on:
pull_request:
types: [opened, synchronize, labeled, unlabeled, edited]
jobs:
check_threadsafety:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for modified files
id: changed_files
uses: actions/github-script@v6
with:
script: |
const pr = context.payload.pull_request;
const { data: files } = await github.rest.pulls.listFiles({
owner: pr.base.repo.owner.login,
repo: pr.base.repo.name,
pull_number: pr.number,
});
const changedFiles = JSON.stringify(files.map(file => file.filename));
console.log(`Changed files: ${changedFiles}`);
return changedFiles;
- name: Verify threadsafety acknowledgement
if: steps.changed_files.outputs.result != ''
uses: actions/github-script@v6
with:
script: |
const changedFiles = JSON.parse(${{ steps.changed_files.outputs.result }});
console.log(`changedFiles: ${changedFiles}`);
const prBody = context.payload.pull_request.body;
// Check if changed files are in snowpark/_internal, snowpark/mock, or snowpark/*.py. We exclude snowpark/modin in this check.
if (changedFiles.some(file => file.match(/src\/snowflake\/snowpark\/_internal|src\/snowflake\/snowpark\/mock|src\/snowflake\/snowpark\/[^/]+\.py/))) {
console.log("Checking PR description for thread-safety acknowledgment...");
if (!prBody.includes("[x] I acknowledge that I have ensured my changes to be thread-safe")) {
console.log("Thread-safety acknowledgment not found in PR description.");
console.log("Please acknowledge the threadsafety implications of your changes by adding '[x] I acknowledge that I have ensured my changes to be thread-safe' to the PR description.");
process.exit(1);
} else {
console.log("Thread-safety acknowledgment found in PR description.");
}
} else {
console.log("No critical files modified; skipping threadsafety check.");
}