Skip to content

Commit 1e5b94c

Browse files
authored
ci: Gate manual release workflows on wait-for-checks (#907)
## Summary Ports the CI consolidation and `wait-for-checks` adoption from `crawlee-python` to `apify-sdk-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_package.yaml`, and `_tests.yaml` into a single `_checks.yaml`. Every check now carries the shared `Checks /` prefix. `unit_tests`, `integration_tests`, and `e2e_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 63f2687 commit 1e5b94c

10 files changed

Lines changed: 147 additions & 138 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_package.yaml

Lines changed: 0 additions & 38 deletions
This file was deleted.
Lines changed: 84 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,61 @@
1-
name: Tests
1+
name: Checks
22

33
on:
44
# Runs when manually triggered from the GitHub UI.
55
workflow_dispatch:
6+
inputs:
7+
run_tests:
8+
description: Whether to run the test suites (unit, integration, E2E).
9+
required: false
10+
type: boolean
11+
default: true
612

713
# Runs when invoked by another workflow.
814
workflow_call:
15+
inputs:
16+
run_tests:
17+
description: Whether to run the test suites (unit, integration, E2E).
18+
required: false
19+
type: boolean
20+
default: true
921

1022
permissions:
1123
contents: read
1224

1325
jobs:
26+
actions_lint_check:
27+
name: Actions lint check
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@v6
32+
- name: Run actionlint
33+
uses: rhysd/actionlint@v1.7.11
34+
35+
spell_check:
36+
name: Spell check
37+
runs-on: ubuntu-latest
38+
steps:
39+
- name: Checkout repository
40+
uses: actions/checkout@v6
41+
- name: Check spelling with typos
42+
uses: crate-ci/typos@v1
43+
44+
lint_check:
45+
name: Lint check
46+
uses: apify/workflows/.github/workflows/python_lint_check.yaml@main
47+
with:
48+
python_versions: '["3.10", "3.11", "3.12", "3.13", "3.14"]'
49+
50+
type_check:
51+
name: Type check
52+
uses: apify/workflows/.github/workflows/python_type_check.yaml@main
53+
with:
54+
python_versions: '["3.10", "3.11", "3.12", "3.13", "3.14"]'
55+
1456
unit_tests:
1557
name: Unit tests
58+
if: inputs.run_tests
1659
uses: apify/workflows/.github/workflows/python_unit_tests.yaml@main
1760
secrets: inherit
1861
with:
@@ -27,9 +70,11 @@ jobs:
2770

2871
if: >-
2972
${{
30-
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.owner.login == 'apify') ||
31-
(github.event_name == 'push' && github.ref == 'refs/heads/master') ||
32-
github.event_name == 'workflow_dispatch'
73+
inputs.run_tests && (
74+
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.owner.login == 'apify') ||
75+
(github.event_name == 'push' && github.ref == 'refs/heads/master') ||
76+
github.event_name == 'workflow_dispatch'
77+
)
3378
}}
3479
3580
strategy:
@@ -85,9 +130,11 @@ jobs:
85130

86131
if: >-
87132
${{
88-
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.owner.login == 'apify') ||
89-
(github.event_name == 'push' && github.ref == 'refs/heads/master') ||
90-
github.event_name == 'workflow_dispatch'
133+
inputs.run_tests && (
134+
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.owner.login == 'apify') ||
135+
(github.event_name == 'push' && github.ref == 'refs/heads/master') ||
136+
github.event_name == 'workflow_dispatch'
137+
)
91138
}}
92139
93140
strategy:
@@ -137,3 +184,33 @@ jobs:
137184
token: ${{ env.CODECOV_TOKEN }}
138185
files: coverage-e2e.xml
139186
flags: e2e
187+
188+
package_check:
189+
name: Package check
190+
runs-on: ubuntu-latest
191+
steps:
192+
- name: Checkout repository
193+
uses: actions/checkout@v6
194+
195+
- name: Set up uv package manager
196+
uses: astral-sh/setup-uv@v8.1.0
197+
with:
198+
python-version: "3.14"
199+
200+
- name: Build sdist and wheel
201+
run: uv run poe build
202+
203+
- name: Verify built package
204+
uses: apify/actions/python-package-check@v1.1.0
205+
with:
206+
package_name: apify
207+
dist_dir: dist
208+
python_version: "3.14"
209+
smoke_code: |
210+
from apify import Actor, Configuration, ProxyConfiguration
211+
Configuration()
212+
ProxyConfiguration()
213+
214+
doc_check:
215+
name: Doc check
216+
uses: apify/workflows/.github/workflows/python_docs_check.yaml@main

.github/workflows/manual_release_beta.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,22 @@ permissions:
1616
contents: read
1717

1818
jobs:
19+
wait_for_checks:
20+
# Gate the release on the `Checks` workflow already succeeding on this commit (run by `on_master.yaml`).
21+
name: Wait for required checks
22+
runs-on: ubuntu-latest
23+
permissions:
24+
checks: read
25+
steps:
26+
- name: Wait for checks
27+
uses: apify/actions/wait-for-checks@v1.2.0
28+
with:
29+
ref: ${{ github.sha }}
30+
check-regexp: '^Checks'
31+
1932
release_prepare:
2033
name: Release prepare
34+
needs: [wait_for_checks]
2135
runs-on: ubuntu-latest
2236
outputs:
2337
version_number: ${{ steps.release_prepare.outputs.version_number }}
@@ -82,5 +96,6 @@ jobs:
8296
contents: write
8397
pages: write
8498
id-token: write
99+
checks: read
85100
uses: ./.github/workflows/manual_release_docs.yaml
86101
secrets: inherit

