Skip to content

Commit ef86e6b

Browse files
committed
refactor(ci): reuse workflows
1 parent 4f34752 commit ef86e6b

File tree

3 files changed

+68
-72
lines changed

3 files changed

+68
-72
lines changed
Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
name: Lint and Type Check
1+
name: CI
22

33
on:
44
push:
55
branches: [main, develop]
66
pull_request:
77
branches: [main, develop]
8+
workflow_call: # Allow this workflow to be called by other workflows
89

910
jobs:
1011
lint:
@@ -26,7 +27,7 @@ jobs:
2627
python-version: "3.12"
2728

2829
- name: Install dependencies
29-
run: uv sync
30+
run: uv sync --all-extras
3031

3132
- name: Run Ruff linter
3233
run: uv run ruff check packages/ examples/
@@ -53,7 +54,38 @@ jobs:
5354
python-version: "3.12"
5455

5556
- name: Install dependencies
56-
run: uv sync
57+
run: uv sync --all-extras
5758

5859
- name: Run ty type checker
5960
run: uv run ty check packages/
61+
62+
test:
63+
name: Test on Python ${{ matrix.python-version }}
64+
runs-on: ubuntu-latest
65+
strategy:
66+
matrix:
67+
python-version: ["3.12", "3.13"]
68+
69+
steps:
70+
- name: Checkout code
71+
uses: actions/checkout@v4
72+
73+
- name: Install uv
74+
uses: astral-sh/setup-uv@v4
75+
with:
76+
enable-cache: true
77+
78+
- name: Set up Python ${{ matrix.python-version }}
79+
uses: actions/setup-python@v5
80+
with:
81+
python-version: ${{ matrix.python-version }}
82+
83+
- name: Install dependencies
84+
run: uv sync --all-extras
85+
86+
- name: Run tests
87+
run: |
88+
# Run tests for each package individually since namespace packages
89+
# with editable installs work best when run from package directory
90+
cd packages/myfy-core && uv run pytest tests/ -v && cd ../..
91+
# Add other package tests as they are created

.github/workflows/publish.yml

Lines changed: 15 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -14,46 +14,13 @@ on:
1414
type: string
1515

1616
jobs:
17-
test:
18-
name: Test
19-
runs-on: ubuntu-latest
20-
strategy:
21-
matrix:
22-
python-version: ['3.12', '3.13']
23-
24-
steps:
25-
- uses: actions/checkout@v4
26-
with:
27-
fetch-depth: 0 # Need full history for version calculation
28-
29-
- name: Set up Python ${{ matrix.python-version }}
30-
uses: actions/setup-python@v5
31-
with:
32-
python-version: ${{ matrix.python-version }}
33-
34-
- name: Install uv
35-
uses: astral-sh/setup-uv@v3
36-
37-
- name: Install dependencies
38-
run: |
39-
uv sync --all-extras --dev
40-
41-
- name: Run linting
42-
run: |
43-
uv run ruff check packages/
44-
uv run ruff format --check packages/
45-
46-
- name: Run type checking
47-
run: |
48-
uv run ty check packages/
49-
50-
- name: Run tests
51-
run: |
52-
uv run pytest
17+
# Run all CI checks first
18+
ci:
19+
uses: ./.github/workflows/ci.yml
5320

5421
build-and-publish:
5522
name: Build and Publish
56-
needs: test
23+
needs: ci
5724
runs-on: ubuntu-latest
5825
permissions:
5926
id-token: write # Required for PyPI trusted publishing
@@ -70,10 +37,7 @@ jobs:
7037
python-version: '3.12'
7138

7239
- name: Install uv
73-
uses: astral-sh/setup-uv@v3
74-
75-
- name: Install commitizen
76-
run: uv pip install --system commitizen
40+
uses: astral-sh/setup-uv@v4
7741

7842
- name: Calculate version
7943
id: version
@@ -111,14 +75,15 @@ jobs:
11175
sed -i "s/__version__ = .*/__version__ = \"$VERSION\"/" packages/myfy-frontend/myfy/frontend/version.py
11276
sed -i "s/__version__ = .*/__version__ = \"$VERSION\"/" packages/myfy/myfy/version.py
11377
114-
# Update dependency constraints to match new version
115-
sed -i "s/myfy-core~=[0-9.]*/myfy-core~=$VERSION/" packages/myfy-web/pyproject.toml
116-
sed -i "s/myfy-core~=[0-9.]*/myfy-core~=$VERSION/" packages/myfy-cli/pyproject.toml
117-
sed -i "s/myfy-core~=[0-9.]*/myfy-core~=$VERSION/" packages/myfy-frontend/pyproject.toml
118-
sed -i "s/myfy-web~=[0-9.]*/myfy-web~=$VERSION/" packages/myfy-frontend/pyproject.toml
119-
sed -i "s/myfy-core~=[0-9.]*/myfy-core~=$VERSION/" packages/myfy/pyproject.toml
120-
sed -i "s/myfy-cli~=[0-9.]*/myfy-cli~=$VERSION/" packages/myfy/pyproject.toml
121-
sed -i "s/myfy-web~=[0-9.]*/myfy-web~=$VERSION/" packages/myfy/pyproject.toml
78+
# Update dependency constraints to match new version (only base version, not alpha suffix)
79+
BASE_VERSION=$(echo $VERSION | sed 's/a.*//')
80+
sed -i "s/myfy-core~=[0-9a-z.]*/myfy-core~=$BASE_VERSION/" packages/myfy-web/pyproject.toml
81+
sed -i "s/myfy-core~=[0-9a-z.]*/myfy-core~=$BASE_VERSION/" packages/myfy-cli/pyproject.toml
82+
sed -i "s/myfy-core~=[0-9a-z.]*/myfy-core~=$BASE_VERSION/" packages/myfy-frontend/pyproject.toml
83+
sed -i "s/myfy-web~=[0-9a-z.]*/myfy-web~=$BASE_VERSION/" packages/myfy-frontend/pyproject.toml
84+
sed -i "s/myfy-core~=[0-9a-z.]*/myfy-core~=$BASE_VERSION/" packages/myfy/pyproject.toml
85+
sed -i "s/myfy-cli~=[0-9a-z.]*/myfy-cli~=$BASE_VERSION/" packages/myfy/pyproject.toml
86+
sed -i "s/myfy-web~=[0-9a-z.]*/myfy-web~=$BASE_VERSION/" packages/myfy/pyproject.toml
12287
12388
echo "Version updated to $VERSION in all files"
12489
@@ -191,7 +156,7 @@ jobs:
191156
verbose: true
192157

