Skip to content

Commit 414db5f

Browse files
authored
chore(ci): Align GitHub workflows across Python projects (#53)
1 parent 782a833 commit 414db5f

File tree

10 files changed

+268
-208
lines changed

10 files changed

+268
-208
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/actionlint@v1.7.9
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/_tests.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
# Create a custom unit tests job, because apify-shared-python doesn't use codecov report.
12+
unit_tests:
13+
name: Unit tests
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
os: [ubuntu-latest, windows-latest]
18+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
19+
runs-on: ${{ matrix.os }}
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v6
24+
25+
- name: Set up Python ${{ matrix.python-version }}
26+
uses: actions/setup-python@v6
27+
with:
28+
python-version: ${{ matrix.python-version }}
29+
30+
- name: Set up uv package manager
31+
uses: astral-sh/setup-uv@v7
32+
with:
33+
python-version: ${{ matrix.python-version }}
34+
35+
- name: Install Python dependencies
36+
run: make install-dev
37+
38+
- name: Run unit tests
39+
run: make unit-tests-cov

.github/workflows/check_pr_title.yaml

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: Stable release
2+
3+
on:
4+
# Runs when manually triggered from the GitHub UI, with options to specify the type of release.
5+
workflow_dispatch:
6+
inputs:
7+
release_type:
8+
description: Release type
9+
required: true
10+
type: choice
11+
default: auto
12+
options:
13+
- auto
14+
- custom
15+
- patch
16+
- minor
17+
- major
18+
custom_version:
19+
description: The custom version to bump to (only for "custom" type)
20+
required: false
21+
type: string
22+
default: ""
23+
24+
concurrency:
25+
group: release
26+
cancel-in-progress: false
27+
28+
jobs:
29+
code_checks:
30+
name: Code checks
31+
uses: ./.github/workflows/_check_code.yaml
32+
33+
tests:
34+
name: Tests
35+
uses: ./.github/workflows/_tests.yaml
36+
37+
release_prepare:
38+
name: Release prepare
39+
needs: [code_checks, tests]
40+
runs-on: ubuntu-latest
41+
outputs:
42+
version_number: ${{ steps.release_prepare.outputs.version_number }}
43+
tag_name: ${{ steps.release_prepare.outputs.tag_name }}
44+
changelog: ${{ steps.release_prepare.outputs.changelog }}
45+
release_notes: ${{ steps.release_prepare.outputs.release_notes }}
46+
steps:
47+
- uses: apify/workflows/git-cliff-release@main
48+
name: Release prepare
49+
id: release_prepare
50+
with:
51+
release_type: ${{ inputs.release_type }}
52+
custom_version: ${{ inputs.custom_version }}
53+
existing_changelog_path: CHANGELOG.md
54+
55+
changelog_update:
56+
name: Changelog update
57+
needs: [release_prepare]
58+
uses: apify/workflows/.github/workflows/python_bump_and_update_changelog.yaml@main
59+
with:
60+
version_number: ${{ needs.release_prepare.outputs.version_number }}
61+
changelog: ${{ needs.release_prepare.outputs.changelog }}
62+
secrets: inherit
63+
64+
github_release:
65+
name: GitHub release
66+
needs: [release_prepare, changelog_update]
67+
runs-on: ubuntu-latest
68+
env:
69+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70+
steps:
71+
- name: GitHub release
72+
uses: softprops/action-gh-release@v2
73+
with:
74+
tag_name: ${{ needs.release_prepare.outputs.tag_name }}
75+
name: ${{ needs.release_prepare.outputs.version_number }}
76+
target_commitish: ${{ needs.changelog_update.outputs.changelog_commitish }}
77+
body: ${{ needs.release_prepare.outputs.release_notes }}
78+
79+
pypi_publish:
80+
name: PyPI publish
81+
needs: [release_prepare, changelog_update]
82+
runs-on: ubuntu-latest
83+
permissions:
84+
contents: write
85+
id-token: write # Required for OIDC authentication.
86+
environment:
87+
name: pypi
88+
url: https://pypi.org/project/apify-shared
89+
steps:
90+
- name: Prepare distribution
91+
uses: apify/workflows/prepare-pypi-distribution@main
92+
with:
93+
package_name: apify-shared
94+
is_prerelease: ""
95+
version_number: ${{ needs.release_prepare.outputs.version_number }}
96+
ref: ${{ needs.changelog_update.outputs.changelog_commitish }}
97+
98+
# Publishes the package to PyPI using PyPA official GitHub action with OIDC authentication.
99+
- name: Publish package to PyPI
100+
uses: pypa/gh-action-pypi-publish@release/v1
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
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
1415

1516
steps:
1617
# Add the "t-tooling" label to all new issues
17-
- uses: actions/github-script@v7
18+
- uses: actions/github-script@v8
1819
with:
1920
script: |
2021
github.rest.issues.addLabels({
2122
issue_number: context.issue.number,
2223
owner: context.repo.owner,
2324
repo: context.repo.repo,
2425
labels: ["t-tooling"]
25-
})
26+
})