.github/workflows/manual_release_docs.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,19 @@ jobs:
2323
contents: write
2424
pages: write
2525
id-token: write
26+
checks: read
2627
runs-on: ubuntu-latest
2728

2829
steps:
30+
# Gate manual dispatches on the `Checks` workflow already succeeding on this commit (run by `on_master.yaml`);
31+
# skipped when called from another workflow.
32+
- name: Wait for checks
33+
if: github.event_name == 'workflow_dispatch'
34+
uses: apify/actions/wait-for-checks@v1.2.0
35+
with:
36+
ref: ${{ github.sha }}
37+
check-regexp: '^Checks'
38+
2939
- name: Checkout repository
3040
uses: actions/checkout@v6
3141
with:

.github/workflows/manual_release_stable.yaml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,22 @@ permissions:
2929
contents: read
3030

3131
jobs:
32-
code_checks:
33-
name: Code checks
34-
uses: ./.github/workflows/_check_code.yaml
32+
wait_for_checks:
33+
# Gate the release on the `Checks` workflow already succeeding on this commit (run by `on_master.yaml`).
34+
name: Wait for required checks
35+
runs-on: ubuntu-latest
36+
permissions:
37+
checks: read
38+
steps:
39+
- name: Wait for checks
40+
uses: apify/actions/wait-for-checks@v1.2.0
41+
with:
42+
ref: ${{ github.sha }}
43+
check-regexp: '^Checks'
3544

3645
release_prepare:
3746
name: Release prepare
38-
needs: [code_checks]
47+
needs: [wait_for_checks]
3948
runs-on: ubuntu-latest
4049
outputs:
4150
version_number: ${{ steps.release_prepare.outputs.version_number }}
@@ -118,6 +127,7 @@ jobs:
118127
needs: [release_prepare, changelog_update, pypi_publish]
119128
permissions:
120129
contents: write
130+
checks: read
121131
uses: ./.github/workflows/manual_version_docs.yaml
122132
with:
123133
# Pass the bumped version explicitly — the job's checkout uses the dispatch ref (pre-bump),
@@ -132,6 +142,7 @@ jobs:
132142
contents: write
133143
pages: write
134144
id-token: write
145+
checks: read
135146
uses: ./.github/workflows/manual_release_docs.yaml
136147
secrets: inherit
137148

.github/workflows/manual_version_docs.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,22 @@ jobs:
3636
runs-on: ubuntu-latest
3737
permissions:
3838
contents: write
39+
checks: read
3940

4041
defaults:
4142
run:
4243
working-directory: website
4344

4445
steps:
46+
# Gate manual dispatches on the `Checks` workflow already succeeding on this commit (run by `on_master.yaml`);
47+
# skipped when called from another workflow.
48+
- name: Wait for checks
49+
if: github.event_name == 'workflow_dispatch'
50+
uses: apify/actions/wait-for-checks@v1.2.0
51+
with:
52+
ref: ${{ github.sha }}
53+
check-regexp: '^Checks'
54+
4555
- name: Checkout repository
4656
uses: actions/checkout@v6
4757
with:

.github/workflows/on_master.yaml

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,27 @@ permissions:
1111
contents: read
1212

1313
jobs:
14-
doc_checks:
15-
name: Doc checks
16-
uses: ./.github/workflows/_check_docs.yaml
14+
checks:
15+
name: Checks
16+
uses: ./.github/workflows/_checks.yaml
17+
with:
18+
# Skip the test suites for docs-only commits — they don't change runtime behavior.
19+
run_tests: ${{ !startsWith(github.event.head_commit.message, 'docs') }}
20+
secrets: inherit
1721

1822
doc_release:
1923
# Skip this for non-"docs" commits.
2024
if: startsWith(github.event.head_commit.message, 'docs')
2125
name: Doc release
22-
needs: [doc_checks]
26+
needs: [checks]
2327
permissions:
2428
contents: write
2529
pages: write
2630
id-token: write
31+
checks: read
2732
uses: ./.github/workflows/manual_release_docs.yaml
2833
secrets: inherit
2934

30-
code_checks:
31-
name: Code checks
32-
uses: ./.github/workflows/_check_code.yaml
33-
34-
tests:
35-
# Skip this for "docs" commits.
36-
if: "!startsWith(github.event.head_commit.message, 'docs')"
37-
name: Tests
38-
uses: ./.github/workflows/_tests.yaml
39-
secrets: inherit
40-
4135
# The beta release is dispatched as a separate workflow run (instead of calling `manual_release_beta.yaml` via `uses:`)
4236
# because PyPI's Trusted Publishing does not currently support reusable workflows.
4337
# See: https://docs.pypi.org/trusted-publishers/troubleshooting/#reusable-workflows-on-github
@@ -50,7 +44,7 @@ jobs:
5044
startsWith(github.event.head_commit.message, 'refactor') ||
5145
startsWith(github.event.head_commit.message, 'style')
5246
name: Beta release
53-
needs: [code_checks, tests]
47+
needs: [checks]
5448
runs-on: ubuntu-latest
5549
permissions:
5650
actions: write # Required by execute-workflow.

0 commit comments

Comments
 (0)