Skip to content

Commit 4b21bf1

Browse files
authored
Backported project setup improvements from apify-sdk-python (apify#115)
We've made a lot of project setup improvements in the Python SDK, so now that that is kind of stable, it's time to backport them to this project. (Almost) all of these changes were approved in the Python SDK, so there shouldn't be anything controversial.
1 parent 1173155 commit 4b21bf1

15 files changed

Lines changed: 98 additions & 78 deletions

.flake8

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ ignore =
2020
D409
2121
D413
2222
U101
23+
unused-arguments-ignore-overload-functions = True
24+
unused-arguments-ignore-stub-functions = True
2325
per-file-ignores =
2426
docs/*: D
2527
scripts/*: D

.github/workflows/check_docs.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
name: Check documentation status
22

3-
on: push
3+
on:
4+
workflow_call:
45

56
jobs:
67
check_docs:
78
name: Check whether documentation is up-to-date
8-
runs-on: ubuntu-20.04
9+
runs-on: ubuntu-latest
910

1011
steps:
1112
- name: Checkout repository
Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
name: Lint and test
1+
name: Lint and type checks
22

3-
on: push
3+
on:
4+
workflow_call:
45

56
jobs:
6-
lint_and_test:
7-
name: Lint, check types and run unit tests
8-
runs-on: ubuntu-20.04
7+
lint_and_type_checks:
8+
name: Lint and type checks
9+
runs-on: ubuntu-latest
910
strategy:
1011
matrix:
1112
python-version: ["3.8", "3.9", "3.10", "3.11"]
@@ -22,11 +23,8 @@ jobs:
2223
- name: Install dependencies
2324
run: make install-dev
2425

25-
- name: Lint
26+
- name: Run lint
2627
run: make lint
2728

28-
- name: Type check
29+
- name: Run type checks
2930
run: make type-check
30-
31-
- name: Unit tests
32-
run: make test
Lines changed: 11 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ on:
55
push:
66
branches:
77
- master
8+
tags-ignore:
9+
- '**'
810
# A release via GitHub releases will publish a stable version
911
release:
1012
types: [published]
@@ -22,57 +24,22 @@ on:
2224
- 'final'
2325

2426
jobs:
25-
lint_and_test:
26-
name: Lint and run unit tests
27-
runs-on: ubuntu-20.04
28-
strategy:
29-
matrix:
30-
python-version: ["3.8", "3.9", "3.10", "3.11"]
27+
lint_and_type_checks:
28+
name: Run lint and type_checks
29+
uses: ./.github/workflows/lint_and_type_checks.yaml
3130

32-
steps:
33-
- name: Checkout repository
34-
uses: actions/checkout@v3
35-
36-
- name: Set up Python ${{ matrix.python-version }}
37-
uses: actions/setup-python@v4
38-
with:
39-
python-version: ${{ matrix.python-version }}
40-
41-
- name: Install dependencies
42-
run: make install-dev
43-
44-
- name: Lint
45-
run: make lint
46-
47-
- name: Type check
48-
run: make type-check
49-
50-
- name: Unit tests
51-
run: make test
31+
unit_tests:
32+
name: Run unit tests
33+
uses: ./.github/workflows/unit_tests.yaml
5234

5335
check_docs:
5436
name: Check whether the documentation is up to date
55-
runs-on: ubuntu-20.04
56-
57-
steps:
58-
- name: Checkout repository
59-
uses: actions/checkout@v3
60-
61-
- name: Set up Python
62-
uses: actions/setup-python@v4
63-
with:
64-
python-version: 3.8
65-
66-
- name: Install dependencies
67-
run: make install-dev
68-
69-
- name: Check whether docs are built from the latest code
70-
run: make check-docs
37+
uses: ./.github/workflows/check_docs.yaml
7138

7239
deploy:
7340
name: Publish to PyPI
74-
needs: [lint_and_test, check_docs]
75-
runs-on: ubuntu-20.04
41+
needs: [lint_and_type_checks, unit_tests, check_docs]
42+
runs-on: ubuntu-latest
7643

7744
steps:
7845
- name: Checkout repository

.github/workflows/run_checks.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Code quality checks
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
lint_and_type_checks:
8+
name: Run lint and type checks
9+
uses: ./.github/workflows/lint_and_type_checks.yaml
10+
11+
unit_tests:
12+
name: Run unit tests
13+
needs: [lint_and_type_checks]
14+
uses: ./.github/workflows/unit_tests.yaml
15+
16+
check_docs:
17+
name: Check whether the documentation is up to date
18+
uses: ./.github/workflows/check_docs.yaml
19+

.github/workflows/unit_tests.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Unit tests
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
unit_tests:
8+
name: Run unit tests
9+
strategy:
10+
matrix:
11+
os: [ubuntu-latest, windows-latest]
12+
python-version: ["3.8", "3.9", "3.10", "3.11"]
13+
runs-on: ${{ matrix.os }}
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v3
18+
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
24+
- name: Install dependencies
25+
run: make install-dev
26+
27+
- name: Run unit tests
28+
run: make unit-tests

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,4 @@ build/
1414

1515
.vscode
1616
.idea
17-
18-
cli_test_client.py
1917
.DS_Store

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ repos:
77
language: system
88
pass_filenames: false
99

10-
- id: check-docs
10+
- id: check-async-docstrings
1111
name: "Check whether async docstrings are aligned with sync ones"
1212
entry: "make check-async-docstrings"
1313
language: system
@@ -21,7 +21,7 @@ repos:
2121

2222
- id: unit-test
2323
name: "Run unit tests"
24-
entry: "make test"
24+
entry: "make unit-tests"
2525
language: system
2626
pass_filenames: false
2727

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Changelog
4444
- added option to manually publish the package with a workflow dispatch
4545
- added `pre-commit` to run code quality checks before committing
4646
- converted `unittest`-style tests to `pytest`-style tests
47+
- backported project setup improvements from `apify-sdk-python`
4748

4849
[0.6.0](../../releases/tag/v0.6.0) - 2022-06-27
4950
-----------------------------------------------

0 commit comments

Comments
 (0)