Skip to content

Commit e201147

Browse files
authored
chore(ci): Align GitHub workflows across Python projects (#1613)
1 parent 3dc7969 commit e201147

13 files changed

+167
-130
lines changed

.github/workflows/_check_code.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Code checks
2+
3+
on:
4+
# Runs when manually triggered from the GitHub UI.
5+
workflow_dispatch:
6+
7+
# Runs when invoked by another workflow.
8+
workflow_call:
9+
10+
jobs:
11+
actions_lint_check:
12+
name: Actions lint check
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v6
17+
- name: Run actionlint
18+
uses: rhysd/[email protected]
19+
20+
lint_check:
21+
name: Lint check
22+
uses: apify/workflows/.github/workflows/python_lint_check.yaml@main
23+
with:
24+
python-versions: '["3.10", "3.11", "3.12", "3.13", "3.14"]'
25+
26+
type_check:
27+
name: Type check
28+
uses: apify/workflows/.github/workflows/python_type_check.yaml@main
29+
with:
30+
python-versions: '["3.10", "3.11", "3.12", "3.13", "3.14"]'

.github/workflows/_check_docs.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Doc checks
2+
3+
on:
4+
# Runs when manually triggered from the GitHub UI.
5+
workflow_dispatch:
6+
7+
# Runs when invoked by another workflow.
8+
workflow_call:
9+
10+
jobs:
11+
doc_checks:
12+
name: Doc checks
13+
uses: apify/workflows/.github/workflows/python_docs_check.yaml@main
14+
secrets: inherit

.github/workflows/build_and_deploy_docs.yaml renamed to .github/workflows/_release_docs.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
1-
name: Build and deploy docs
1+
name: Doc release
22

33
on:
4+
# Runs when manually triggered from the GitHub UI.
45
workflow_dispatch:
6+
7+
# Runs when invoked by another workflow.
58
workflow_call:
69
inputs:
710
ref:
811
required: true
912
type: string
1013

1114
env:
12-
NODE_VERSION: 20
15+
NODE_VERSION: 22
1316
PYTHON_VERSION: 3.14
1417

1518
jobs:
16-
build_and_deploy_docs:
19+
release_docs:
20+
name: Doc release
1721
environment:
1822
name: github-pages
1923
permissions:
Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
name: Create a pre-release
1+
name: Pre-release
22

33
on:
4-
# Trigger a beta version release (pre-release) on push to the master branch.
5-
push:
6-
branches:
7-
- master
8-
tags-ignore:
9-
- "**" # Ignore all tags to prevent duplicate builds when tags are pushed.
10-
11-
# Or it can be triggered manually.
4+
# Runs when manually triggered from the GitHub UI.
125
workflow_dispatch:
136

7+
# Runs when invoked by another workflow.
8+
workflow_call:
9+
outputs:
10+
changelog_commitish:
11+
description: The commit SHA after updating the changelog
12+
value: ${{ jobs.update_changelog.outputs.changelog_commitish }}
13+
1414
concurrency:
1515
group: release
1616
cancel-in-progress: false
1717

1818
jobs:
1919
release_metadata:
20+
if: "!startsWith(github.event.head_commit.message, 'docs') && !startsWith(github.event.head_commit.message, 'ci') && startsWith(github.repository, 'apify/')"
2021
name: Prepare release metadata
2122
runs-on: ubuntu-latest
2223
outputs:
@@ -31,36 +32,16 @@ jobs:
3132
release_type: prerelease
3233
existing_changelog_path: CHANGELOG.md
3334

34-
# If github.ref points to a [ci skip] commit, this workflow won't run.
35-
# Otherwise, these checks will be launched from the `run_code_checks` workflow.
36-
wait_for_checks:
37-
name: Wait for code checks to pass
38-
runs-on: ubuntu-latest
39-
steps:
40-
- uses: lewagon/[email protected]
41-
with:
42-
ref: ${{ github.ref }}
43-
repo-token: ${{ secrets.GITHUB_TOKEN }}
44-
check-regexp: "( check| tests)$"
45-
wait-interval: 5
46-
4735
update_changelog:
4836
name: Update changelog
49-
needs: [release_metadata, wait_for_checks]
37+
needs: [release_metadata]
5038
uses: apify/workflows/.github/workflows/python_bump_and_update_changelog.yaml@main
5139
with:
5240
version_number: ${{ needs.release_metadata.outputs.version_number }}
5341
changelog: ${{ needs.release_metadata.outputs.changelog }}
5442
secrets:
5543
APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
5644

57-
build_and_deploy_docs:
58-
needs: [update_changelog]
59-
uses: ./.github/workflows/build_and_deploy_docs.yaml
60-
with:
61-
ref: ${{ needs.update_changelog.outputs.changelog_commitish }}
62-
secrets: inherit
63-
6445
publish_to_pypi:
6546
if: "!startsWith(github.event.head_commit.message, 'ci') && !startsWith(github.event.head_commit.message, 'docs')"
6647
name: Publish to PyPI
@@ -80,6 +61,7 @@ jobs:
8061
is_prerelease: "yes"
8162
version_number: ${{ needs.release_metadata.outputs.version_number }}
8263
ref: ${{ needs.update_changelog.outputs.changelog_commitish }}
64+
8365
# Publishes the package to PyPI using PyPA official GitHub action with OIDC authentication.
8466
- name: Publish package to PyPI
8567
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/_tests.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Tests
2+
3+
on:
4+
# Runs when manually triggered from the GitHub UI.
5+
workflow_dispatch:
6+
7+
# Runs when invoked by another workflow.
8+
workflow_call:
9+
10+
jobs:
11+
unit_tests:
12+
name: Unit tests
13+
uses: apify/workflows/.github/workflows/python_unit_tests.yaml@main
14+
secrets:
15+
httpbin_url: ${{ secrets.APIFY_HTTPBIN_TOKEN && format('https://httpbin.apify.actor?token={0}', secrets.APIFY_HTTPBIN_TOKEN) || 'https://httpbin.org' }}
16+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
17+
with:
18+
python-versions: '["3.10", "3.11", "3.12", "3.13", "3.14"]'
19+
operating-systems: '["ubuntu-latest", "windows-latest", "macos-latest"]'
20+
python-version-for-codecov: "3.14"
21+
operating-system-for-codecov: ubuntu-latest

.github/workflows/check_pr_title.yaml

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

.github/workflows/release.yaml renamed to .github/workflows/manual_release_stable.yaml

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
name: Create a release
1+
name: Stable release
22

33
on:
4-
# Trigger a stable version release via GitHub's UI, with the ability to specify the type of release.
4+
# Runs when manually triggered from the GitHub UI, with options to specify the type of release.
55
workflow_dispatch:
66
inputs:
77
release_type:
@@ -26,8 +26,13 @@ concurrency:
2626
cancel-in-progress: false
2727

2828
jobs:
29+
code_checks:
30+
name: Code checks
31+
uses: ./.github/workflows/_check_code.yaml
32+
2933
release_metadata:
3034
name: Prepare release metadata
35+
needs: [code_checks]
3136
runs-on: ubuntu-latest
3237
outputs:
3338
version_number: ${{ steps.release_metadata.outputs.version_number }}
@@ -43,37 +48,18 @@ jobs:
4348
custom_version: ${{ inputs.custom_version }}
4449
existing_changelog_path: CHANGELOG.md
4550

46-
lint_check:
47-
name: Lint check
48-
uses: apify/workflows/.github/workflows/python_lint_check.yaml@main
49-
with:
50-
python-versions: '["3.10", "3.11", "3.12", "3.13", "3.14"]'
51-
52-
type_check:
53-
name: Type check
54-
uses: apify/workflows/.github/workflows/python_type_check.yaml@main
55-
with:
56-
python-versions: '["3.10", "3.11", "3.12", "3.13", "3.14"]'
57-
5851
update_changelog:
5952
name: Update changelog
60-
needs: [release_metadata, lint_check, type_check]
53+
needs: [release_metadata]
6154
uses: apify/workflows/.github/workflows/python_bump_and_update_changelog.yaml@main
6255
with:
6356
version_number: ${{ needs.release_metadata.outputs.version_number }}
6457
changelog: ${{ needs.release_metadata.outputs.changelog }}
6558
secrets:
6659
APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
6760

68-
build_and_deploy_docs:
69-
needs: [update_changelog]
70-
uses: ./.github/workflows/build_and_deploy_docs.yaml
71-
with:
72-
ref: ${{ needs.update_changelog.outputs.changelog_commitish }}
73-
secrets: inherit
74-
7561
create_github_release:
76-
name: Create github release
62+
name: Create GitHub release
7763
needs: [release_metadata, update_changelog]
7864
runs-on: ubuntu-latest
7965
env:
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
name: Update new issue
1+
name: CI (issue)
22

33
on:
4+
# Runs when a new issue is opened.
45
issues:
56
types:
67
- opened
78

89
jobs:
910
label_issues:
10-
name: Label issues
11+
name: Add labels
1112
runs-on: ubuntu-latest
1213
permissions:
1314
issues: write

.github/workflows/on_master.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: CI (master)
2+
3+
on:
4+
# Runs on every push to the master branch.
5+
push:
6+
branches:
7+
- master
8+
tags-ignore:
9+
- "**" # Ignore all tags to avoid duplicate executions triggered by tag pushes.
10+
11+
jobs:
12+
doc_checks:
13+
name: Doc checks
14+
uses: ./.github/workflows/_check_docs.yaml
15+
secrets: inherit
16+
17+
code_checks:
18+
name: Code checks
19+
uses: ./.github/workflows/_check_code.yaml
20+
21+
tests:
22+
name: Tests
23+
uses: ./.github/workflows/_tests.yaml
24+
secrets: inherit
25+
26+
pre_release:
27+
name: Pre-release
28+
needs: [code_checks, tests]
29+
uses: ./.github/workflows/_release_pre.yaml
30+
secrets: inherit
31+
32+
release_docs:
33+
name: Doc release
34+
needs: [doc_checks, pre_release]
35+
uses: ./.github/workflows/_release_docs.yaml
36+
with:
37+
ref: ${{ needs.pre_release.outputs.changelog_commitish }}
38+
secrets: inherit
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: CI (PR)
2+
3+
on:
4+
# Runs whenever a pull request is opened or updated.
5+
pull_request:
6+
7+
jobs:
8+
check_pr_title:
9+
name: Check PR title
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: amannn/[email protected]
13+
env:
14+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15+
16+
doc_checks:
17+
name: Doc checks
18+
uses: ./.github/workflows/_check_docs.yaml
19+
secrets: inherit
20+
21+
code_checks:
22+
name: Code checks
23+
uses: ./.github/workflows/_check_code.yaml
24+
25+
tests:
26+
name: Tests
27+
uses: ./.github/workflows/_tests.yaml
28+
secrets: inherit

0 commit comments

Comments
 (0)