Skip to content

Commit b648b85

Browse files
authored
feat: add Python workflows (#129)
1 parent 991a66a commit b648b85

File tree

5 files changed

+218
-0
lines changed

5 files changed

+218
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Docs check
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
docs_check:
8+
name: Docs check
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 Python dependencies
34+
run: |
35+
pipx install --python ${{ env.PYTHON_VERSION }} poetry
36+
make install-dev
37+
38+
- name: Build API reference
39+
run: make build-api-reference
40+
41+
- name: Build docs website
42+
run: make build-docs
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Integration tests
2+
3+
on:
4+
workflow_call:
5+
secrets:
6+
APIFY_TEST_USER_PYTHON_SDK_API_TOKEN:
7+
description: API token of the Python testing user on Apify
8+
required: true
9+
10+
# Concurrency control to ensure only one instance of this workflow runs at a time.
11+
# This avoids exceeding API usage limits on the test user account.
12+
concurrency:
13+
group: integration_tests
14+
15+
jobs:
16+
# Job to run integration tests from the main repository.
17+
integration_tests_on_main:
18+
name: Integration tests (main repository)
19+
runs-on: ubuntu-latest
20+
# If PR is from the main repository or it is a push to master.
21+
if: github.event.pull_request.head.repo.owner.login == 'apify' || github.ref == 'refs/heads/master'
22+
strategy:
23+
matrix:
24+
python-version: ["3.9", "3.12"] # Oldest and newest supported Python versions.
25+
max-parallel: 1 # No parallel tests to avoid exceeding API limits.
26+
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v4
30+
31+
- name: Set up Python ${{ matrix.python-version }}
32+
uses: actions/setup-python@v5
33+
with:
34+
python-version: ${{ matrix.python-version }}
35+
36+
- name: Install Python dependencies
37+
run: |
38+
pipx install --python ${{ matrix.python-version }} poetry
39+
make install-dev
40+
41+
- name: Run integration tests
42+
run: make INTEGRATION_TESTS_CONCURRENCY=8 integration-tests
43+
env:
44+
APIFY_TEST_USER_API_TOKEN: ${{ secrets.APIFY_TEST_USER_PYTHON_SDK_API_TOKEN }}
45+
46+
# Job to request approval before running integration tests for PRs from forks.
47+
integration_tests_on_fork_approval:
48+
name: Approve integration tests for fork PR
49+
runs-on: ubuntu-latest
50+
# If the PR is from a fork.
51+
if: github.event.pull_request.head.repo.owner.login != 'apify'
52+
environment:
53+
name: fork-pr-integration-tests
54+
url: ${{ github.event.pull_request.html_url }}
55+
steps:
56+
- name: Await approval
57+
run: echo "Waiting for approval to run integration tests for fork PR."
58+
59+
# Job to run integration tests for PRs from forks, only after manual approval.
60+
integration_tests_on_fork:
61+
name: Integration tests (fork after approval)
62+
needs: integration_tests_on_fork_approval
63+
# If the PR is from a fork.
64+
if: github.event.pull_request.head.repo.owner.login != 'apify'
65+
runs-on: ubuntu-latest
66+
strategy:
67+
matrix:
68+
python-version: ["3.9", "3.12"] # Oldest and newest supported Python versions.
69+
max-parallel: 1 # No parallel tests to avoid overshooting limits.
70+
71+
steps:
72+
- name: Checkout repository
73+
uses: actions/checkout@v4
74+
75+
- name: Set up Python ${{ matrix.python-version }}
76+
uses: actions/setup-python@v5
77+
with:
78+
python-version: ${{ matrix.python-version }}
79+
80+
- name: Install Python dependencies
81+
run: |
82+
pipx install --python ${{ matrix.python-version }} poetry
83+
make install-dev
84+
85+
- name: Run integration tests
86+
run: make INTEGRATION_TESTS_CONCURRENCY=8 integration-tests
87+
env:
88+
APIFY_TEST_USER_API_TOKEN: ${{ secrets.APIFY_TEST_USER_PYTHON_SDK_API_TOKEN }}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Lint check
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
lint_check:
8+
name: Lint check
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
python-version: ["3.9", "3.10", "3.11", "3.12"]
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Python ${{ matrix.python-version }}
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: ${{ matrix.python-version }}
22+
23+
- name: Install Python dependencies
24+
run: |
25+
pipx install --python ${{ matrix.python-version }} poetry
26+
make install-dev
27+
28+
- name: Run lint check
29+
run: make lint
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Type check
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
type_check:
8+
name: Type check
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
python-version: ["3.9", "3.10", "3.11", "3.12"]
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Python ${{ matrix.python-version }}
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: ${{ matrix.python-version }}
22+
23+
- name: Install Python dependencies
24+
run: |
25+
pipx install --python ${{ matrix.python-version }} poetry
26+
make install-dev
27+
28+
- name: Run type check
29+
run: make type-check
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Unit tests
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
unit_tests:
8+
name: Unit tests
9+
strategy:
10+
matrix:
11+
os: [ubuntu-latest, windows-latest]
12+
python-version: ["3.9", "3.10", "3.11", "3.12"]
13+
runs-on: ${{ matrix.os }}
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
24+
- name: Install Python dependencies
25+
run: |
26+
pipx install --python ${{ matrix.python-version }} poetry
27+
make install-dev
28+
29+
- name: Run unit tests
30+
run: make unit-tests

0 commit comments

Comments
 (0)