Skip to content

Commit 8dc2a40

Browse files
authored
chore: Replace Makefile with poethepoet task runner (#57)
See apify/crawlee-python#1678 for details.
1 parent 2b10c8d commit 8dc2a40

File tree

6 files changed

+142
-119
lines changed

6 files changed

+142
-119
lines changed

.github/workflows/_tests.yaml

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,12 @@ on:
88
workflow_call:
99

1010
jobs:
11-
# Create a custom unit tests job, because apify-shared-python doesn't use codecov report.
1211
unit_tests:
1312
name: Unit tests
14-
strategy:
15-
fail-fast: false
16-
matrix:
17-
os: [ubuntu-latest, windows-latest]
18-
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
19-
runs-on: ${{ matrix.os }}
20-
21-
steps:
22-
- name: Checkout repository
23-
uses: actions/checkout@v6
24-
25-
- name: Set up Python ${{ matrix.python-version }}
26-
uses: actions/setup-python@v6
27-
with:
28-
python-version: ${{ matrix.python-version }}
29-
30-
- name: Set up uv package manager
31-
uses: astral-sh/setup-uv@v7
32-
with:
33-
python-version: ${{ matrix.python-version }}
34-
35-
- name: Install Python dependencies
36-
run: make install-dev
37-
38-
- name: Run unit tests
39-
run: make unit-tests-cov
13+
uses: apify/workflows/.github/workflows/python_unit_tests.yaml@main
14+
with:
15+
python-versions: '["3.10", "3.11", "3.12", "3.13", "3.14"]'
16+
operating-systems: '["ubuntu-latest", "windows-latest"]'
17+
# Apify shared don't use codecov, but we have to provide these inputs.
18+
python-version-for-codecov: "3.14"
19+
operating-system-for-codecov: ubuntu-latest

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ repos:
33
hooks:
44
- id: lint-check
55
name: Lint check
6-
entry: make lint
6+
entry: uv run poe lint
77
language: system
88
pass_filenames: false
99

1010
- id: type-check
1111
name: Type check
12-
entry: make type-check
12+
entry: uv run poe type-check
1313
language: system
1414
pass_filenames: false

CONTRIBUTING.md

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,37 @@ For local development, it is required to have Python 3.10 (or a later version) i
88

99
We use [uv](https://docs.astral.sh/uv/) for project management. Install it and set up your IDE accordingly.
1010

11+
We use [Poe the Poet](https://poethepoet.natn.io/) as a task runner, similar to npm scripts in `package.json`.
12+
All tasks are defined in `pyproject.toml` under `[tool.poe.tasks]` and can be run with `uv run poe <task>`.
13+
14+
### Available tasks
15+
16+
| Task | Description |
17+
| ---- | ----------- |
18+
| `install-dev` | Install development dependencies |
19+
| `check-code` | Run lint, type-check, and unit-tests |
20+
| `lint` | Run linter |
21+
| `format` | Fix lint issues and format code |
22+
| `type-check` | Run type checker |
23+
| `unit-tests` | Run unit tests |
24+
| `unit-tests-cov` | Run unit tests with coverage |
25+
| `build` | Build package |
26+
| `clean` | Remove build artifacts and clean caches |
27+
1128
## Dependencies
1229

1330
To install this package and its development dependencies, run:
1431

1532
```sh
16-
make install-dev
33+
uv run poe install-dev
1734
```
1835

1936
## Code checking
2037

2138
To execute all code checking tools together, run:
2239

2340
```sh
24-
make check-code
41+
uv run poe check-code
2542
```
2643

2744
### Linting
@@ -31,7 +48,7 @@ We utilize [ruff](https://docs.astral.sh/ruff/) for linting, which analyzes code
3148
To run linting:
3249

3350
```sh
34-
make lint
51+
uv run poe lint
3552
```
3653

3754
### Formatting
@@ -41,7 +58,7 @@ Our automated code formatting also leverages [ruff](https://docs.astral.sh/ruff/
4158
To run formatting:
4259

4360
```sh
44-
make format
61+
uv run poe format
4562
```
4663

4764
### Type checking
@@ -51,30 +68,28 @@ Type checking is handled by [ty](https://docs.astral.sh/ty/), verifying code aga
5168
To run type checking:
5269

5370
```sh
54-
make type-check
71+
uv run poe type-check
5572
```
5673

5774
### Unit tests
5875

59-
We employ pytest as our testing framework, equipped with various plugins. Check pyproject.toml for configuration details and installed plugins.
60-
6176
We use [pytest](https://docs.pytest.org/) as a testing framework with many plugins. Check `pyproject.toml` for configuration details and installed plugins.
6277

6378
To run unit tests:
6479

6580
```sh
66-
make unit-tests
81+
uv run poe unit-tests
6782
```
6883

6984
To run unit tests with HTML coverage report:
7085

7186
```sh
72-
make unit-tests-cov
87+
uv run poe unit-tests-cov
7388
```
7489

7590
## Release process
7691

77-
Publishing new versions to [PyPI](https://pypi.org/project/apify) is automated through GitHub Actions.
92+
Publishing new versions to [PyPI](https://pypi.org/project/apify-shared) is automated through GitHub Actions.
7893

7994
- **Beta releases**: On each commit to the master branch, a new beta release is automatically published. The version number is determined based on the latest release and conventional commits. The beta version suffix is incremented by 1 from the last beta release on PyPI.
8095
- **Stable releases**: A stable version release may be created by triggering the `release` GitHub Actions workflow. The version number is determined based on the latest release and conventional commits (`auto` release type), or it may be overridden using the `custom` release type.
@@ -90,18 +105,18 @@ Publishing new versions to [PyPI](https://pypi.org/project/apify) is automated t
90105

91106
```toml
92107
[project]
93-
name = "apify"
108+
name = "apify_shared"
94109
version = "x.z.y"
95110
```
96111

97-
4. Generate the distribution archives for the package:
112+
4. Build the package:
98113

99-
```shell
100-
uv build
114+
```sh
115+
uv run poe build
101116
```
102117

103-
5. Set up the PyPI API token for authentication and upload the package to PyPI:
118+
5. Upload to PyPI:
104119

105-
```shell
120+
```sh
106121
uv publish --token YOUR_API_TOKEN
107122
```

Makefile

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

pyproject.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ dependencies = []
4444
[dependency-groups]
4545
dev = [
4646
"dycw-pytest-only~=2.1.0",
47+
"poethepoet<1.0.0",
4748
"pre-commit~=4.3.0",
4849
"pytest-asyncio~=1.1.0",
4950
"pytest-cov~=6.2.0",
@@ -104,3 +105,21 @@ python-version = "3.10"
104105

105106
[tool.ty.src]
106107
include = ["src", "tests", "scripts", "docs", "website"]
108+
109+
# Run tasks with: uv run poe <task>
110+
[tool.poe.tasks]
111+
clean = "rm -rf .coverage .pytest_cache .ruff_cache .ty_cache build dist htmlcov"
112+
install-sync = "uv sync --all-extras"
113+
install-dev = "uv sync --all-extras"
114+
build = "uv build --verbose"
115+
publish-to-pypi = "uv publish --verbose --token ${APIFY_PYPI_TOKEN_CRAWLEE}"
116+
type-check = "uv run ty check"
117+
unit-tests = "uv run pytest --numprocesses=auto --verbose --cov=src/apify_shared tests/unit"
118+
unit-tests-cov = "uv run pytest --numprocesses=auto --verbose --cov=src/apify_shared --cov-report=html tests/unit"
119+
check-code = ["lint", "type-check", "unit-tests"]
120+
121+
[tool.poe.tasks.lint]
122+
shell = "uv run ruff format --check && uv run ruff check"
123+
124+
[tool.poe.tasks.format]
125+
shell = "uv run ruff check --fix && uv run ruff format"

0 commit comments

Comments
 (0)