Skip to content

Commit df5501a

Browse files
SNOW-1923653: Add AST generation acknowledgement to PR template and GitHub action to validate it (#3173)
1. Which Jira issue is this PR addressing? Make sure that there is an accompanying issue to your PR. [SNOW-1923653](https://snowflakecomputing.atlassian.net/browse/SNOW-1923653) 2. Fill out the following pre-review checklist: - [x] I am adding a new automated test(s) to verify correctness of my new code - [ ] If this test skips Local Testing mode, I'm requesting review from @snowflakedb/local-testing - [ ] I am adding new logging messages - [ ] I am adding a new telemetry message - [ ] I am adding new credentials - [ ] I am adding a new dependency - [ ] If this is a new feature/behavior, I'm adding the Local Testing parity changes. - [x] I acknowledge that I have ensured my changes to be thread-safe. Follow the link for more information: [Thread-safe Developer Guidelines](https://github.com/snowflakedb/snowpark-python/blob/main/CONTRIBUTING.md#thread-safe-development) - [x] If adding any arguments to public Snowpark APIs or creating new public Snowpark APIs, I acknowledge that I have ensured my changes include AST support. Follow the link for more information: [AST Support Guidelines](https://github.com/snowflakedb/snowpark-python/blob/main/CONTRIBUTING.md#ast-abstract-syntax-tree-support-in-snowpark) 3. Please describe how your code solves the related issue. This PR creates an AST acknowledgement checkbox in our repository's PR template along with a GitHub action to verify its usage. This is in the same vein as the thread safety acknowledgement checkbox and GitHub Action. [SNOW-1923653]: https://snowflakecomputing.atlassian.net/browse/SNOW-1923653?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
1 parent 8e44d9b commit df5501a

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

.github/pull_request_template.md

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Please answer these questions before creating your pull request. Thanks!
2525
- [ ] I am adding a new dependency
2626
- [ ] If this is a new feature/behavior, I'm adding the Local Testing parity changes.
2727
- [ ] I acknowledge that I have ensured my changes to be thread-safe. Follow the link for more information: [Thread-safe Developer Guidelines](https://github.com/snowflakedb/snowpark-python/blob/main/CONTRIBUTING.md#thread-safe-development)
28+
- [ ] If adding any arguments to public Snowpark APIs or creating new public Snowpark APIs, I acknowledge that I have ensured my changes include AST support. Follow the link for more information: [AST Support Guidelines](https://github.com/snowflakedb/snowpark-python/blob/main/CONTRIBUTING.md#ast-abstract-syntax-tree-support-in-snowpark)
2829

2930
3. Please describe how your code solves the related issue.
3031

.github/workflows/ast-check.yml

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

CONTRIBUTING.md

+6
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ Once you have decided that the new component being added with required protectio
104104
105105
An example PR to make auto temp table cleaner thread-safe can be found [here](https://github.com/snowflakedb/snowpark-python/pull/2309).
106106
107+
### AST (Abstract Syntax Tree) Support in Snowpark
108+
109+
If you are an open-source developer modifying existing Snowpark APIs (such as by adding a parameter to a `Dataframe` API), or creating new Snowpark APIs in your PR, please request a review from the `snowpark-ir` [team](https://github.com/orgs/snowflakedb/teams/snowpark-ir) and add the `snowpark-ast` [label](https://github.com/snowflakedb/snowpark-python/labels/snowpark-ast). You can also raise an issue on our [issue tracker](https://github.com/snowflakedb/snowpark-python/issues) with the `snowpark-ast` label and assign it to the `snowpark-ir` team to request a review. We will add code to support detailed logging of the usage of your modified or newly created API if relevant to your PR. After we do so, we will also update your PR description by completing the required AST support acknowledgement checkbox.
110+
111+
If you are an internal developer, please ensure you complete the PR checklist for AST support found in the [Snowpark Python AST developer guide](https://docs.google.com/document/d/16K9jBv0pT6SkYbFTxNIQT9-bJjemE4niZTfc9mie6RQ/edit?tab=t.0), before completing the AST support acknowledgement checkbox.
112+
107113
## Tests
108114
109115
The [README under tests folder](tests/README.md) tells you how to set up to run tests.

0 commit comments

Comments
 (0)