193158
validate-install:
194-
name: Validate Installation
159+
name: Validate Installation on Python ${{ matrix.python-version }}
195160
needs: build-and-publish
196161
runs-on: ubuntu-latest
197162
strategy:

.github/workflows/release.yml

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,18 @@ on:
1212
- minor
1313
- major
1414
prerelease:
15-
description: 'Is this a pre-release? (e.g., beta, rc)'
15+
description: 'Is this a pre-release? (e.g., b1, rc1)'
1616
required: false
1717
type: string
1818

1919
jobs:
20+
# Run all CI checks first
21+
ci:
22+
uses: ./.github/workflows/ci.yml
23+
2024
release:
2125
name: Create Release
26+
needs: ci
2227
runs-on: ubuntu-latest
2328
permissions:
2429
id-token: write # Required for PyPI trusted publishing
@@ -36,7 +41,7 @@ jobs:
3641
python-version: '3.12'
3742

3843
- name: Install uv
39-
uses: astral-sh/setup-uv@v3
44+
uses: astral-sh/setup-uv@v4
4045

4146
- name: Install commitizen
4247
run: uv pip install --system commitizen
@@ -52,7 +57,7 @@ jobs:
5257
# Run commitizen bump
5358
cz bump --increment ${{ github.event.inputs.bump_type }} --yes
5459
55-
# Get the new version from .cz.toml or pyproject.toml
60+
# Get the new version from pyproject.toml
5661
NEW_VERSION=$(grep -o 'version = "[^"]*"' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
5762
5863
# Add prerelease suffix if specified
@@ -81,30 +86,24 @@ jobs:
8186
- name: Update dependency constraints
8287
run: |
8388
VERSION="${{ steps.bump.outputs.version }}"
89+
# Extract base version without prerelease suffix for dependency constraints
90+
BASE_VERSION=$(echo $VERSION | sed 's/[a-z].*//')
8491
8592
# Update internal dependency constraints
86-
sed -i "s/myfy-core~=[0-9.]*/myfy-core~=$VERSION/" packages/myfy-web/pyproject.toml
87-
sed -i "s/myfy-core~=[0-9.]*/myfy-core~=$VERSION/" packages/myfy-cli/pyproject.toml
88-
sed -i "s/myfy-core~=[0-9.]*/myfy-core~=$VERSION/" packages/myfy-frontend/pyproject.toml
89-
sed -i "s/myfy-web~=[0-9.]*/myfy-web~=$VERSION/" packages/myfy-frontend/pyproject.toml
90-
sed -i "s/myfy-core~=[0-9.]*/myfy-core~=$VERSION/" packages/myfy/pyproject.toml
91-
sed -i "s/myfy-cli~=[0-9.]*/myfy-cli~=$VERSION/" packages/myfy/pyproject.toml
92-
sed -i "s/myfy-web~=[0-9.]*/myfy-web~=$VERSION/" packages/myfy/pyproject.toml
93+
sed -i "s/myfy-core~=[0-9a-z.]*/myfy-core~=$BASE_VERSION/" packages/myfy-web/pyproject.toml
94+
sed -i "s/myfy-core~=[0-9a-z.]*/myfy-core~=$BASE_VERSION/" packages/myfy-cli/pyproject.toml
95+
sed -i "s/myfy-core~=[0-9a-z.]*/myfy-core~=$BASE_VERSION/" packages/myfy-frontend/pyproject.toml
96+
sed -i "s/myfy-web~=[0-9a-z.]*/myfy-web~=$BASE_VERSION/" packages/myfy-frontend/pyproject.toml
97+
sed -i "s/myfy-core~=[0-9a-z.]*/myfy-core~=$BASE_VERSION/" packages/myfy/pyproject.toml
98+
sed -i "s/myfy-cli~=[0-9a-z.]*/myfy-cli~=$BASE_VERSION/" packages/myfy/pyproject.toml
99+
sed -i "s/myfy-web~=[0-9a-z.]*/myfy-web~=$BASE_VERSION/" packages/myfy/pyproject.toml
93100
94101
- name: Commit version bump
95102
run: |
96103
git add .
97104
git commit -m "chore(release): bump version to ${{ steps.bump.outputs.version }}" || true
98105
git tag -a "v${{ steps.bump.outputs.version }}" -m "Release v${{ steps.bump.outputs.version }}"
99106
100-
- name: Run tests
101-
run: |
102-
uv sync --all-extras --dev
103-
uv run ruff check packages/
104-
uv run ruff format --check packages/
105-
uv run ty check packages/
106-
uv run pytest
107-
108107
- name: Build packages
109108
run: |
110109
# Build in dependency order
@@ -202,7 +201,7 @@ jobs:
202201
verbose: true
203202

204203
validate-release:
205-
name: Validate Release
204+
name: Validate Release on Python ${{ matrix.python-version }}
206205
needs: release
207206
runs-on: ubuntu-latest
208207
strategy:

0 commit comments

Comments
 (0)