Skip to content

Commit

Permalink
chore: migrate to Poetry and update tooling just like in Crawlee (#262)
Browse files Browse the repository at this point in the history
### Description

- Migrate to Poetry for packaging and dependency management.
- Update versions of dev tools.
- Take some tooling settings from Crawlee.
- Drop support for Python 3.8 as it's gonna be deprecated very soon -
gonna release this as 1.8.0.

### Issues

- Closes: #170 

### Testing

- N/A

### Checklist

- [x] CI passed
  • Loading branch information
vdusek authored Aug 30, 2024
1 parent a19fe3a commit 042746f
Show file tree
Hide file tree
Showing 17 changed files with 260 additions and 169 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/check_pr_title.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Check PR title

on:
pull_request_target:
types: [opened, edited, synchronize]

jobs:
check_pr_title:
name: Check PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/integration_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
max-parallel: 1 # no concurrency on this level, to not overshoot the test user limits

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint_and_type_checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- name: Checkout repository
Expand Down
12 changes: 4 additions & 8 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,12 @@ jobs:
if: steps.get-release-type.outputs.release_type != 'final'
run: python ./scripts/update_version_for_prerelease.py ${{ steps.get-release-type.outputs.release_type }}

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

- # Check whether the package description will render correctly on PyPI
name: Check package rendering on PyPI
run: make twine-check

- # Publish package to PyPI using their official GitHub action
name: Publish package to PyPI
# Publishes the package to PyPI using PyPA official GitHub action with OIDC authentication.
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

- # Tag the current commit with the version tag if this is not made from the release event (releases are tagged with the release process)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
runs-on: ${{ matrix.os }}

steps:
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/update_new_issue.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Update new issue

on:
issues:
types:
- opened

jobs:
label_issues:
name: Label issues
runs-on: ubuntu-latest
permissions:
issues: write

steps:
# Add the "t-tooling" label to all new issues
- uses: actions/github-script@v7
with:
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ["t-tooling"]
})
16 changes: 8 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ repos:
language: system
pass_filenames: false

- id: check-async-docstrings
name: Check whether async docstrings are aligned with sync ones
entry: make check-async-docstrings
language: system
pass_filenames: false

- id: type-check
name: Type-check codebase
entry: make type-check
Expand All @@ -25,8 +19,14 @@ repos:
language: system
pass_filenames: false

- id: check-changelog
name: Check whether current version is mentioned in changelog
- id: check-async-docstrings
name: Check whether async docstrings are aligned with sync ones
entry: make check-async-docstrings
language: system
pass_filenames: false

- id: check-changelog-entry
name: Check changelog entry
entry: make check-changelog-entry
language: system
pass_filenames: false
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# Changelog

## [1.7.2](../../releases/tag/v1.7.2) - Unreleased
## [1.8.0](../../releases/tag/v1.8.0) - Unreleased

### Added

- add `headers_template` kwarg to webhook create and update
- allow passing list of fields to `unwind` parameter in dataset item listing endpoints

### Others

- drop support for Python 3.8

## [1.7.1](../../releases/tag/v1.7.1) - 2024-07-11

### Fixed
Expand Down
57 changes: 31 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,59 +1,64 @@
.PHONY: clean install-dev build publish twine-check lint unit-tests integration-tests type-check check-code format check-async-docstrings fix-async-docstrings check-version-availability check-changelog-entry build-api-reference
.PHONY: clean install-dev build publish-to-pypi lint type-check unit-tests unit-tests-cov integration-tests format check-code check-async-docstrings fix-async-docstrings check-version-availability check-changelog-entry build-api-reference run-doc

DIRS_WITH_CODE = src tests scripts

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

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

install-dev:
python3 -m pip install --upgrade pip
pip install --no-cache-dir -e ".[dev]"
pre-commit install
python3 -m pip install --upgrade pip poetry
poetry install --all-extras
poetry run pre-commit install

build:
python3 -m build
poetry build --no-interaction -vv

publish:
python3 -m twine upload dist/*

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

lint:
python3 -m ruff check $(DIRS_WITH_CODE)
poetry run ruff format --check $(DIRS_WITH_CODE)
poetry run ruff check $(DIRS_WITH_CODE)

type-check:
poetry run mypy $(DIRS_WITH_CODE)

unit-tests:
python3 -m pytest --numprocesses=auto --verbose -ra --cov=src/apify_client tests/unit
poetry run pytest --numprocesses=auto --verbose --cov=src/apify_client tests/unit

unit-tests-cov:
python3 -m pytest --numprocesses=auto --verbose -ra --cov=src/apify_client --cov-report=html tests/unit
poetry run pytest --numprocesses=auto --verbose --cov=src/apify_client --cov-report=html tests/unit

integration-tests:
python3 -m pytest --numprocesses=$(INTEGRATION_TESTS_CONCURRENCY) --verbose -ra tests/integration

type-check:
python3 -m mypy $(DIRS_WITH_CODE)

check-code: lint check-async-docstrings type-check unit-tests
poetry run pytest --numprocesses=$(INTEGRATION_TESTS_CONCURRENCY) tests/integration

format:
python3 -m ruff check --fix $(DIRS_WITH_CODE)
python3 -m ruff format $(DIRS_WITH_CODE)
poetry run ruff check --fix $(DIRS_WITH_CODE)
poetry run ruff format $(DIRS_WITH_CODE)

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

check-async-docstrings:
python3 scripts/check_async_docstrings.py
poetry run python scripts/check_async_docstrings.py

fix-async-docstrings:
python3 scripts/fix_async_docstrings.py
poetry run python scripts/fix_async_docstrings.py

check-version-availability:
python3 scripts/check_version_availability.py
poetry run python scripts/check_version_availability.py

check-changelog-entry:
python3 scripts/check_version_in_changelog.py
poetry run python scripts/check_version_in_changelog.py

build-api-reference:
cd website && ./build_api_reference.sh

run-doc: build-api-reference
cd website && npm clean-install && npm run start
16 changes: 0 additions & 16 deletions mypy.ini

This file was deleted.

Loading

0 comments on commit 042746f

Please sign in to comment.