Skip to content

Commit 0adfd22

Browse files
committed
fix: cache crash
1 parent e89aaec commit 0adfd22

File tree

2 files changed

+79
-16
lines changed

2 files changed

+79
-16
lines changed

.github/workflows/pythonpackage.yml

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,24 @@ jobs:
5555
with:
5656
python-version: ${{ matrix.python-version }}
5757
allow-prereleases: true
58-
cache: 'pip'
59-
cache-dependency-path: |
60-
requirements*.txt
61-
requirements-dev.in
6258

6359
- name: Install uv
6460
uses: astral-sh/setup-uv@v6
6561
with:
6662
enable-cache: true
67-
cache-dependency-glob: requirements*.txt
63+
cache-dependency-glob: |
64+
requirements*.txt
65+
requirements-dev.in
66+
pyproject.toml
6867
6968
- name: Install dependencies
7069
run: |
7170
uv pip install --system -e .
7271
uv pip install --system pytest pytest-xdist pytest-cov
7372
73+
- name: Create coverage directory
74+
run: mkdir -p coverage/reports
75+
7476
- name: Run tests
7577
run: |
7678
pytest --cov=json2xml --cov-report=xml:coverage/reports/coverage.xml --cov-report=term -xvs tests -n auto
@@ -83,12 +85,15 @@ jobs:
8385
with:
8486
directory: ./coverage/reports/
8587
env_vars: OS,PYTHON
86-
fail_ci_if_error: true
88+
fail_ci_if_error: false # Don't fail CI if codecov upload fails
8789
files: ./coverage/reports/coverage.xml
8890
flags: unittests
8991
token: ${{ secrets.CODECOV_TOKEN }}
9092
name: codecov-umbrella
9193
verbose: true
94+
env:
95+
OS: ${{ matrix.os }}
96+
PYTHON: ${{ matrix.python-version }}
9297

9398
lint:
9499
runs-on: ubuntu-latest
@@ -101,16 +106,15 @@ jobs:
101106
uses: actions/[email protected]
102107
with:
103108
python-version: '3.12'
104-
cache: 'pip'
105-
cache-dependency-path: |
106-
requirements*.txt
107-
requirements-dev.in
108109

109110
- name: Install uv
110111
uses: astral-sh/setup-uv@v6
111112
with:
112113
enable-cache: true
113-
cache-dependency-glob: requirements*.txt
114+
cache-dependency-glob: |
115+
requirements*.txt
116+
requirements-dev.in
117+
pyproject.toml
114118
115119
- name: Install dependencies
116120
run: |
@@ -131,16 +135,15 @@ jobs:
131135
uses: actions/[email protected]
132136
with:
133137
python-version: '3.12'
134-
cache: 'pip'
135-
cache-dependency-path: |
136-
requirements*.txt
137-
requirements-dev.in
138138

139139
- name: Install uv
140140
uses: astral-sh/setup-uv@v6
141141
with:
142142
enable-cache: true
143-
cache-dependency-glob: requirements*.txt
143+
cache-dependency-glob: |
144+
requirements*.txt
145+
requirements-dev.in
146+
pyproject.toml
144147
145148
- name: Install dependencies
146149
run: |

dev.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/usr/bin/env python3
2+
"""Development script for running tests, linting, and type checking."""
3+
4+
import subprocess
5+
import sys
6+
from pathlib import Path
7+
8+
9+
def run_command(cmd: list[str], description: str) -> bool:
10+
"""Run a command and return True if successful."""
11+
print(f"\n🔍 {description}...")
12+
try:
13+
result = subprocess.run(cmd, check=True, cwd=Path(__file__).parent)
14+
print(f"✅ {description} passed!")
15+
return True
16+
except subprocess.CalledProcessError as e:
17+
print(f"❌ {description} failed with exit code {e.returncode}")
18+
return False
19+
20+
21+
def main() -> None:
22+
"""Run development checks."""
23+
if len(sys.argv) > 1:
24+
command = sys.argv[1]
25+
else:
26+
command = "all"
27+
28+
success = True
29+
30+
if command in ("lint", "all"):
31+
success &= run_command(["ruff", "check", "json2xml", "tests"], "Linting")
32+
33+
if command in ("test", "all"):
34+
success &= run_command([
35+
"pytest", "--cov=json2xml", "--cov-report=term",
36+
"-xvs", "tests", "-n", "auto"
37+
], "Tests")
38+
39+
if command in ("typecheck", "all"):
40+
success &= run_command(["mypy", "json2xml", "tests"], "Type checking")
41+
42+
if command == "help":
43+
print("Usage: python dev.py [command]")
44+
print("Commands:")
45+
print(" all - Run all checks (default)")
46+
print(" lint - Run linting only")
47+
print(" test - Run tests only")
48+
print(" typecheck - Run type checking only")
49+
print(" help - Show this help")
50+
return
51+
52+
if not success:
53+
print(f"\n❌ Some checks failed!")
54+
sys.exit(1)
55+
else:
56+
print(f"\n🎉 All checks passed!")
57+
58+
59+
if __name__ == "__main__":
60+
main()

0 commit comments

Comments
 (0)