1- name : Tests
1+ name : Legacy Tests
22
33on :
44 push :
55 branches :
66 - " develop"
7- pull_request_target :
8- types : [opened, synchronize, reopened, labeled]
9- branches :
10- - " develop"
117 workflow_dispatch :
128
13- jobs :
14- access-check :
15- runs-on : ubuntu-latest
16- steps :
17- - name : Check if bot account
18- id : bot-check
19- run : |
20- actor="${{ github.triggering_actor }}"
21- echo "Checking actor: $actor"
22- if [[ "$actor" == *"[bot]" ]] || [[ "$actor" == "renovate" ]] || [[ "$actor" == "dependabot" ]]; then
23- echo "is_bot=true" >> $GITHUB_OUTPUT
24- echo "Detected bot account: $actor - skipping permission check"
25- exit 0
26- else
27- echo "is_bot=false" >> $GITHUB_OUTPUT
28- echo "Detected human account: $actor"
29- fi
30- - name : Check user permissions
31- if : steps.bot-check.outputs.is_bot == 'false'
32- uses : actions-cool/check-user-permission@v2
33- with :
34- require : write
35- username : ${{ github.triggering_actor }}
36- error-if-missing : true
37-
38- legacy-test-scope :
39- needs : access-check
40- runs-on : ubuntu-latest
41- outputs :
42- run_legacy_tests : ${{ steps.scope.outputs.run_legacy_tests }}
43- steps :
44- - name : Detect changes requiring legacy tests
45- id : scope
46- env :
47- GH_TOKEN : ${{ github.token }}
48- GH_EVENT_NAME : ${{ github.event_name }}
49- PR_NUMBER : ${{ github.event.pull_request.number }}
50- REPOSITORY : ${{ github.repository }}
51- run : |
52- if [[ "$GH_EVENT_NAME" != "pull_request_target" ]]; then
53- echo "run_legacy_tests=true" >> "$GITHUB_OUTPUT"
54- exit 0
55- fi
56-
57- run_legacy_tests=false
58- while IFS= read -r file; do
59- case "$file" in
60- .codegen/*|.github/actions/*|.github/workflows/test.yml|Cargo.lock|Cargo.toml|Dockerfile|hatch.toml|mypy.ini|pyproject.toml|ruff.toml|uv.lock|crates/*|examples/*|rust-rewrite/tools/*|scripts/*|src/*|tests/*)
61- run_legacy_tests=true
62- ;;
63- esac
64- done < <(gh api --paginate "repos/$REPOSITORY/pulls/$PR_NUMBER/files" --jq '.[].filename')
65-
66- echo "run_legacy_tests=$run_legacy_tests" >> "$GITHUB_OUTPUT"
67- if [[ "$run_legacy_tests" == "true" ]]; then
68- echo "Code, package, test, or workflow files changed; running legacy tests."
69- else
70- echo "Only docs/site/planning files changed; skipping expensive legacy tests."
71- fi
9+ permissions :
10+ contents : read
7211
12+ jobs :
7313 unit-tests :
74- needs : [access-check, legacy-test-scope]
7514 runs-on : ubuntu-latest
7615 strategy :
7716 matrix :
7817 group : [1, 2, 3, 4, 5, 6, 7, 8]
79-
8018 steps :
81- - name : Skip legacy unit tests
82- if : ${{ needs.legacy-test-scope.outputs.run_legacy_tests != 'true' }}
83- run : echo "Only docs/site/planning files changed; skipping legacy unit test shard ${{ matrix.group }}."
84-
8519 - uses : actions/checkout@v4
86- if : ${{ needs.legacy-test-scope.outputs.run_legacy_tests == 'true' }}
8720 with :
8821 fetch-depth : 0
89- ref : ${{ github.event.pull_request.head.sha }}
9022
9123 - name : Setup environment
92- if : ${{ needs.legacy-test-scope.outputs.run_legacy_tests == 'true' }}
9324 uses : ./.github/actions/setup-environment
9425
9526 - name : Test with pytest
96- if : ${{ needs.legacy-test-scope.outputs.run_legacy_tests == 'true' }}
9727 timeout-minutes : 5
9828 run : |
9929 uv run pytest \
@@ -105,61 +35,14 @@ jobs:
10535 tests/unit
10636
10737 - uses : ./.github/actions/report
108- if : ${{ needs.legacy-test-scope.outputs.run_legacy_tests == 'true' }}
10938 with :
11039 flag : unit-tests
11140 codecov_token : ${{ secrets.CODECOV_TOKEN }}
11241
113- codemod-tests :
114- needs : access-check
115- # TODO: re-enable when this check is a develop required check
116- if : false
117- runs-on : ubuntu-latest
118- strategy :
119- matrix :
120- sync_graph : [true, false]
121- size : [small, large]
122- exclude :
123- # Exclude large codemod tests when not needed
124- - size : ${{(contains(github.event.pull_request.labels.*.name, 'big-codemod-tests') || github.event_name == 'push' || github.event_name == 'workflow_dispatch') && 'kevin' || 'large'}}
125- - size : large
126- sync_graph : true
127- concurrency :
128- group : ${{ github.workflow }}-${{github.ref}}-${{matrix.sync_graph}}-${{matrix.size}}-${{github.event_name == 'push'&& github.sha}}
129- cancel-in-progress : true
130- name : " Codemod tests ${{matrix.size}}: Sync Graph=${{matrix.sync_graph}}"
131- steps :
132- - uses : actions/checkout@v4
133- with :
134- ref : ${{ github.event.pull_request.head.sha }}
135-
136- - name : Setup environment
137- uses : ./.github/actions/setup-environment
138-
139- - name : Cache oss-repos
140- uses : ./.github/actions/setup-oss-repos
141-
142- - name : Run ATS and Tests
143- uses : ./.github/actions/run-ats
144- timeout-minutes : 15
145- with :
146- default_tests : " tests/integration/codemod/test_codemods.py"
147- codecov_static_token : ${{ secrets.CODECOV_STATIC_TOKEN }}
148- codecov_token : ${{ secrets.CODECOV_TOKEN }}
149- collect_args : " --size=${{matrix.size}} --sync-graph=${{matrix.sync_graph}}"
150- ats_collect_args : " --size=${{matrix.size}},--sync-graph=${{matrix.sync_graph}},"
151- codecov_flags : codemod-tests-${{matrix.size}}-${{matrix.sync_graph}}
152- env :
153- GITHUB_WORKSPACE : $GITHUB_WORKSPACE
154-
15542 parse-tests :
156- needs : access-check
157- if : contains(github.event.pull_request.labels.*.name, 'parse-tests') || github.event_name == 'push' || github.event_name == 'workflow_dispatch'
15843 runs-on : ubuntu-latest
15944 steps :
16045 - uses : actions/checkout@v4
161- with :
162- ref : ${{ github.event.pull_request.head.sha }}
16346
16447 - name : Setup environment
16548 uses : ./.github/actions/setup-environment
@@ -187,65 +70,15 @@ jobs:
18770 flag : no-flag
18871 codecov_token : ${{ secrets.CODECOV_TOKEN }}
18972
190- - name : Notify parse tests failure
191- uses : slackapi/slack-github-action@v2.1.1
192- if : failure() && github.event_name == 'push' && false
193- with :
194- webhook : ${{ secrets.SLACK_WEBHOOK_URL }}
195- webhook-type : incoming-webhook
196- payload : |
197- {
198- "blocks": [
199- {
200- "type": "header",
201- "text": {
202- "type": "plain_text",
203- "text": "❌ Parse Tests Failed",
204- "emoji": true
205- }
206- },
207- {
208- "type": "section",
209- "text": {
210- "type": "mrkdwn",
211- "text": "*Branch:* ${{ github.ref_name }}\n*Triggered by:* <${{ github.server_url }}/${{ github.actor }}|@${{ github.actor }}>\n\n*Details:*\n• <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View workflow run>"
212- }
213- },
214- {
215- "type": "context",
216- "elements": [
217- {
218- "type": "mrkdwn",
219- "text": "Failed at <!date^${{ github.event.head_commit.timestamp }}^{date_num} {time}|just now>"
220- }
221- ]
222- }
223- ]
224- }
225-
22673 integration-tests :
227- needs : [access-check, legacy-test-scope]
228- # The rust-rewrite baseline PR keeps protected checks focused on local unit,
229- # Rust, wheel, docs, and large-repo proof. These legacy integration tests push
230- # branches to an external fixture repo and require a writable PAT.
231- if : ${{ github.event_name != 'pull_request_target' || github.event.pull_request.head.ref != 'rust-rewrite' }}
23274 runs-on : ubuntu-latest
23375 steps :
234- - name : Skip legacy integration tests
235- if : ${{ needs.legacy-test-scope.outputs.run_legacy_tests != 'true' }}
236- run : echo "Only docs/site/planning files changed; skipping legacy integration tests."
237-
23876 - uses : actions/checkout@v4
239- if : ${{ needs.legacy-test-scope.outputs.run_legacy_tests == 'true' }}
240- with :
241- ref : ${{ github.event.pull_request.head.sha }}
24277
24378 - name : Setup environment
244- if : ${{ needs.legacy-test-scope.outputs.run_legacy_tests == 'true' }}
24579 uses : ./.github/actions/setup-environment
24680
24781 - name : Test with pytest
248- if : ${{ needs.legacy-test-scope.outputs.run_legacy_tests == 'true' }}
24982 timeout-minutes : 5
25083 env :
25184 GITHUB_WORKSPACE : $GITHUB_WORKSPACE
25790 tests/integration/codegen
25891
25992 - uses : ./.github/actions/report
260- if : ${{ needs.legacy-test-scope.outputs.run_legacy_tests == 'true' }}
26193 with :
26294 flag : integration-tests
26395 codecov_token : ${{ secrets.CODECOV_TOKEN }}
0 commit comments