Skip to content

Commit a26e4b4

Browse files
author
Feanil Patel
authored
Merge pull request #35034 from irtazaakram/GHartifactissue#34985
fix: gha artifact upload issues
2 parents c596736 + 4fa1a4b commit a26e4b4

File tree

4 files changed

+97
-102
lines changed

4 files changed

+97
-102
lines changed

.github/actions/unit-tests/action.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

.github/actions/verify-tests-count/action.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.

.github/dependabot.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,3 @@ updates:
77
interval: "weekly"
88
reviewers:
99
- "openedx/arbi-bom"
10-
- package-ecosystem: "github-actions"
11-
directory: "/.github/actions/unit-tests/"
12-
schedule:
13-
interval: "weekly"
14-
reviewers:
15-
- "openedx/arbi-bom"
16-
- package-ecosystem: "github-actions"
17-
directory: "/.github/actions/verify-tests-count/"
18-
schedule:
19-
interval: "weekly"
20-
reviewers:
21-
- "openedx/arbi-bom"

.github/workflows/unit-tests.yml

Lines changed: 97 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,36 @@ jobs:
9999
run: |
100100
pip freeze
101101
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
104132

105133
- name: Renaming coverage data file
106134
run: |
@@ -109,8 +137,8 @@ jobs:
109137
- name: Upload coverage
110138
uses: actions/upload-artifact@v4
111139
with:
112-
name: coverage
113-
path: reports/${{matrix.shard_name}}.coverage
140+
name: coverage-${{ matrix.shard_name }}
141+
path: reports/${{ matrix.shard_name }}.coverage
114142
overwrite: true
115143

116144
collect-and-verify:
@@ -130,8 +158,49 @@ jobs:
130158
run: |
131159
make test-requirements
132160
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+
135204
136205
# This job aggregates test results. It's the required check for branch protection.
137206
# https://github.com/marketplace/actions/alls-green#why
@@ -156,7 +225,8 @@ jobs:
156225
- name: collect pytest warnings files
157226
uses: actions/download-artifact@v4
158227
with:
159-
name: pytest-warnings-json
228+
pattern: pytest-warnings-json-*
229+
merge-multiple: true
160230
path: test_root/log
161231

162232
- name: display structure of downloaded files
@@ -175,6 +245,24 @@ jobs:
175245
reports/pytest_warnings/warning_report_all.html
176246
overwrite: true
177247

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+
178266
# Combine and upload coverage reports.
179267
coverage:
180268
if: (github.repository == 'edx/edx-platform-private') || (github.repository == 'openedx/edx-platform' && (startsWith(github.base_ref, 'open-release') == false))
@@ -196,7 +284,8 @@ jobs:
196284
- name: Download all artifacts
197285
uses: actions/download-artifact@v4
198286
with:
199-
name: coverage
287+
pattern: coverage-*
288+
merge-multiple: true
200289
path: reports
201290

202291
- name: Install Python dependencies

0 commit comments

Comments
 (0)