99
99
run : |
100
100
pip freeze
101
101
102
- - name : Setup and run tests
103
- uses : ./.github/actions/unit-tests
102
+ - name : set settings path
103
+ shell : bash
104
+ run : |
105
+ echo "settings_path=$(python scripts/unit_test_shards_parser.py --shard-name=${{ matrix.shard_name }} --output settings )" >> $GITHUB_ENV
106
+
107
+ - name : get unit tests for shard
108
+ shell : bash
109
+ run : |
110
+ echo "unit_test_paths=$(python scripts/unit_test_shards_parser.py --shard-name=${{ matrix.shard_name }} )" >> $GITHUB_ENV
111
+
112
+ - name : run tests
113
+ shell : bash
114
+ run : |
115
+ python -Wd -m pytest -p no:randomly --ds=${{ env.settings_path }} ${{ env.unit_test_paths }} --cov=.
116
+
117
+ - name : rename warnings json file
118
+ if : success()
119
+ shell : bash
120
+ run : |
121
+ cd test_root/log
122
+ mv pytest_warnings.json pytest_warnings_${{ matrix.shard_name }}.json
123
+
124
+ - name : save pytest warnings json file
125
+ if : success()
126
+ uses : actions/upload-artifact@v4
127
+ with :
128
+ name : pytest-warnings-json-${{ matrix.shard_name }}
129
+ path : |
130
+ test_root/log/pytest_warnings*.json
131
+ overwrite : true
104
132
105
133
- name : Renaming coverage data file
106
134
run : |
@@ -109,8 +137,8 @@ jobs:
109
137
- name : Upload coverage
110
138
uses : actions/upload-artifact@v4
111
139
with :
112
- name : coverage
113
- path : reports/${{matrix.shard_name}}.coverage
140
+ name : coverage-${{ matrix.shard_name }}
141
+ path : reports/${{ matrix.shard_name }}.coverage
114
142
overwrite : true
115
143
116
144
collect-and-verify :
@@ -130,8 +158,49 @@ jobs:
130
158
run : |
131
159
make test-requirements
132
160
133
- - name : verify unit tests count
134
- uses : ./.github/actions/verify-tests-count
161
+ - name : collect tests from all modules
162
+ shell : bash
163
+ run : |
164
+ echo "root_cms_unit_tests_count=$(pytest --disable-warnings --collect-only --ds=cms.envs.test cms/ -q | head -n -2 | wc -l)" >> $GITHUB_ENV
165
+ echo "root_lms_unit_tests_count=$(pytest --disable-warnings --collect-only --ds=lms.envs.test lms/ openedx/ common/djangoapps/ xmodule/ pavelib/ -q | head -n -2 | wc -l)" >> $GITHUB_ENV
166
+
167
+ - name : get GHA unit test paths
168
+ shell : bash
169
+ run : |
170
+ echo "cms_unit_test_paths=$(python scripts/gha_unit_tests_collector.py --cms-only)" >> $GITHUB_ENV
171
+ echo "lms_unit_test_paths=$(python scripts/gha_unit_tests_collector.py --lms-only)" >> $GITHUB_ENV
172
+
173
+ - name : collect tests from GHA unit test shards
174
+ shell : bash
175
+ run : |
176
+ echo "cms_unit_tests_count=$(pytest --disable-warnings --collect-only --ds=cms.envs.test ${{ env.cms_unit_test_paths }} -q | head -n -2 | wc -l)" >> $GITHUB_ENV
177
+ echo "lms_unit_tests_count=$(pytest --disable-warnings --collect-only --ds=lms.envs.test ${{ env.lms_unit_test_paths }} -q | head -n -2 | wc -l)" >> $GITHUB_ENV
178
+
179
+ - name : add unit tests count
180
+ shell : bash
181
+ run : |
182
+ echo "root_all_unit_tests_count=$((${{ env.root_cms_unit_tests_count }}+${{ env.root_lms_unit_tests_count }}))" >> $GITHUB_ENV
183
+ echo "shards_all_unit_tests_count=$((${{ env.cms_unit_tests_count }}+${{ env.lms_unit_tests_count }}))" >> $GITHUB_ENV
184
+
185
+ - name : print unit tests count
186
+ shell : bash
187
+ run : |
188
+ echo CMS unit tests from root: ${{ env.root_cms_unit_tests_count }}
189
+ echo LMS unit tests from root: ${{ env.root_lms_unit_tests_count }}
190
+ echo CMS unit tests from shards: ${{ env.cms_unit_tests_count }}
191
+ echo LMS unit tests from shards: ${{ env.lms_unit_tests_count }}
192
+ echo All root unit tests count: ${{ env.root_all_unit_tests_count }}
193
+ echo All shards unit tests count: ${{ env.shards_all_unit_tests_count }}
194
+
195
+ - name : fail the check
196
+ shell : bash
197
+ if : ${{ env.root_all_unit_tests_count != env.shards_all_unit_tests_count }}
198
+ run : |
199
+ echo "::error title='Unit test modules in unit-test-shards.json (unit-tests.yml workflow) are outdated'::unit tests running in unit-tests
200
+ workflow don't match the count for unit tests for entire edx-platform suite, please update the unit-test-shards.json under .github/workflows
201
+ to add any missing apps and match the count. for more details please take a look at scripts/gha-shards-readme.md"
202
+ exit 1
203
+
135
204
136
205
# This job aggregates test results. It's the required check for branch protection.
137
206
# https://github.com/marketplace/actions/alls-green#why
@@ -156,7 +225,8 @@ jobs:
156
225
- name : collect pytest warnings files
157
226
uses : actions/download-artifact@v4
158
227
with :
159
- name : pytest-warnings-json
228
+ pattern : pytest-warnings-json-*
229
+ merge-multiple : true
160
230
path : test_root/log
161
231
162
232
- name : display structure of downloaded files
@@ -175,6 +245,24 @@ jobs:
175
245
reports/pytest_warnings/warning_report_all.html
176
246
overwrite : true
177
247
248
+ merge-artifacts :
249
+ runs-on : ubuntu-20.04
250
+ needs : [compile-warnings-report]
251
+ steps :
252
+ - name : Merge Pytest Warnings JSON Artifacts
253
+ uses : actions/upload-artifact/merge@v4
254
+ with :
255
+ name : pytest-warnings-json
256
+ pattern : pytest-warnings-json-*
257
+ delete-merged : true
258
+
259
+ - name : Merge Coverage Artifacts
260
+ uses : actions/upload-artifact/merge@v4
261
+ with :
262
+ name : coverage
263
+ pattern : coverage-*
264
+ delete-merged : true
265
+
178
266
# Combine and upload coverage reports.
179
267
coverage :
180
268
if : (github.repository == 'edx/edx-platform-private') || (github.repository == 'openedx/edx-platform' && (startsWith(github.base_ref, 'open-release') == false))
@@ -196,7 +284,8 @@ jobs:
196
284
- name : Download all artifacts
197
285
uses : actions/download-artifact@v4
198
286
with :
199
- name : coverage
287
+ pattern : coverage-*
288
+ merge-multiple : true
200
289
path : reports
201
290
202
291
- name : Install Python dependencies
0 commit comments