Skip to content

Commit a5dbad8

Browse files
committed
ci: use the same setup as in Crawlee
1 parent 3e33e91 commit a5dbad8

16 files changed

+301
-107
lines changed
Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
name: Check package version availability
1+
name: Check changelog entry
22

33
on:
44
workflow_call:
55

66
jobs:
7-
check_version_availability:
8-
name: Check version availability
7+
check_changelog_entry:
8+
name: Check changelog entry
99
runs-on: ubuntu-latest
1010
if: (!startsWith(github.event.pull_request.title, 'docs:'))
11+
env:
12+
PYTHON_VERSION: 3.12
1113

1214
steps:
13-
# We need to check out the head commit in case of PRs,
14-
# and the default ref otherwise (during release).
15+
# We need to check out the head commit in case of PRs, and the default ref otherwise (during release).
1516
- name: Checkout repository
1617
uses: actions/checkout@v4
1718
with:
@@ -20,12 +21,12 @@ jobs:
2021
- name: Set up Python
2122
uses: actions/setup-python@v5
2223
with:
23-
python-version: "3.9"
24+
python-version: ${{ env.PYTHON_VERSION }}
2425

2526
- name: Install dependencies
2627
run: |
27-
pipx install poetry
28+
pipx install --python ${{ env.PYTHON_VERSION }} poetry
2829
make install-dev
2930
30-
- name: Check version availability
31-
run: make check-version-availability
31+
- name: Check changelog entry
32+
run: make check-changelog-entry
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Docs build
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
docs:
8+
name: Docs build
9+
runs-on: ubuntu-latest
10+
env:
11+
NODE_VERSION: 20
12+
PYTHON_VERSION: 3.12
13+
14+
steps:
15+
- name: Checkout Source code
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Node
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: ${{ env.NODE_VERSION }}
22+
23+
- name: Enable corepack
24+
run: |
25+
corepack enable
26+
corepack prepare yarn@stable --activate
27+
28+
- name: Set up Python
29+
uses: actions/setup-python@v5
30+
with:
31+
python-version: ${{ env.PYTHON_VERSION }}
32+
33+
- name: Install dependencies
34+
run: |
35+
pipx install --python ${{ env.PYTHON_VERSION }} poetry
36+
make install-dev
37+
38+
- name: Build generated API reference
39+
run: make build-api-reference
40+
41+
- name: Install dependencies and try to build the website
42+
run: |
43+
# go to website dir
44+
cd website
45+
# install website deps
46+
yarn
47+
# build the docs
48+
yarn build
49+
env:
50+
APIFY_SIGNING_TOKEN: ${{ secrets.APIFY_SIGNING_TOKEN }}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Check version conflict
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
check_version_conflict:
8+
name: Check version conflict
9+
runs-on: ubuntu-latest
10+
if: (!startsWith(github.event.pull_request.title, 'docs:'))
11+
env:
12+
PYTHON_VERSION: 3.12
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: ${{ env.PYTHON_VERSION }}
22+
23+
- name: Install dependencies
24+
run: |
25+
pipx install --python ${{ env.PYTHON_VERSION }} poetry
26+
make install-dev
27+
28+
- name: Check version conflict
29+
run: make check-version-conflict

.github/workflows/integration_tests.yaml renamed to .github/workflows/_integration_tests.yaml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,16 @@ concurrency: # This is to make sure that only one run of this workflow is runnin
1212

1313
jobs:
1414
integration_tests:
15-
name: Run integration tests
15+
name: Integration tests
1616
runs-on: ubuntu-latest
1717
strategy:
1818
matrix:
19-
# Run integration tests only on the oldest and newest supported Python versions,
20-
# as these tests are time-consuming and these versions are the most likely to encounter issues.
21-
python-version: ["3.9", "3.12"]
19+
python-version: ["3.9", "3.10", "3.11", "3.12"]
2220
max-parallel: 1 # no concurrency on this level, to not overshoot the test user limits
2321

2422
steps:
25-
# We need to check out the head commit in case of PRs,
26-
# and the default ref otherwise (during release).
2723
- name: Checkout repository
2824
uses: actions/checkout@v4
29-
with:
30-
ref: "${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || '' }}"
3125

3226
- name: Set up Python ${{ matrix.python-version }}
3327
uses: actions/setup-python@v5
@@ -36,7 +30,7 @@ jobs:
3630

3731
- name: Install dependencies
3832
run: |
39-
pipx install poetry
33+
pipx install --python ${{ matrix.python-version }} poetry
4034
make install-dev
4135
4236
- name: Run integration tests

