Skip to content

Commit 45e3279

Browse files
authored
ci: Gate manual release workflows on wait-for-checks (#826)
## Summary Ports the CI consolidation and `wait-for-checks` adoption from `crawlee-python` to `apify-client-python`. See [apify/crawlee-python#1913](apify/crawlee-python#1913) for the original rationale and PR description; the follow-up permission fixes from [#1914](apify/crawlee-python#1914) and [#1915](apify/crawlee-python#1915) are baked in here. Two commits: 1. **Consolidate check workflows into a single Checks workflow** — merges `_check_code.yaml`, `_check_docs.yaml`, `_check_docstrings.yaml`, `_check_package.yaml`, and `_tests.yaml` into a single `_checks.yaml`. Every check now carries the shared `Checks /` prefix. `unit_tests` and `integration_tests` are gated on a `run_tests` input so `on_master.yaml` can keep skipping tests for docs-only commits. 2. **Gate manual release workflows on wait-for-checks** — replaces the inline `code_checks` step in `manual_release_stable.yaml` / `manual_release_beta.yaml` / `manual_release_docs.yaml` / `manual_version_docs.yaml` with an `apify/actions/wait-for-checks@v1.2.0` step that verifies the `Checks` workflow already passed on the dispatch commit (it runs via `on_master.yaml` on every push). Every reusable-workflow caller that ends up requesting `checks: read` (docs jobs in `on_master.yaml`, `version_docs` / `doc_release` in `manual_release_stable.yaml`, `doc_release_post_publish` in `manual_release_beta.yaml`) explicitly grants the permission, since reusable workflows are capped at the caller's permission set.
1 parent 8c45b56 commit 45e3279

12 files changed

Lines changed: 245 additions & 259 deletions

.github/workflows/_check_code.yaml

Lines changed: 0 additions & 42 deletions
This file was deleted.

.github/workflows/_check_docs.yaml

Lines changed: 0 additions & 16 deletions
This file was deleted.

.github/workflows/_check_docstrings.yaml

Lines changed: 0 additions & 39 deletions
This file was deleted.

.github/workflows/_check_package.yaml

Lines changed: 0 additions & 38 deletions
This file was deleted.

.github/workflows/_checks.yaml

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
name: Checks
2+
3+
on:
4+
# Runs when manually triggered from the GitHub UI.
5+
workflow_dispatch:
6+
inputs:
7+
run_tests:
8+
description: Whether to run the test suites (unit, integration).
9+
required: false
10+
type: boolean
11+
default: true
12+
13+
# Runs when invoked by another workflow.
14+
workflow_call:
15+
inputs:
16+
run_tests:
17+
description: Whether to run the test suites (unit, integration).
18+
required: false
19+
type: boolean
20+
default: true
21+
22+
permissions:
23+
contents: read
24+
25+
env:
26+
PYTHON_VERSION: 3.14
27+
28+
jobs:
29+
actions_lint_check:
30+
name: Actions lint check
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: Checkout repository
34+
uses: actions/checkout@v6
35+
- name: Run actionlint
36+
uses: rhysd/actionlint@v1.7.11
37+
38+
spell_check:
39+
name: Spell check
40+
runs-on: ubuntu-latest
41+
steps:
42+
- name: Checkout repository
43+
uses: actions/checkout@v6
44+
- name: Check spelling with typos
45+
uses: crate-ci/typos@v1
46+
47+
lint_check:
48+
name: Lint check
49+
uses: apify/workflows/.github/workflows/python_lint_check.yaml@main
50+
with:
51+
python_versions: '["3.11", "3.12", "3.13", "3.14"]'
52+
53+
type_check:
54+
name: Type check
55+
uses: apify/workflows/.github/workflows/python_type_check.yaml@main
56+
with:
57+
python_versions: '["3.11", "3.12", "3.13", "3.14"]'
58+
59+
docstrings_check:
60+
name: Docstrings check
61+
runs-on: ubuntu-latest
62+
steps:
63+
- name: Checkout repository
64+
uses: actions/checkout@v6
65+
66+
- name: Set up Python
67+
uses: actions/setup-python@v6
68+
with:
69+
python-version: ${{ env.PYTHON_VERSION }}
70+
71+
- name: Set up uv package manager
72+
uses: astral-sh/setup-uv@v7
73+
with:
74+
python-version: ${{ env.PYTHON_VERSION }}
75+
76+
- name: Install dependencies
77+
run: uv run poe install-dev
78+
79+
- name: Async docstrings check
80+
run: uv run poe check-docstrings
81+
82+
unit_tests:
83+
name: Unit tests
84+
if: inputs.run_tests
85+
uses: apify/workflows/.github/workflows/python_unit_tests.yaml@main
86+
secrets: inherit
87+
with:
88+
python_versions: '["3.11", "3.12", "3.13", "3.14"]'
89+
operating_systems: '["ubuntu-latest", "windows-latest"]'
90+
python_version_for_codecov: "3.14"
91+
operating_system_for_codecov: ubuntu-latest
92+
tests_concurrency: "16"
93+
94+
# Integration tests are inlined (not calling the reusable workflow) to avoid GitHub's compile-time secret
95+
# validation for nested reusable workflows, which fails on fork PRs where repo secrets are not available.
96+
integration_tests:
97+
name: Integration tests (${{ matrix.python-version }}, ${{ matrix.os }})
98+
if: >-
99+
${{
100+
inputs.run_tests && (
101+
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.owner.login == 'apify') ||
102+
(github.event_name == 'push' && github.ref == 'refs/heads/master') ||
103+
github.event_name == 'workflow_dispatch'
104+
)
105+
}}
106+
107+
strategy:
108+
matrix:
109+
os: ["ubuntu-latest"]
110+
python-version: ["3.11", "3.14"]
111+
112+
runs-on: ${{ matrix.os }}
113+
114+
env:
115+
TESTS_CONCURRENCY: "16"
116+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
117+
118+
steps:
119+
- name: Checkout repository
120+
uses: actions/checkout@v6
121+
122+
- name: Set up Python ${{ matrix.python-version }}
123+
uses: actions/setup-python@v6
124+
with:
125+
python-version: ${{ matrix.python-version }}
126+
127+
- name: Set up uv package manager
128+
uses: astral-sh/setup-uv@v7
129+
with:
130+
python-version: ${{ matrix.python-version }}
131+
132+
- name: Install Python dependencies
133+
run: uv run poe install-dev
134+
135+
- name: Run integration tests
136+
run: uv run poe integration-tests-cov
137+
env:
138+
APIFY_TEST_USER_API_TOKEN: ${{ secrets.APIFY_TEST_USER_PYTHON_SDK_API_TOKEN }}
139+
APIFY_TEST_USER_2_API_TOKEN: ${{ secrets.APIFY_TEST_USER_2_API_TOKEN }}
140+
141+
- name: Upload integration test coverage
142+
if: >-
143+
${{
144+
matrix.os == 'ubuntu-latest' &&
145+
matrix.python-version == '3.14' &&
146+
env.CODECOV_TOKEN != ''
147+
}}
148+
uses: codecov/codecov-action@v6
149+
with:
150+
token: ${{ env.CODECOV_TOKEN }}
151+
files: coverage-integration.xml
152+
flags: integration
153+
154+
package_check:
155+
name: Package check
156+
runs-on: ubuntu-latest
157+
steps:
158+
- name: Checkout repository
159+
uses: actions/checkout@v6
160+
161+
- name: Set up uv package manager
162+
uses: astral-sh/setup-uv@v8.1.0
163+
with:
164+
python-version: "3.14"
165+
166+
- name: Build sdist and wheel
167+
run: uv run poe build
168+
169+
- name: Verify built package
170+
uses: apify/actions/python-package-check@v1.1.0
171+
with:
172+
package_name: apify_client
173+
dist_dir: dist
174+
python_version: "3.14"
175+
smoke_code: |
176+
from apify_client import ApifyClient, ApifyClientAsync
177+
ApifyClient(token='x')
178+
ApifyClientAsync(token='x')
179+
180+
doc_check:
181+
name: Doc check
182+
uses: apify/workflows/.github/workflows/python_docs_check.yaml@main

0 commit comments

Comments
 (0)