Skip to content

Commit 85315df

Browse files
vdusekjanbuchar
andauthored
chore: migrate to Poetry and update tooling just like in Crawlee (#247)
### Description - Migrate to Poetry for packaging and dependency management. - Update versions of dev tools. - Take some tooling settings from Crawlee. ### Issues - Closes: #156 ### Testing - N/A ### Checklist - [x] CI passed --------- Co-authored-by: Jan Buchar <[email protected]>
1 parent 47ca815 commit 85315df

39 files changed

+646
-420
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Check PR title
2+
3+
on:
4+
pull_request_target:
5+
types: [opened, edited, synchronize]
6+
7+
jobs:
8+
check_pr_title:
9+
name: Check PR title
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: amannn/[email protected]
13+
env:
14+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yaml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,12 @@ jobs:
104104
if: steps.get-release-type.outputs.release_type != 'final'
105105
run: python ./scripts/update_version_for_prerelease.py ${{ steps.get-release-type.outputs.release_type }}
106106

107-
- # Build a source distribution and a python3-only wheel
108-
name: Build distribution files
107+
# Builds the package.
108+
- name: Build package
109109
run: make build
110110

111-
- # Check whether the package description will render correctly on PyPI
112-
name: Check package rendering on PyPI
113-
run: make twine-check
114-
115-
- # Publish package to PyPI using their official GitHub action
116-
name: Publish package to PyPI
111+
# Publishes the package to PyPI using PyPA official GitHub action with OIDC authentication.
112+
- name: Publish package to PyPI
117113
uses: pypa/gh-action-pypi-publish@release/v1
118114

119115
- # Tag the current commit with the version tag if this is not made from the release event (releases are tagged with the release process)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Update new issue
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
label_issues:
8+
name: Label issues
9+
runs-on: ubuntu-latest
10+
permissions:
11+
issues: write
12+
13+
steps:
14+
# Add the "t-tooling" label to all new issues
15+
- uses: actions/github-script@v7
16+
with:
17+
script: |
18+
github.rest.issues.addLabels({
19+
issue_number: context.issue.number,
20+
owner: context.repo.owner,
21+
repo: context.repo.repo,
22+
labels: ["t-tooling"]
23+
})

.pre-commit-config.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,14 @@ repos:
1919
language: system
2020
pass_filenames: false
2121

22-
- id: check-changelog
23-
name: Check whether current version is mentioned in changelog
22+
- id: check-changelog-entry
23+
name: Check changelog entry
2424
entry: make check-changelog-entry
2525
language: system
2626
pass_filenames: false
27+
28+
- id: check-version-conflict
29+
name: Check version conflict
30+
entry: make check-version-conflict
31+
language: system
32+
pass_filenames: false

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Changelog
22

3-
## [1.7.3](../../releases/tag/v1.7.3) - Unreleased
3+
## [2.0.0](../../releases/tag/v2.0.0) - Unreleased
44

55
### Added
66

Makefile

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,58 @@
1-
.PHONY: clean install-dev build publish twine-check lint unit-tests integration-tests type-check check-code format check-version-availability check-changelog-entry build-api-reference
1+
.PHONY: clean install-dev build publish-to-pypi lint type-check unit-tests unit-tests-cov integration-tests format check-code check-version-availability check-changelog-entry build-api-reference run-doc
22

33
DIRS_WITH_CODE = src tests scripts
44

55
# This is default for local testing, but GitHub workflows override it to a higher value in CI
66
INTEGRATION_TESTS_CONCURRENCY = 1
77

88
clean:
9-
rm -rf build dist .mypy_cache .pytest_cache .ruff_cache src/*.egg-info __pycache__
9+
rm -rf .mypy_cache .pytest_cache .ruff_cache build dist htmlcov .coverage
1010

1111
install-dev:
12-
python3 -m pip install --upgrade pip
13-
pip install --no-cache-dir -e ".[dev,scrapy]"
14-
pre-commit install
12+
python3 -m pip install --upgrade pip poetry
13+
poetry install --all-extras
14+
poetry run pre-commit install
1515

1616
build:
17-
python3 -m build
17+
poetry build --no-interaction -vv
1818

19-
publish:
20-
python3 -m twine upload dist/*
21-
22-
twine-check:
23-
python3 -m twine check dist/*
19+
# APIFY_PYPI_TOKEN_CRAWLEE is expected to be set in the environment
20+
publish-to-pypi:
21+
poetry config pypi-token.pypi "${APIFY_PYPI_TOKEN_CRAWLEE}"
22+
poetry publish --no-interaction -vv
2423

2524
lint:
26-
python3 -m ruff check $(DIRS_WITH_CODE)
25+
poetry run ruff format --check $(DIRS_WITH_CODE)
26+
poetry run ruff check $(DIRS_WITH_CODE)
27+
28+
type-check:
29+
poetry run mypy $(DIRS_WITH_CODE)
2730

2831
unit-tests:
29-
python3 -m pytest --numprocesses=auto --verbose -ra --cov=src/apify tests/unit
32+
poetry run pytest --numprocesses=auto --verbose --cov=src/apify tests/unit
3033

3134
unit-tests-cov:
32-
python3 -m pytest --numprocesses=auto --verbose -ra --cov=src/apify --cov-report=html tests/unit
35+
poetry run pytest --numprocesses=auto --verbose --cov=src/apify --cov-report=html tests/unit
3336

3437
integration-tests:
35-
python3 -m pytest --numprocesses=$(INTEGRATION_TESTS_CONCURRENCY) --verbose -ra tests/integration
38+
poetry run pytest --numprocesses=$(INTEGRATION_TESTS_CONCURRENCY) tests/integration
3639

37-
type-check:
38-
python3 -m mypy $(DIRS_WITH_CODE)
40+
format:
41+
poetry run ruff check --fix $(DIRS_WITH_CODE)
42+
poetry run ruff format $(DIRS_WITH_CODE)
3943

44+
# The check-code target runs a series of checks equivalent to those performed by pre-commit hooks
45+
# and the run_checks.yaml GitHub Actions workflow.
4046
check-code: lint type-check unit-tests
4147

42-
format:
43-
python3 -m ruff check --fix $(DIRS_WITH_CODE)
44-
python3 -m ruff format $(DIRS_WITH_CODE)
45-
4648
check-version-availability:
47-
python3 scripts/check_version_availability.py
49+
poetry run python scripts/check_version_availability.py
4850

4951
check-changelog-entry:
50-
python3 scripts/check_version_in_changelog.py
52+
poetry run python scripts/check_version_in_changelog.py
5153

5254
build-api-reference:
5355
cd website && ./build_api_reference.sh
56+
57+
run-doc: build-api-reference
58+
cd website && npm clean-install && npm run start

0 commit comments

Comments
 (0)