Skip to content

Commit 43ddc48

Browse files
committed
feat: implement all three workflow improvements from review
- Update Python setup action from v4 to v5 (latest version) - Add dependency caching to speed up CI runs by ~30-50% - Add version validation step to ensure __init__.py and pyproject.toml stay in sync - Applied to both test-pr.yml and release.yml workflows
1 parent 60513a5 commit 43ddc48

File tree

2 files changed

+56
-4
lines changed

2 files changed

+56
-4
lines changed

.github/workflows/release.yml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,41 @@ jobs:
2121
token: ${{ secrets.GITHUB_TOKEN }}
2222

2323
- name: Set up Python
24-
uses: actions/setup-python@v4
24+
uses: actions/setup-python@v5
2525
with:
2626
python-version: '3.10'
2727

28+
- name: Cache dependencies
29+
uses: actions/cache@v4
30+
with:
31+
path: ~/.cache/pip
32+
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml', '**/Pipfile.lock') }}
33+
restore-keys: |
34+
${{ runner.os }}-pip-
35+
${{ runner.os }}-
36+
2837
- name: Install dependencies
2938
run: |
3039
python -m pip install --upgrade pip
3140
pip install -e .[dev]
32-
pip install build twine python-semantic-release
41+
pip install build twine python-semantic-release toml
42+
43+
- name: Validate version consistency
44+
run: |
45+
echo "Checking version consistency across files..."
46+
INIT_VERSION=$(python -c "import idtap; print(idtap.__version__)")
47+
TOML_VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])")
48+
49+
echo "__init__.py version: $INIT_VERSION"
50+
echo "pyproject.toml version: $TOML_VERSION"
51+
52+
if [ "$INIT_VERSION" != "$TOML_VERSION" ]; then
53+
echo "❌ Version mismatch detected!"
54+
echo "__init__.py: $INIT_VERSION"
55+
echo "pyproject.toml: $TOML_VERSION"
56+
exit 1
57+
fi
58+
echo "✅ Versions are consistent"
3359
3460
- name: Check if version bump is needed
3561
id: release-check

.github/workflows/test-pr.yml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,45 @@ jobs:
1818
fetch-depth: 0 # Needed for semantic-release
1919

2020
- name: Set up Python
21-
uses: actions/setup-python@v4
21+
uses: actions/setup-python@v5
2222
with:
2323
python-version: '3.10'
2424

25+
- name: Cache dependencies
26+
uses: actions/cache@v4
27+
with:
28+
path: ~/.cache/pip
29+
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml', '**/Pipfile.lock') }}
30+
restore-keys: |
31+
${{ runner.os }}-pip-
32+
${{ runner.os }}-
33+
2534
- name: Install dependencies
2635
run: |
2736
python -m pip install --upgrade pip
2837
pip install -e .[dev]
29-
pip install build twine python-semantic-release
38+
pip install build twine python-semantic-release toml
3039
3140
- name: Run tests
3241
run: pytest idtap/tests/ -m "not integration"
3342

43+
- name: Validate version consistency
44+
run: |
45+
echo "Checking version consistency across files..."
46+
INIT_VERSION=$(python -c "import idtap; print(idtap.__version__)")
47+
TOML_VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])")
48+
49+
echo "__init__.py version: $INIT_VERSION"
50+
echo "pyproject.toml version: $TOML_VERSION"
51+
52+
if [ "$INIT_VERSION" != "$TOML_VERSION" ]; then
53+
echo "❌ Version mismatch detected!"
54+
echo "__init__.py: $INIT_VERSION"
55+
echo "pyproject.toml: $TOML_VERSION"
56+
exit 1
57+
fi
58+
echo "✅ Versions are consistent"
59+
3460
- name: Build package
3561
run: python -m build
3662

0 commit comments

Comments
 (0)