.github/workflows/_linting.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Linting
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
linting:
8+
name: Linting
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
python-version: ["3.9", "3.10", "3.11", "3.12"]
13+
14+
steps:
15+
# We need to check out the head commit in case of PRs, and the default ref otherwise (during release).
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
with:
19+
ref: "${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || '' }}"
20+
21+
- name: Set up Python ${{ matrix.python-version }}
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
26+
- name: Install dependencies
27+
run: |
28+
pipx install --python ${{ matrix.python-version }} poetry
29+
make install-dev
30+
31+
- name: Run linting
32+
run: make lint
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
version_number:
7+
required: true
8+
type: string
9+
10+
jobs:
11+
publish_to_pypi:
12+
name: Publish to PyPI
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
id-token: write # Required for OIDC authentication.
17+
environment:
18+
name: pypi
19+
url: https://pypi.org/project/crawlee
20+
env:
21+
PYTHON_VERSION: 3.12
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
27+
- name: Set up Python
28+
uses: actions/setup-python@v5
29+
with:
30+
python-version: ${{ env.PYTHON_VERSION }}
31+
32+
- name: Install dependencies
33+
run: |
34+
pipx install --python ${{ env.PYTHON_VERSION }} poetry
35+
make install-dev
36+
37+
# Determines the release type based on the event that triggered the workflow.
38+
- name: Determine release type
39+
id: determine-release-type
40+
run: |
41+
if [[ ${{ github.event_name }} = release ]]; then
42+
release_type="final"
43+
elif [[ ${{ github.event_name }} = push ]]; then
44+
release_type="beta"
45+
elif [[ ${{ github.event_name }} = workflow_dispatch ]]; then
46+
release_type=${{ github.event.inputs.release_type }}
47+
fi
48+
echo "release_type=${release_type}" >> $GITHUB_OUTPUT
49+
50+
# Updates the version number for pre-releases in the project's configuration.
51+
- name: Set pre-release version
52+
if: steps.determine-release-type.outputs.release_type != 'final'
53+
run: python ./scripts/update_version_for_prerelease.py ${{ steps.determine-release-type.outputs.release_type }}
54+
55+
# Builds the package.
56+
- name: Build package
57+
run: make build
58+
59+
# Publishes the package to PyPI using PyPA official GitHub action with OIDC authentication.
60+
- name: Publish package to PyPI
61+
uses: pypa/gh-action-pypi-publish@release/v1
62+
63+
# If this workflow is not triggered by a GitHub release event, manually create and push a Git tag.
64+
- name: Create Git tag with the published version
65+
if: github.event_name != 'release'
66+
run: |
67+
GIT_TAG=v$(python ./scripts/print_current_package_version.py)
68+
echo "Current package version retrieved: ${GIT_TAG}"
69+
70+
echo "Creating Git tag: ${GIT_TAG}"
71+
git tag "$GIT_TAG"
72+
echo "Git tag ${GIT_TAG} created successfully."
73+
74+
echo "Pushing Git tag ${GIT_TAG} to the remote repository."
75+
git push origin tag "$GIT_TAG"
76+
echo "Git tag ${GIT_TAG} pushed successfully."
77+
78+
# If triggered by a release, upload build artifacts to the associated GitHub release.
79+
- name: Upload the build artifacts to release
80+
if: github.event_name == 'release'
81+
run: |
82+
echo "Uploading build artifacts to GitHub release: ${{ github.ref_name }}"
83+
gh release upload ${{ github.ref_name }} dist/*
84+
echo "Build artifacts uploaded successfully."
85+
86+
env:
87+
GH_TOKEN: ${{ github.token }}
Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
name: Lint and type checks
1+
name: Type checking
22

33
on:
44
workflow_call:
55

66
jobs:
7-
lint_and_type_checks:
8-
name: Lint and type checks
7+
type_checking:
8+
name: Type checking
99
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
1212
python-version: ["3.9", "3.10", "3.11", "3.12"]
1313

1414
steps:
15-
# We need to check out the head commit in case of PRs,
16-
# and the default ref otherwise (during release).
15+
# We need to check out the head commit in case of PRs, and the default ref otherwise (during release).
1716
- name: Checkout repository
1817
uses: actions/checkout@v4
1918
with:
@@ -26,11 +25,8 @@ jobs:
2625

2726
- name: Install dependencies
2827
run: |
29-
pipx install poetry
28+
pipx install --python ${{ matrix.python-version }} poetry
3029
make install-dev
3130
32-
- name: Run lint
33-
run: make lint
34-
35-
- name: Run type checks
31+
- name: Run type checking
3632
run: make type-check

.github/workflows/unit_tests.yaml renamed to .github/workflows/_unit_tests.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,15 @@ on:
55

66
jobs:
77
unit_tests:
8-
name: Run unit tests
8+
name: Unit tests
99
strategy:
1010
matrix:
1111
os: [ubuntu-latest, windows-latest]
1212
python-version: ["3.9", "3.10", "3.11", "3.12"]
1313
runs-on: ${{ matrix.os }}
1414

1515
steps:
16-
# We need to check out the head commit in case of PRs,
17-
# and the default ref otherwise (during release).
16+
# We need to check out the head commit in case of PRs, and the default ref otherwise (during release).
1817
- name: Checkout repository
1918
uses: actions/checkout@v4
2019
with:
@@ -27,8 +26,10 @@ jobs:
2726

2827
- name: Install dependencies
2928
run: |
30-
pipx install poetry
29+
pipx install --python ${{ matrix.python-version }} poetry
3130
make install-dev
3231
3332
- name: Run unit tests
3433
run: make unit-tests
34+
env:
35+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/docs.yaml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,24 @@ jobs:
1515
pages: write
1616
id-token: write
1717
runs-on: ubuntu-latest
18+
env:
19+
NODE_VERSION: 18
20+
PYTHON_VERSION: 3.12
1821

1922
steps:
2023
- name: Checkout repository
2124
uses: actions/checkout@v4
2225
with:
2326
token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
2427

25-
- name: Set up Node.js
28+
- name: Set up Node
2629
uses: actions/setup-node@v4
2730
with:
28-
node-version: 18
31+
node-version: ${{ env.NODE_VERSION }}
2932
cache: npm
3033
cache-dependency-path: website/package-lock.json
3134

32-
- name: Install Node.js dependencies
35+
- name: Install Node dependencies
3336
run: |
3437
npm install
3538
npm update @apify/docs-theme
@@ -48,11 +51,11 @@ jobs:
4851
- name: Set up Python
4952
uses: actions/setup-python@v5
5053
with:
51-
python-version: 3.9
54+
python-version: ${{ env.PYTHON_VERSION }}
5255

5356
- name: Install dependencies
5457
run: |
55-
pipx install poetry
58+
pipx install --python ${{ matrix.python-version }} poetry
5659
make install-dev
5760
5861
- name: Build generated API reference

0 commit comments

Comments
 (0)