-
Notifications
You must be signed in to change notification settings - Fork 40
195 lines (173 loc) · 5.99 KB
/
test.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
name: Tests
on:
push:
branches:
- "develop"
pull_request_target:
types: [ opened, synchronize, reopened, labeled ]
branches:
- "develop"
workflow_dispatch:
jobs:
access-check:
runs-on: ubuntu-latest
steps:
- uses: actions-cool/check-user-permission@v2
with:
require: write
username: ${{ github.triggering_actor }}
error-if-missing: true
unit-tests:
needs: access-check
runs-on: ubuntu-latest-8
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup environment
uses: ./.github/actions/setup-environment
- name: Run tests
shell: bash
run: |
uv run --frozen pytest --cov \
-o junit_suite_name="${{ github.job }}" \
-n auto \
-vv \
--cov-append \
--timeout 15 \
"tests/unit"
- uses: ./.github/actions/report
with:
flag: unit-tests
codecov_token: ${{ secrets.CODECOV_TOKEN }}
codemod-tests:
needs: access-check
# TODO: re-enable when this check is a develop required check
if: false
runs-on: ubuntu-latest-32
strategy:
matrix:
sync_graph: [ true, false ]
size: [ small, large ]
exclude:
# Exclude large codemod tests when not needed
- size: ${{(contains(github.event.pull_request.labels.*.name, 'big-codemod-tests') || github.event_name == 'push' || github.event_name == 'workflow_dispatch') && 'kevin' || 'large'}}
- size: large
sync_graph: true
concurrency:
group: ${{ github.workflow }}-${{github.ref}}-${{matrix.sync_graph}}-${{matrix.size}}-${{github.event_name == 'push'&& github.sha}}
cancel-in-progress: true
name: "Codemod tests ${{matrix.size}}: Sync Graph=${{matrix.sync_graph}}"
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup environment
uses: ./.github/actions/setup-environment
- name: Cache oss-repos
uses: ./.github/actions/setup-oss-repos
- name: Run tests
timeout-minutes: 15
shell: bash
run: |
TESTS_TO_RUN=$(uv run --frozen pytest --collect-only --size=${{matrix.size}} --sync-graph=${{matrix.sync_graph}} -q --disable-warnings --no-summary --no-header)
TESTS_TO_RUN=$(echo "${TESTS_TO_RUN}" | head -n -2)
echo $TESTS_TO_RUN | xargs uv run --frozen pytest --cov \
-o junit_suite_name="${{ github.job }}" \
-n auto \
-vv \
--cov-append \
--timeout 15 \
"tests/integration/codemod/test_codemods.py"
- uses: ./.github/actions/report
with:
flag: codemod-tests-${{matrix.size}}-${{matrix.sync_graph}}
codecov_token: ${{ secrets.CODECOV_TOKEN }}
parse-tests:
needs: access-check
if: contains(github.event.pull_request.labels.*.name, 'parse-tests') || github.event_name == 'push' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest-32
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup environment
uses: ./.github/actions/setup-environment
- name: Cache oss-repos
uses: ./.github/actions/setup-oss-repos
- name: Install yarn and pnpm
run: |
npm install -g yarn &
npm install -g pnpm
- name: Test with pytest
timeout-minutes: 15
env:
GITHUB_WORKSPACE: $GITHUB_WORKSPACE
run: |
uv run pytest \
-n auto \
-o junit_suite_name="${{github.job}}" \
tests/integration/codemod/test_parse.py
- uses: ./.github/actions/report
with:
flag: no-flag
codecov_token: ${{ secrets.CODECOV_TOKEN }}
- name: Notify parse tests failure
uses: slackapi/[email protected]
if: failure() && github.event_name == 'push' && false
with:
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
webhook-type: incoming-webhook
payload: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "❌ Parse Tests Failed",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"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>"
}
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "Failed at <!date^${{ github.event.head_commit.timestamp }}^{date_num} {time}|just now>"
}
]
}
]
}
integration-tests:
needs: access-check
runs-on: ubuntu-latest-16
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup environment
uses: ./.github/actions/setup-environment
- name: Test with pytest
timeout-minutes: 5
env:
GITHUB_WORKSPACE: $GITHUB_WORKSPACE
GITHUB_TOKEN: ${{ secrets.GHA_PAT }}
run: |
uv run pytest \
-n auto \
-o junit_suite_name="${{github.job}}" \
tests/integration/codegen
- uses: ./.github/actions/report
with:
flag: integration-tests
codecov_token: ${{ secrets.CODECOV_TOKEN }}