|
12 | 12 |
|
13 | 13 | jobs: |
14 | 14 | setup: |
| 15 | + name: Setup ✅ |
15 | 16 | runs-on: ubuntu-latest |
| 17 | + outputs: |
| 18 | + cache-hit: ${{ steps.setup_uv.outputs.cache-hit }} |
16 | 19 | steps: |
17 | 20 | - name: Checkout code |
18 | 21 | uses: actions/checkout@v4 |
19 | 22 |
|
20 | | - - name: Set up Python |
21 | | - uses: actions/setup-python@v5 |
| 23 | + - name: Install uv (+ enable cache) |
| 24 | + id: setup_uv |
| 25 | + uses: astral-sh/setup-uv@v6 |
22 | 26 | with: |
23 | | - python-version: 3.12 |
| 27 | + enable-cache: true |
24 | 28 |
|
25 | | - - name: Cache virtual environment |
26 | | - id: cached-virtualenv |
27 | | - uses: actions/cache@v4 |
28 | | - with: |
29 | | - path: .venv |
30 | | - key: ${{ runner.os }}-venv-${{ hashFiles('**/uv.lock') }} |
31 | | - |
32 | | - - name: Install dependencies |
33 | | - if: steps.cached-virtualenv.outputs.cache-hit != 'true' |
34 | | - run: | |
35 | | - python -m venv .venv |
36 | | - source .venv/bin/activate |
37 | | - pip install --upgrade pip |
38 | | - pip install uv |
39 | | - uv sync |
| 29 | + - name: Sync dependencies |
| 30 | + run: uv sync --locked --dev |
| 31 | + |
| 32 | + - name: Prune uv cache (optimized for CI) |
| 33 | + run: uv cache prune --ci |
40 | 34 |
|
41 | 35 | ruff-format: |
| 36 | + name: Ruff format check |
42 | 37 | needs: setup |
43 | 38 | runs-on: ubuntu-latest |
44 | 39 | steps: |
45 | 40 | - name: Checkout code |
46 | 41 | uses: actions/checkout@v4 |
47 | 42 |
|
48 | | - - name: Restore virtual environment cache |
49 | | - uses: actions/cache@v4 |
| 43 | + - name: Install uv + restore cache |
| 44 | + uses: astral-sh/setup-uv@v6 |
50 | 45 | with: |
51 | | - path: .venv |
52 | | - key: ${{ runner.os }}-venv-${{ hashFiles('**/uv.lock') }} |
53 | | - |
54 | | - - name: Set path |
55 | | - run: echo ${{ github.workspace }}/.venv/bin >> $GITHUB_PATH |
| 46 | + enable-cache: true |
56 | 47 |
|
57 | | - - name: Check ruff version |
58 | | - run: uv run ruff --version |
59 | | - |
60 | | - - name: Run ruff format check |
| 48 | + - name: Check ruff formatting |
61 | 49 | run: uv run ruff format --check . |
62 | 50 |
|
63 | 51 | ruff-lint: |
| 52 | + name: Ruff lint check |
64 | 53 | needs: setup |
65 | 54 | runs-on: ubuntu-latest |
66 | 55 | steps: |
67 | 56 | - name: Checkout code |
68 | 57 | uses: actions/checkout@v4 |
69 | 58 |
|
70 | | - - name: Restore virtual environment cache |
71 | | - uses: actions/cache@v4 |
| 59 | + - name: Install uv + restore cache |
| 60 | + uses: astral-sh/setup-uv@v6 |
72 | 61 | with: |
73 | | - path: .venv |
74 | | - key: ${{ runner.os }}-venv-${{ hashFiles('**/poetry.lock') }} |
75 | | - |
76 | | - - name: Set path |
77 | | - run: echo ${{ github.workspace }}/.venv/bin >> $GITHUB_PATH |
78 | | - |
79 | | - - name: Check ruff version |
80 | | - run: uv run ruff --version |
| 62 | + enable-cache: true |
81 | 63 |
|
82 | 64 | - name: Run ruff lint |
83 | 65 | run: uv run ruff check --output-format=github . |
84 | 66 |
|
85 | 67 | mypy-type-check: |
| 68 | + name: MyPy type check |
86 | 69 | needs: setup |
87 | 70 | runs-on: ubuntu-latest |
88 | 71 | steps: |
89 | 72 | - name: Checkout code |
90 | 73 | uses: actions/checkout@v4 |
91 | 74 |
|
92 | | - - name: Restore virtual environment cache |
93 | | - uses: actions/cache@v4 |
| 75 | + - name: Install uv + restore cache |
| 76 | + uses: astral-sh/setup-uv@v6 |
94 | 77 | with: |
95 | | - path: .venv |
96 | | - key: ${{ runner.os }}-venv-${{ hashFiles('**/poetry.lock') }} |
97 | | - |
98 | | - - name: Set path |
99 | | - run: echo ${{ github.workspace }}/.venv/bin >> $GITHUB_PATH |
| 78 | + enable-cache: true |
100 | 79 |
|
101 | | - - name: Check mypy version |
102 | | - run: uv run mypy --version |
103 | | - |
104 | | - - name: Run mypy type check |
105 | | - run: uv run mypy . |
| 80 | + - name: Run mypy |
| 81 | + run: uv run --frozen mypy . |
106 | 82 |
|
107 | 83 | pytest: |
| 84 | + name: PyTest |
108 | 85 | needs: setup |
109 | 86 | runs-on: ubuntu-latest |
110 | 87 | steps: |
111 | 88 | - name: Checkout code |
112 | 89 | uses: actions/checkout@v4 |
113 | 90 |
|
114 | | - - name: Restore virtual environment cache |
115 | | - uses: actions/cache@v4 |
| 91 | + - name: Install uv + restore cache |
| 92 | + uses: astral-sh/setup-uv@v6 |
116 | 93 | with: |
117 | | - path: .venv |
118 | | - key: ${{ runner.os }}-venv-${{ hashFiles('**/poetry.lock') }} |
119 | | - |
120 | | - - name: Set path |
121 | | - run: echo ${{ github.workspace }}/.venv/bin >> $GITHUB_PATH |
| 94 | + enable-cache: true |
122 | 95 |
|
123 | | - - name: Run pytest |
124 | | - run: pytest tests/ |
| 96 | + - name: Run tests |
| 97 | + run: uv run --frozen pytest tests/ |
125 | 98 |
|
126 | 99 | publish: |
127 | 100 | runs-on: ubuntu-latest |
|
0 commit comments