|
| 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 | + } |
0 commit comments