Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit de5e284

Browse files
authored
dev: Pytest-split test (#1144)
1 parent 5fb43ea commit de5e284

File tree

6 files changed

+2790
-13
lines changed

6 files changed

+2790
-13
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
test:
5050
name: Test
5151
needs: [build]
52-
uses: codecov/gha-workflows/.github/workflows/[email protected].27
52+
uses: codecov/gha-workflows/.github/workflows/run-tests-split[email protected].29
5353
secrets: inherit
5454
with:
5555
repo: ${{ vars.CODECOV_IMAGE_V2 || 'codecov/self-hosted-api' }}

.test_durations

Lines changed: 2755 additions & 0 deletions
Large diffs are not rendered by default.

Makefile

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,18 @@ test:
3434
COVERAGE_CORE=sysmon python -m pytest --cov=./ --junitxml=junit.xml -o junit_family=legacy
3535

3636
test.unit:
37-
COVERAGE_CORE=sysmon python -m pytest --cov=./ -m "not integration" --cov-report=xml:unit.coverage.xml --junitxml=unit.junit.xml -o junit_family=legacy
37+
@if [ -n "$(GROUP)" ]; then \
38+
COVERAGE_CORE=sysmon python -m pytest --splits ${SPLIT} --group $(GROUP) --cov=./ -m "not integration" --cov-report=xml:unit.$(GROUP).coverage.xml --junitxml=unit.$(GROUP).junit.xml -o junit_family=legacy; \
39+
else \
40+
COVERAGE_CORE=sysmon python -m pytest --cov=./ -m "not integration" --cov-report=xml:unit.coverage.xml --junitxml=unit.junit.xml -o junit_family=legacy; \
41+
fi
3842

3943
test.integration:
40-
COVERAGE_CORE=sysmon python -m pytest --cov=./ -m "integration" --cov-report=xml:integration.coverage.xml --junitxml=integration.junit.xml -o junit_family=legacy
44+
@if [ -n "$(GROUP)" ]; then \
45+
COVERAGE_CORE=sysmon python -m pytest --splits ${SPLIT} --group $(GROUP) --cov=./ -m "integration" --cov-report=xml:integration.$(GROUP).coverage.xml --junitxml=integration.$(GROUP).junit.xml -o junit_family=legacy; \
46+
else \
47+
COVERAGE_CORE=sysmon python -m pytest --cov=./ -m "integration" --cov-report=xml:integration.coverage.xml --junitxml=integration.junit.xml -o junit_family=legacy; \
48+
fi
4149

4250
lint:
4351
make lint.install
@@ -205,10 +213,18 @@ test_env.container_check_db:
205213
while ! nc -vz timescale 5432; do sleep 1; echo "waiting for timescale"; done
206214

207215
test_env.run_unit:
208-
docker-compose exec api make test.unit
216+
@if [ -n "$(GROUP)" ]; then \
217+
docker-compose exec api make test.unit SPLIT=${SPLIT} GROUP=${GROUP}; \
218+
else \
219+
docker-compose exec api make test.unit; \
220+
fi
209221

210222
test_env.run_integration:
211-
#docker-compose exec api make test.integration
223+
# @if [ -n "$(GROUP)" ]; then \
224+
# docker-compose exec api make test.integration SPLIT=${SPLIT} GROUP=${GROUP}; \
225+
# else \
226+
# docker-compose exec api make test.integration; \
227+
# fi
212228
echo "Skipping. No Tests"
213229

214230
test_env.check-for-migration-conflicts:

graphql_api/tests/test_pull.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from datetime import datetime, timedelta
33
from unittest.mock import patch
44

5+
import pytest
56
from django.test import TransactionTestCase
67
from freezegun import freeze_time
78
from shared.api_archive.archive import ArchiveService
@@ -459,27 +460,28 @@ def test_with_complete_pull_request(self):
459460
"behindByCommit": "1089nf898as-jdf09hahs09fgh",
460461
}
461462

463+
@pytest.mark.skip(
464+
reason="Skipping due to https://github.com/codecov/engineering-team/issues/3358"
465+
)
462466
def test_compare_bundle_analysis_missing_reports(self):
467+
repository = RepositoryFactory(author=self.owner)
463468
head = CommitFactory(
464-
repository=self.repository,
469+
repository=repository,
465470
author=self.owner,
466-
commitid="5672734ij1n234918231290j12nasdfioasud0f9",
471+
commitid="cool-commit-id",
467472
totals={"c": "78.38", "diff": [0, 0, 0, 0, 0, "14"]},
468473
)
469474
compared_to = CommitFactory(
470-
repository=self.repository,
475+
repository=repository,
471476
author=self.owner,
472-
commitid="9asd78fa7as8d8fa97s8d7fgagsd8fa9asd8f77s",
477+
commitid="blah",
473478
)
474479

475480
my_pull = PullFactory(
476-
repository=self.repository,
477-
title="test-pull-request",
481+
repository=repository,
478482
author=self.owner,
479483
head=head.commitid,
480484
compared_to=compared_to.commitid,
481-
behind_by=23,
482-
behind_by_commit="1089nf898as-jdf09hahs09fgh",
483485
)
484486

485487
pull = self.fetch_one_pull_request(

requirements.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ pytest-cov
4343
pytest-django
4444
pytest-mock
4545
pytest>=7.2.0
46+
pytest-split
4647
python-dateutil
4748
python-json-logger
4849
python-redis-lock

requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ pytest==8.1.1
360360
# pytest-cov
361361
# pytest-django
362362
# pytest-mock
363+
# pytest-split
363364
pytest-asyncio==0.23.6
364365
# via -r requirements.in
365366
pytest-cov==5.0.0
@@ -368,6 +369,8 @@ pytest-django==4.8.0
368369
# via -r requirements.in
369370
pytest-mock==3.14.0
370371
# via -r requirements.in
372+
pytest-split==0.10.0
373+
# via -r requirements.in
371374
python-dateutil==2.9.0.post0
372375
# via
373376
# -r requirements.in

0 commit comments

Comments
 (0)