.github/workflows/on_master.yaml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: CI (master)
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
tags-ignore:
8+
- "**" # Ignore all tags to avoid duplicate executions triggered by tag pushes.
9+
10+
concurrency:
11+
group: release
12+
cancel-in-progress: false
13+
14+
jobs:
15+
code_checks:
16+
name: Code checks
17+
uses: ./.github/workflows/_check_code.yaml
18+
19+
tests:
20+
# Skip this for "ci" and "docs" commits.
21+
if: "!startsWith(github.event.head_commit.message, 'ci') && !startsWith(github.event.head_commit.message, 'docs')"
22+
name: Tests
23+
uses: ./.github/workflows/_tests.yaml
24+
25+
release_prepare:
26+
# Skip this for "ci", "docs" and "test" commits and for forks.
27+
if: "!startsWith(github.event.head_commit.message, 'ci') && !startsWith(github.event.head_commit.message, 'docs') && !startsWith(github.event.head_commit.message, 'test') && startsWith(github.repository, 'apify/')"
28+
name: Release prepare
29+
needs: [code_checks, tests]
30+
runs-on: ubuntu-latest
31+
outputs:
32+
version_number: ${{ steps.release_prepare.outputs.version_number }}
33+
tag_name: ${{ steps.release_prepare.outputs.tag_name }}
34+
changelog: ${{ steps.release_prepare.outputs.changelog }}
35+
steps:
36+
- uses: apify/workflows/git-cliff-release@main
37+
id: release_prepare
38+
name: Release prepare
39+
with:
40+
release_type: prerelease
41+
existing_changelog_path: CHANGELOG.md
42+
43+
changelog_update:
44+
name: Changelog update
45+
needs: [release_prepare]
46+
uses: apify/workflows/.github/workflows/python_bump_and_update_changelog.yaml@main
47+
with:
48+
version_number: ${{ needs.release_prepare.outputs.version_number }}
49+
changelog: ${{ needs.release_prepare.outputs.changelog }}
50+
secrets: inherit
51+
52+
pypi_publish:
53+
name: PyPI publish
54+
needs: [release_prepare, changelog_update]
55+
runs-on: ubuntu-latest
56+
permissions:
57+
contents: write
58+
id-token: write # Required for OIDC authentication.
59+
environment:
60+
name: pypi
61+
url: https://pypi.org/project/apify-shared
62+
steps:
63+
- name: Prepare distribution
64+
uses: apify/workflows/prepare-pypi-distribution@main
65+
with:
66+
package_name: apify-shared
67+
is_prerelease: "yes"
68+
version_number: ${{ needs.release_prepare.outputs.version_number }}
69+
ref: ${{ needs.changelog_update.outputs.changelog_commitish }}
70+
71+
- name: Publish package to PyPI
72+
uses: pypa/gh-action-pypi-publish@release/v1
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: CI (PR)
2+
3+
on:
4+
# Runs whenever a pull request is opened or updated.
5+
pull_request:
6+
7+
jobs:
8+
pr_title_check:
9+
name: PR title check
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: amannn/action-semantic-pull-request@v6.1.1
13+
env:
14+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15+
16+
code_checks:
17+
name: Code checks
18+
uses: ./.github/workflows/_check_code.yaml
19+
20+
tests:
21+
name: Tests
22+
uses: ./.github/workflows/_tests.yaml

.github/workflows/pre_release.yaml

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

0 commit comments

Comments
 (0)