Skip to content

Commit 671e323

Browse files
authored
chore: Replace Makefile with poethepoet task runner (#748)
See apify/crawlee-python#1678 for details.
1 parent e021b32 commit 671e323

File tree

8 files changed

+108
-133
lines changed

8 files changed

+108
-133
lines changed

.github/workflows/_release_docs.yaml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,10 @@ jobs:
6868
python-version: ${{ env.PYTHON_VERSION }}
6969

7070
- name: Install Python dependencies
71-
run: make install-dev
71+
run: uv run poe install-dev
7272

73-
- name: Build generated API reference
74-
run: make build-api-reference
75-
76-
- name: Build Docusaurus docs
77-
run: make build-docs
73+
- name: Build docs
74+
run: uv run poe build-docs
7875
env:
7976
APIFY_SIGNING_TOKEN: ${{ secrets.APIFY_SIGNING_TOKEN }}
8077

.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: 45 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,41 @@ 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+
| `integration-tests` | Run integration tests |
26+
| `integration-tests-cov` | Run integration tests with coverage |
27+
| `build-docs` | Build documentation website |
28+
| `run-docs` | Run documentation website locally |
29+
| `build` | Build package |
30+
| `clean` | Remove build artifacts and clean caches |
31+
1132
## Dependencies
1233

1334
To install this package and its development dependencies, run:
1435

1536
```sh
16-
make install-dev
37+
uv run poe install-dev
1738
```
1839

1940
## Code checking
2041

2142
To execute all code checking tools together, run:
2243

2344
```sh
24-
make check-code
45+
uv run poe check-code
2546
```
2647

2748
### Linting
@@ -31,7 +52,7 @@ We utilize [ruff](https://docs.astral.sh/ruff/) for linting, which analyzes code
3152
To run linting:
3253

3354
```sh
34-
make lint
55+
uv run poe lint
3556
```
3657

3758
### Formatting
@@ -41,7 +62,7 @@ Our automated code formatting also leverages [ruff](https://docs.astral.sh/ruff/
4162
To run formatting:
4263

4364
```sh
44-
make format
65+
uv run poe format
4566
```
4667

4768
### Type checking
@@ -51,78 +72,50 @@ Type checking is handled by [ty](https://docs.astral.sh/ty/), verifying code aga
5172
To run type checking:
5273

5374
```sh
54-
make type-check
75+
uv run poe type-check
5576
```
5677

5778
### Unit tests
5879

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

6382
To run unit tests:
6483

6584
```sh
66-
make unit-tests
85+
uv run poe unit-tests
6786
```
6887

69-
To run unit tests with HTML coverage report:
88+
To run unit tests with XML coverage report:
7089

7190
```sh
72-
make unit-tests-cov
91+
uv run poe unit-tests-cov
7392
```
7493

7594
## Integration tests
7695

77-
We have integration tests which build and run Actors using the Python SDK on the Apify Platform. To run these tests,
78-
you need to set the `APIFY_TEST_USER_API_TOKEN` environment variable to the API token of the Apify user you want to
79-
use for the tests, and then start them with `make integration-tests`.
80-
81-
If you want to run the integration tests on a different environment than the main Apify Platform, you need to set
82-
the `APIFY_INTEGRATION_TESTS_API_URL` environment variable to the right URL to the Apify API you want to use.
83-
84-
## Documentation
85-
86-
We adhere to the [Google docstring format](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html) for documenting our codebase. Every user-facing class or method is documented. Documentation standards are enforced using [Ruff](https://docs.astral.sh/ruff/).
87-
88-
Our API documentation is generated from these docstrings using [pydoc-markdown](https://pypi.org/project/pydoc-markdown/) with additional post-processing. Markdown files in the `docs/` folder complement the autogenerated content. Final documentation is rendered using [Docusaurus](https://docusaurus.io/) and published to GitHub Pages.
89-
90-
To run the documentation locally, you need to have Node.js version 20 or higher installed. Once you have the correct version of Node.js, follow these steps:
91-
92-
Navigate to the `website/` directory:
93-
94-
```sh
95-
cd website/
96-
```
96+
We have integration tests which build and run Actors using the Python SDK on the Apify platform.
9797

98-
Enable Corepack, which installs Yarn automatically:
98+
Prerequisites:
9999

100-
```sh
101-
corepack enable
102-
```
100+
- Set `APIFY_TEST_USER_API_TOKEN` to your Apify API token
101+
- Optionally set `APIFY_INTEGRATION_TESTS_API_URL` to use a different Apify API environment
103102

104-
Build the API reference:
103+
To run integration tests:
105104

106105
```sh
107-
./build_api_reference.sh
106+
uv run poe integration-tests
108107
```
109108

110-
Install the necessary dependencies:
111-
112-
```sh
113-
yarn
114-
```
109+
## Documentation
115110

116-
Start the project in development mode with Hot Module Replacement (HMR):
111+
We adhere to the [Google docstring format](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html) for documenting our codebase. Every user-facing class or method is documented. Documentation standards are enforced using [Ruff](https://docs.astral.sh/ruff/).
117112

118-
```sh
119-
yarn start
120-
```
113+
Our API documentation is generated from these docstrings using [pydoc-markdown](https://pypi.org/project/pydoc-markdown/) with additional post-processing. Markdown files in the `docs/` folder complement the autogenerated content. Final documentation is rendered using [Docusaurus](https://docusaurus.io/) and published to GitHub Pages.
121114

122-
Or using `make`:
115+
To run the documentation locally (requires Node.js):
123116

124117
```sh
125-
make run-doc
118+
uv run poe run-docs
126119
```
127120

128121
## Release process
@@ -147,14 +140,14 @@ name = "apify"
147140
version = "x.z.y"
148141
```
149142

150-
4. Generate the distribution archives for the package:
143+
4. Build the package:
151144

152-
```shell
153-
uv build
145+
```sh
146+
uv run poe build
154147
```
155148

156-
5. Set up the PyPI API token for authentication and upload the package to PyPI:
149+
5. Upload to PyPI:
157150

158-
```shell
151+
```sh
159152
uv publish --token YOUR_API_TOKEN
160153
```

Makefile

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

docs/02_concepts/12_pay_per_event.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ When you plan to start using the pay-per-event pricing model for an Actor that i
4343

4444
It is encouraged to test your monetization code on your machine before releasing it to the public. To tell your Actor that it should work in pay-per-event mode, pass it the `ACTOR_TEST_PAY_PER_EVENT` environment variable:
4545

46-
```shell
46+
```sh
4747
ACTOR_TEST_PAY_PER_EVENT=true python -m youractor
4848
```
4949

pyproject.toml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ dev = [
6868
"crawlee[parsel]",
6969
"dycw-pytest-only<3.0.0",
7070
"griffe",
71+
"poethepoet<1.0.0",
7172
"pre-commit<5.0.0",
7273
"pydoc-markdown<5.0.0",
7374
"pytest-asyncio<2.0.0",
@@ -216,3 +217,33 @@ exclude_lines = ["pragma: no cover", "if TYPE_CHECKING:", "assert_never()"]
216217

217218
[tool.ipdb]
218219
context = 7
220+
221+
# Run tasks with: uv run poe <task>
222+
[tool.poe.tasks]
223+
clean = "rm -rf .coverage .pytest_cache .ruff_cache .ty_cache build dist htmlcov"
224+
install-sync = "uv sync --all-extras"
225+
build = "uv build --verbose"
226+
publish-to-pypi = "uv publish --verbose --token ${APIFY_PYPI_TOKEN_CRAWLEE}"
227+
type-check = "uv run ty check"
228+
unit-tests = "uv run pytest --numprocesses=auto --verbose tests/unit"
229+
unit-tests-cov = "uv run pytest --numprocesses=auto --verbose --cov=src/apify --cov-report=xml:coverage-unit.xml tests/unit"
230+
integration-tests = "uv run pytest --numprocesses=${INTEGRATION_TESTS_CONCURRENCY:-1} --verbose tests/integration"
231+
integration-tests-cov = "uv run pytest --numprocesses=${INTEGRATION_TESTS_CONCURRENCY:-1} --verbose --cov=src/apify --cov-report=xml:coverage-integration.xml tests/integration"
232+
check-code = ["lint", "type-check", "unit-tests"]
233+
234+
[tool.poe.tasks.install-dev]
235+
shell = "uv sync --all-extras && uv run pre-commit install"
236+
237+
[tool.poe.tasks.lint]
238+
shell = "uv run ruff format --check && uv run ruff check"
239+
240+
[tool.poe.tasks.format]
241+
shell = "uv run ruff check --fix && uv run ruff format"
242+
243+
[tool.poe.tasks.build-docs]
244+
shell = "./build_api_reference.sh && npm ci && npm run build"
245+
cwd = "website"
246+
247+
[tool.poe.tasks.run-docs]
248+
shell = "./build_api_reference.sh && npm ci && npm run start"
249+
cwd = "website"

tests/integration/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ There are two different groups of integration tests in this repository:
44
- Apify API integration tests. These test that the Apify SDK is correctly communicating with Apify API through Apify client.
55
- Actor integration tests. These test that the Apify SDK can be used in Actors deployed to Apify platform. These are very high level tests, and they test communication with the API and correct interaction with the Apify platform.
66

7-
To run these tests, you need to set the `APIFY_TEST_USER_API_TOKEN` environment variable to the API token of the Apify user you want to use for the tests, and then start them with `make integration-tests`.
7+
To run these tests, you need to set the `APIFY_TEST_USER_API_TOKEN` environment variable to the API token of the Apify user you want to use for the tests, and then start them with `uv run poe integration-tests`.
88

99
## Apify API integration tests
1010
The tests are making real requests to the Apify API as opposed to the unit tests that are mocking such API calls. On the other hand they are faster than `Actor integration tests` as they do not require building and deploying the Actor. These test can be also fully debugged locally. Preferably try to write integration tests on this level if possible.

uv.lock

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)