Skip to content

Commit d9f478c

Browse files
authored
chore: Add test coverage reports (#558)
- Add a code coverage badge to the README. - Update the `pre_release` and `run_code_checks` test pipeline invocations. - Remove the unit test call from the `release` workflow. Since this workflow is triggered only manually, the caller should ensure the package is OK (and also often the flakiness factor). - Update pytest invocations in the Makefile. - Collect coverage from both unit and integration tests and combine them into a single report. - `CODECOV_TOKEN` is a repository-level secret. - Relates to: apify/crawlee-python#767
1 parent c451d97 commit d9f478c

File tree

6 files changed

+66
-23
lines changed

6 files changed

+66
-23
lines changed

.github/workflows/pre_release.yaml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ jobs:
3232
release_type: prerelease
3333
existing_changelog_path: CHANGELOG.md
3434

35+
actions_lint_check:
36+
name: Actions lint check
37+
runs-on: ubuntu-latest
38+
steps:
39+
- name: Checkout repository
40+
uses: actions/checkout@v6
41+
- name: Run actionlint
42+
uses: rhysd/actionlint@v1.7.9
43+
3544
lint_check:
3645
name: Lint check
3746
uses: apify/workflows/.github/workflows/python_lint_check.yaml@main
@@ -47,8 +56,12 @@ jobs:
4756
unit_tests:
4857
name: Unit tests
4958
uses: apify/workflows/.github/workflows/python_unit_tests.yaml@main
59+
secrets: inherit
5060
with:
5161
python-versions: '["3.10", "3.11", "3.12", "3.13", "3.14"]'
62+
operating-systems: '["ubuntu-latest", "windows-latest"]'
63+
python-version-for-codecov: "3.14"
64+
operating-system-for-codecov: ubuntu-latest
5265

5366
async_docstrings:
5467
name: Async dostrings check
@@ -59,7 +72,10 @@ jobs:
5972
uses: apify/workflows/.github/workflows/python_integration_tests.yaml@main
6073
secrets: inherit
6174
with:
62-
python-versions: '["3.10", "3.11", "3.12", "3.13", "3.14"]'
75+
python-versions: '["3.10", "3.14"]'
76+
operating-systems: '["ubuntu-latest"]'
77+
python-version-for-codecov: "3.14"
78+
operating-system-for-codecov: ubuntu-latest
6379

6480
update_changelog:
6581
name: Update changelog

.github/workflows/release.yaml

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,26 +55,13 @@ jobs:
5555
with:
5656
python-versions: '["3.10", "3.11", "3.12", "3.13", "3.14"]'
5757

58-
unit_tests:
59-
name: Unit tests
60-
uses: apify/workflows/.github/workflows/python_unit_tests.yaml@main
61-
with:
62-
python-versions: '["3.10", "3.11", "3.12", "3.13", "3.14"]'
63-
6458
async_docstrings:
6559
name: Async dostrings check
6660
uses: ./.github/workflows/_async_docstrings_check.yaml
6761

68-
integration_tests:
69-
name: Integration tests
70-
uses: apify/workflows/.github/workflows/python_integration_tests.yaml@main
71-
secrets: inherit
72-
with:
73-
python-versions: '["3.10", "3.11", "3.12", "3.13", "3.14"]'
74-
7562
update_changelog:
7663
name: Update changelog
77-
needs: [release_metadata, lint_check, type_check, unit_tests, integration_tests]
64+
needs: [release_metadata, lint_check, type_check]
7865
uses: apify/workflows/.github/workflows/python_bump_and_update_changelog.yaml@main
7966
with:
8067
version_number: ${{ needs.release_metadata.outputs.version_number }}

.github/workflows/run_code_checks.yaml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ on:
1212
workflow_dispatch:
1313

1414
jobs:
15+
actions_lint_check:
16+
name: Actions lint check
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v6
21+
- name: Run actionlint
22+
uses: rhysd/actionlint@v1.7.9
23+
1524
lint_check:
1625
name: Lint check
1726
uses: apify/workflows/.github/workflows/python_lint_check.yaml@main
@@ -27,8 +36,12 @@ jobs:
2736
unit_tests:
2837
name: Unit tests
2938
uses: apify/workflows/.github/workflows/python_unit_tests.yaml@main
39+
secrets: inherit
3040
with:
3141
python-versions: '["3.10", "3.11", "3.12", "3.13", "3.14"]'
42+
operating-systems: '["ubuntu-latest", "windows-latest"]'
43+
python-version-for-codecov: "3.14"
44+
operating-system-for-codecov: ubuntu-latest
3245

3346
async_docstrings:
3447
name: Async dostrings check
@@ -42,6 +55,9 @@ jobs:
4255
name: Integration tests
4356
needs: [lint_check, type_check, unit_tests]
4457
uses: apify/workflows/.github/workflows/python_integration_tests.yaml@main
45-
with:
46-
python-versions: '["3.10", "3.11", "3.12", "3.13", "3.14"]'
4758
secrets: inherit
59+
with:
60+
python-versions: '["3.10", "3.14"]'
61+
operating-systems: '["ubuntu-latest"]'
62+
python-version-for-codecov: "3.14"
63+
operating-system-for-codecov: ubuntu-latest

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ build/
2424
# Coverage reports
2525
.coverage*
2626
htmlcov
27+
coverage-unit.xml
28+
coverage-integration.xml
2729

2830
# IDE, editors
2931
.vscode

Makefile

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
.PHONY: clean install-dev build publish-to-pypi lint type-check unit-tests unit-tests-cov \
2-
integration-tests format check-async-docstrings check-code fix-async-docstrings \
3-
build-api-reference build-docs run-docs
1+
.PHONY: clean install-dev build publish-to-pypi lint type-check unit-tests unit-tests-cov integration-tests \
2+
integration-tests-cov format check-async-docstrings check-code fix-async-docstrings build-api-reference \
3+
build-docs run-docs
44

55
# This is default for local testing, but GitHub workflows override it to a higher value in CI
66
INTEGRATION_TESTS_CONCURRENCY = 1
@@ -27,13 +27,32 @@ type-check:
2727
uv run mypy
2828

2929
unit-tests:
30-
uv run pytest --numprocesses=auto --verbose --cov=src/apify_client tests/unit
30+
uv run pytest \
31+
--numprocesses=auto \
32+
--verbose \
33+
tests/unit
3134

3235
unit-tests-cov:
33-
uv run pytest --numprocesses=auto --verbose --cov=src/apify_client --cov-report=html tests/unit
36+
uv run pytest \
37+
--numprocesses=auto \
38+
--verbose \
39+
--cov=src/apify_client \
40+
--cov-report=xml:coverage-unit.xml \
41+
tests/unit
3442

3543
integration-tests:
36-
uv run pytest --numprocesses=$(INTEGRATION_TESTS_CONCURRENCY) --verbose tests/integration
44+
uv run pytest \
45+
--numprocesses=$(INTEGRATION_TESTS_CONCURRENCY) \
46+
--verbose \
47+
tests/integration
48+
49+
integration-tests-cov:
50+
uv run pytest \
51+
--numprocesses=$(INTEGRATION_TESTS_CONCURRENCY) \
52+
--verbose \
53+
--cov=src/apify_client \
54+
--cov-report=xml:coverage-integration.xml \
55+
tests/integration
3756

3857
format:
3958
uv run ruff check --fix

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
<a href="https://pypi.org/project/apify-client/" rel="nofollow">
88
<img src="https://img.shields.io/pypi/dm/apify-client" alt="PyPI - Downloads" style="max-width: 100%;">
99
</a>
10+
<a href="https://codecov.io/gh/apify/apify-client-python" >
11+
<img src="https://codecov.io/gh/apify/apify-client-python/graph/badge.svg?token=TYQQWYYZ7A" alt="Code cov report" style="max-width: 100%;"/>
12+
</a>
1013
<a href="https://pypi.org/project/apify-client/" rel="nofollow">
1114
<img src="https://img.shields.io/pypi/pyversions/apify-client" alt="PyPI - Python version" style="max-width: 100%;">
1215
</a>

0 commit comments

Comments
 (0)