Skip to content

Commit c17633d

Browse files
feanilclaude
andcommitted
build: collect per-test timing data.
Run pytest with extra reporting enabled to generate files with per-test durations. The file is uploaded as a CI artifact so timing data can be downloaded and used to drive optimal shard rebalancing. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 0d8b828 commit c17633d

4 files changed

Lines changed: 17 additions & 1 deletion

File tree

.github/workflows/unit-tests.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,16 @@ jobs:
119119
- name: run tests
120120
shell: bash
121121
run: |
122-
python -Wd -m pytest -p no:randomly --ds=${{ env.settings_path }} ${{ env.unit_test_paths }} --cov=.
122+
python -Wd -m pytest -p no:randomly --ds=${{ env.settings_path }} ${{ env.unit_test_paths }} --cov=. \
123+
--report-log=reports/pytest-report-${{ matrix.shard_name }}.jsonl
124+
125+
- name: Upload pytest timing report
126+
if: always()
127+
uses: actions/upload-artifact@v7
128+
with:
129+
name: pytest-report-${{ matrix.shard_name }}-${{ matrix.python-version }}-${{ matrix.django-version }}-${{ matrix.mongo-version }}-${{ matrix.os-version }}
130+
path: reports/pytest-report-${{ matrix.shard_name }}.jsonl
131+
overwrite: true
123132

124133
- name: rename warnings json file
125134
if: success()

requirements/edx/development.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,6 +1719,7 @@ pytest==8.2.0
17191719
# pytest-json-report
17201720
# pytest-metadata
17211721
# pytest-randomly
1722+
# pytest-reportlog
17221723
# pytest-xdist
17231724
pytest-attrib==0.1.3
17241725
# via -r requirements/edx/testing.txt
@@ -1734,6 +1735,8 @@ pytest-metadata==3.1.1
17341735
# pytest-json-report
17351736
pytest-randomly==4.0.1
17361737
# via -r requirements/edx/testing.txt
1738+
pytest-reportlog==1.0.0
1739+
# via -r requirements/edx/testing.txt
17371740
pytest-xdist[psutil]==3.8.0
17381741
# via -r requirements/edx/testing.txt
17391742
python-dateutil==2.9.0.post0

requirements/edx/testing.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ pytest-django # Django support for pytest
3838
pytest-json-report # Output json formatted warnings after running pytest
3939
pytest-metadata # To prevent 'make upgrade' failure, dependency of pytest-json-report
4040
pytest-randomly # pytest plugin to randomly order tests
41+
pytest-reportlog # Per-test timing data including setup/teardown (used for shard rebalancing)
4142
pytest-xdist[psutil] # Parallel execution of tests on multiple CPU cores or hosts
4243
singledispatch # Backport of functools.singledispatch from Python 3.4+, used in tests of XBlock rendering
4344
testfixtures # Provides a LogCapture utility used by several tests

requirements/edx/testing.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,6 +1305,7 @@ pytest==8.2.0
13051305
# pytest-json-report
13061306
# pytest-metadata
13071307
# pytest-randomly
1308+
# pytest-reportlog
13081309
# pytest-xdist
13091310
pytest-attrib==0.1.3
13101311
# via -r requirements/edx/testing.in
@@ -1320,6 +1321,8 @@ pytest-metadata==3.1.1
13201321
# pytest-json-report
13211322
pytest-randomly==4.0.1
13221323
# via -r requirements/edx/testing.in
1324+
pytest-reportlog==1.0.0
1325+
# via -r requirements/edx/testing.in
13231326
pytest-xdist[psutil]==3.8.0
13241327
# via -r requirements/edx/testing.in
13251328
python-dateutil==2.9.0.post0

0 commit comments

Comments
 (0)