Skip to content

Commit f4e053e

Browse files
authored
chore: Add test coverage reports (#1612)
- 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. - `CODECOV_TOKEN` is a repository-level secret. - Relates to: #767
1 parent 8ec1a9f commit f4e053e

File tree

5 files changed

+46
-16
lines changed

5 files changed

+46
-16
lines changed

.github/workflows/release.yaml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,9 @@ 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-
secrets:
62-
httpbin_url: ${{ secrets.APIFY_HTTPBIN_TOKEN && format('https://httpbin.apify.actor?token={0}', secrets.APIFY_HTTPBIN_TOKEN) || 'https://httpbin.org'}}
63-
with:
64-
python-versions: '["3.10", "3.11", "3.12", "3.13", "3.14"]'
65-
6658
update_changelog:
6759
name: Update changelog
68-
needs: [release_metadata, lint_check, type_check, unit_tests]
60+
needs: [release_metadata, lint_check, type_check]
6961
uses: apify/workflows/.github/workflows/python_bump_and_update_changelog.yaml@main
7062
with:
7163
version_number: ${{ needs.release_metadata.outputs.version_number }}

.github/workflows/run_code_checks.yaml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ on:
1717
workflow_dispatch:
1818

1919
jobs:
20+
actions_lint_check:
21+
name: Actions lint check
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v6
26+
- name: Run actionlint
27+
uses: rhysd/[email protected]
28+
2029
lint_check:
2130
name: Lint check
2231
uses: apify/workflows/.github/workflows/python_lint_check.yaml@main
@@ -33,10 +42,13 @@ jobs:
3342
name: Unit tests
3443
uses: apify/workflows/.github/workflows/python_unit_tests.yaml@main
3544
secrets:
36-
httpbin_url: ${{ secrets.APIFY_HTTPBIN_TOKEN && format('https://httpbin.apify.actor?token={0}', secrets.APIFY_HTTPBIN_TOKEN) || 'https://httpbin.org'}}
45+
httpbin_url: ${{ secrets.APIFY_HTTPBIN_TOKEN && format('https://httpbin.apify.actor?token={0}', secrets.APIFY_HTTPBIN_TOKEN) || 'https://httpbin.org' }}
46+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
3747
with:
3848
python-versions: '["3.10", "3.11", "3.12", "3.13", "3.14"]'
39-
os: '["ubuntu-latest", "windows-latest", "macos-latest"]'
49+
operating-systems: '["ubuntu-latest", "windows-latest", "macos-latest"]'
50+
python-version-for-codecov: "3.14"
51+
operating-system-for-codecov: ubuntu-latest
4052

4153
docs_check:
4254
name: Docs check

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ build/
2727
# Coverage reports
2828
.coverage*
2929
htmlcov
30+
coverage-unit.xml
31+
coverage-integration.xml
3032

3133
# IDE, editors
3234
.vscode

Makefile

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,36 @@ type-check:
3030
uv run mypy
3131

3232
unit-tests:
33-
uv run pytest --numprocesses=1 -vv tests/unit -m "run_alone"
34-
uv run pytest --numprocesses=auto -vv tests/unit -m "not run_alone"
33+
uv run pytest \
34+
--numprocesses=1 \
35+
--verbose \
36+
-m "run_alone" \
37+
tests/unit
38+
uv run pytest \
39+
--numprocesses=auto \
40+
--verbose \
41+
-m "not run_alone" \
42+
tests/unit
3543

3644
unit-tests-cov:
37-
uv run pytest --numprocesses=1 -vv --cov=src/crawlee tests/unit -m "run_alone"
38-
uv run pytest --numprocesses=auto -vv --cov=src/crawlee --cov-append --cov-report=html tests/unit -m "not run_alone"
45+
uv run pytest \
46+
--numprocesses=1 \
47+
--verbose \
48+
-m "run_alone" \
49+
--cov=src/crawlee \
50+
--cov-report=xml:coverage-unit.xml \
51+
tests/unit
52+
uv run pytest \
53+
--numprocesses=auto \
54+
--verbose \
55+
-m "not run_alone" \
56+
--cov=src/crawlee \
57+
--cov-report=xml:coverage-unit.xml \
58+
--cov-append \
59+
tests/unit
3960

4061
e2e-templates-tests $(args):
41-
uv run pytest --numprocesses=$(E2E_TESTS_CONCURRENCY) -vv tests/e2e/project_template "$(args)" --timeout=600
62+
uv run pytest --numprocesses=$(E2E_TESTS_CONCURRENCY) --verbose tests/e2e/project_template "$(args)" --timeout=600
4263

4364
format:
4465
uv run ruff check --fix

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
<a href="https://pypi.org/project/crawlee/" rel="nofollow">
2121
<img src="https://img.shields.io/pypi/dm/crawlee" alt="PyPI - Downloads" style="max-width: 100%;">
2222
</a>
23+
<a href="https://codecov.io/gh/apify/crawlee-python" >
24+
<img src="https://codecov.io/gh/apify/crawlee-python/graph/badge.svg?token=cCju61iPQG" alt="Code cov report" style="max-width: 100%;"/>
25+
</a>
2326
<a href="https://pypi.org/project/crawlee/" rel="nofollow">
2427
<img src="https://img.shields.io/pypi/pyversions/crawlee" alt="PyPI - Python Version" style="max-width: 100%;">
2528
</a>

0 commit comments

Comments
 (0)