Skip to content

Commit 5990fc4

Browse files
Merge pull request #6 from javidahmed64592/update-workflows
Add setup actions for Python environment and refactor CI workflow
2 parents 276e289 + ffc9a6d commit 5990fc4

3 files changed

Lines changed: 47 additions & 50 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Setup Python Environment (Core)
2+
description: Sets up Python with uv and installs core dependencies
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: Install uv
8+
uses: astral-sh/setup-uv@v5
9+
with:
10+
enable-cache: true
11+
cache-dependency-glob: "uv.lock"
12+
- name: "Set up Python"
13+
uses: actions/setup-python@v5
14+
with:
15+
python-version-file: ".python-version"
16+
- name: Install dependencies
17+
run: |
18+
uv sync
19+
shell: bash
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Setup Python Environment (Dev)
2+
description: Sets up Python with uv and installs dev dependencies
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: Install uv
8+
uses: astral-sh/setup-uv@v5
9+
with:
10+
enable-cache: true
11+
cache-dependency-glob: "uv.lock"
12+
- name: "Set up Python"
13+
uses: actions/setup-python@v5
14+
with:
15+
python-version-file: ".python-version"
16+
- name: Install dependencies
17+
run: |
18+
uv sync --extra dev
19+
shell: bash

.github/workflows/ci.yml

Lines changed: 9 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -13,61 +13,31 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v4
16-
- name: Install uv
17-
uses: astral-sh/setup-uv@v5
18-
with:
19-
enable-cache: true
20-
cache-dependency-glob: "uv.lock"
21-
- name: "Set up Python"
22-
uses: actions/setup-python@v5
23-
with:
24-
python-version-file: ".python-version"
25-
- name: Install dependencies
26-
run: |
27-
uv sync --extra dev
16+
- uses: ./.github/actions/setup-python-dev
2817
- name: Validate pyproject.toml
2918
run: |
3019
uv run validate-pyproject pyproject.toml
3120
ruff:
3221
runs-on: ubuntu-latest
3322
steps:
3423
- uses: actions/checkout@v4
35-
- uses: chartboost/ruff-action@v1
24+
- uses: ./.github/actions/setup-python-dev
25+
- name: Check with ruff
26+
run: |
27+
uv run -m ruff check
3628
mypy:
3729
runs-on: ubuntu-latest
3830
steps:
3931
- uses: actions/checkout@v4
40-
- name: Install uv
41-
uses: astral-sh/setup-uv@v5
42-
with:
43-
enable-cache: true
44-
cache-dependency-glob: "uv.lock"
45-
- name: "Set up Python"
46-
uses: actions/setup-python@v5
47-
with:
48-
python-version-file: ".python-version"
49-
- name: Install dependencies
50-
run: |
51-
uv sync --extra dev
32+
- uses: ./.github/actions/setup-python-dev
5233
- name: Check with mypy
5334
run: |
5435
uv run -m mypy .
5536
test:
5637
runs-on: ubuntu-latest
5738
steps:
5839
- uses: actions/checkout@v4
59-
- name: Install uv
60-
uses: astral-sh/setup-uv@v5
61-
with:
62-
enable-cache: true
63-
cache-dependency-glob: "uv.lock"
64-
- name: "Set up Python"
65-
uses: actions/setup-python@v5
66-
with:
67-
python-version-file: ".python-version"
68-
- name: Install dependencies
69-
run: |
70-
uv sync --extra dev
40+
- uses: ./.github/actions/setup-python-dev
7141
- name: Test with pytest
7242
run: |
7343
uv run -m pytest --cov-report html
@@ -80,25 +50,14 @@ jobs:
8050
runs-on: ubuntu-latest
8151
steps:
8252
- uses: actions/checkout@v4
83-
- name: Install uv
84-
uses: astral-sh/setup-uv@v5
85-
with:
86-
enable-cache: true
87-
cache-dependency-glob: "uv.lock"
88-
- name: "Set up Python"
89-
uses: actions/setup-python@v5
90-
with:
91-
python-version-file: ".python-version"
92-
- name: Install dependencies
93-
run: |
94-
uv sync --extra dev
53+
- uses: ./.github/actions/setup-python-dev
9554
- name: Check version consistency
9655
run: |
9756
echo "Checking version consistency across all package files..."
9857
9958
PACKAGE_NAME="example"
10059
TOML_VERSION=$(uv run python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
101-
LOCK_VERSION=$(uv run python -c "import tomllib; lock_data = tomllib.load(open('uv.lock', 'rb')); pkg = next((p for p in lock_data['package'] if p['name'] == '${PACKAGE_NAME/_/-}'), None); print(pkg['version'] if pkg else 'not found')")
60+
LOCK_VERSION=$(uv run python -c "import tomllib; lock_data = tomllib.load(open('uv.lock', 'rb')); pkg = next((p for p in lock_data['package'] if p['name'] == '${PACKAGE_NAME}'), None); print(pkg['version'] if pkg else 'not found')")
10261
10362
echo "Version in pyproject.toml: $TOML_VERSION"
10463
echo "Version in uv.lock: $LOCK_VERSION"

0 commit comments

Comments
 (0)