Skip to content

Commit f4e5429

Browse files
committed
ci: update ci
1 parent 7e34318 commit f4e5429

File tree

5 files changed

+146
-20
lines changed

5 files changed

+146
-20
lines changed

.github/workflows/ci.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: ci
2+
3+
on:
4+
# Rulesets for main branch
5+
# - Require status checks to pass -> Require branches to be up to date before merging
6+
pull_request:
7+
types: [labeled, unlabeled, opened, synchronize, reopened]
8+
9+
permissions:
10+
contents: write
11+
id-token: write
12+
13+
jobs:
14+
# ====================================================
15+
# Versioning and Release
16+
# ====================================================
17+
check-pre-release:
18+
name: check-pre-release
19+
uses: wislertt/zerv/.github/workflows/shared-check-pr-label-and-branch.yml@v0
20+
with:
21+
target_label: "pre-release"
22+
branch_prefixes: '["release/"]'
23+
branch_names: '["develop"]'
24+
25+
zerv-versioning:
26+
name: zerv-versioning
27+
needs: check-pre-release
28+
uses: wislertt/zerv/.github/workflows/shared-zerv-versioning.yml@v0
29+
with:
30+
schema: ${{ (needs.check-pre-release.outputs.is_valid == 'true' && 'standard-base-prerelease-post') || '' }}
31+
32+
tag-pre-release:
33+
name: tag-pre-release
34+
needs: [zerv-versioning, check-pre-release]
35+
if: needs.check-pre-release.outputs.is_valid == 'true'
36+
uses: wislertt/zerv/.github/workflows/shared-create-tags.yml@v0
37+
with:
38+
tags: '["${{ fromJson(needs.zerv-versioning.outputs.versions).v_semver }}"]'
39+
40+
# ====================================================
41+
# Test and Lint
42+
# ====================================================
43+
test:
44+
name: test
45+
uses: ./.github/workflows/test.yml
46+
secrets:
47+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
48+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
49+
50+
test-reproducibility:
51+
name: test-reproducibility
52+
uses: ./.github/workflows/test-reproducibility.yml
53+
54+
pre-commit:
55+
name: pre-commit
56+
uses: ./.github/workflows/pre-commit.yml
57+
secrets:
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1-
name: ci
1+
name: pre-commit
22

33
on:
4-
pull_request:
5-
types: [opened, synchronize, reopened]
4+
workflow_call:
5+
inputs:
6+
python_version:
7+
description: "Python version to use"
8+
required: false
9+
type: string
10+
default: "3.14"
11+
secrets:
12+
GITHUB_TOKEN:
13+
required: true
614

715
jobs:
816
pre-commit:
@@ -16,7 +24,7 @@ jobs:
1624

1725
- uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
1826
with:
19-
python-version: "3.14"
27+
python-version: ${{ inputs.python_version }}
2028

2129
- name: Install Poetry
2230
uses: snok/install-poetry@76e04a911780d5b312d89783f7b1cd627778900a # v1.4.1

.github/workflows/publish.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Reusable PyPI Publisher
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
version:
7+
required: true
8+
type: string
9+
description: "PEP440 version string"
10+
repository_url:
11+
required: false
12+
type: string
13+
description: "PyPI repository URL (default: official PyPI)"
14+
default: ""
15+
secrets:
16+
PYPI_API_TOKEN:
17+
required: true
18+
19+
jobs:
20+
publish:
21+
name: publish-to-pypi
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
27+
28+
- name: Update version in pyproject.toml
29+
run: |
30+
sed -i.bak 's/^version = .*/version = "${{ inputs.version }}"/' pyproject.toml
31+
grep '^version' pyproject.toml
32+
33+
- name: Set up Python
34+
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
35+
with:
36+
python-version: "3.14"
37+
38+
- name: Install uv
39+
uses: astral-sh/setup-uv@681c641aba71e4a1c380be3ab5e12ad51f415867 # v7.1.6
40+
with:
41+
version: "latest"
42+
43+
- name: Build package
44+
run: uv build
45+
46+
- name: Publish to PyPI
47+
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
48+
with:
49+
repository-url: ${{ inputs.repository_url || '' }}
50+
password: ${{ secrets.PYPI_API_TOKEN }}
51+
verbose: true
52+
skip-existing: true

.github/workflows/ci-test-reproducibility.yml renamed to .github/workflows/test-reproducibility.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
name: ci
1+
name: test-reproducibility
22

33
on:
4-
push:
5-
branches: [main]
6-
pull_request:
7-
types: [opened, synchronize, reopened]
4+
workflow_call:
5+
inputs:
6+
python_version:
7+
description: "Python version to use"
8+
required: false
9+
type: string
10+
default: "3.14"
811

912
jobs:
1013
test-reproducibility:
@@ -16,7 +19,7 @@ jobs:
1619
- name: Set up Python
1720
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
1821
with:
19-
python-version: "3.14"
22+
python-version: ${{ inputs.python_version }}
2023

2124
- name: Install Poetry
2225
uses: snok/install-poetry@76e04a911780d5b312d89783f7b1cd627778900a # v1.4.1
Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1-
name: ci
1+
name: test
22

33
on:
4-
push:
5-
branches: [main]
6-
pull_request:
7-
types: [opened, synchronize, reopened]
8-
9-
env:
10-
TARGET_PYTHON_VERSION: "3.14"
4+
workflow_call:
5+
inputs:
6+
target_python_version:
7+
description: "Target Python version for SonarQube and Codecov"
8+
required: false
9+
type: string
10+
default: "3.14"
11+
secrets:
12+
SONAR_TOKEN:
13+
required: false
14+
CODECOV_TOKEN:
15+
required: false
1116

1217
jobs:
1318
test:
@@ -76,13 +81,13 @@ jobs:
7681
run: make test
7782

7883
- name: SonarQube Scan
79-
if: matrix.python-version == env.TARGET_PYTHON_VERSION && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository)
84+
if: matrix.python-version == inputs.target_python_version && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository)
8085
uses: SonarSource/sonarqube-scan-action@a31c9398be7ace6bbfaf30c0bd5d415f843d45e9 # v7.0.0
8186
env:
8287
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
8388

8489
- name: Upload coverage reports to Codecov
85-
if: matrix.python-version == env.TARGET_PYTHON_VERSION && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository)
90+
if: matrix.python-version == inputs.target_python_version && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository)
8691
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
8792
with:
8893
fail_ci_if_error: true

0 commit comments

Comments
 (0)