Skip to content

Commit d3be3dd

Browse files
committed
feat: CIの設定をuvを使用するように更新し、キャッシュ管理を最適化
1 parent 1c6c26d commit d3be3dd

File tree

1 file changed

+33
-60
lines changed

1 file changed

+33
-60
lines changed

.github/workflows/ci.yaml

Lines changed: 33 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -12,116 +12,89 @@ on:
1212

1313
jobs:
1414
setup:
15+
name: Setup ✅
1516
runs-on: ubuntu-latest
17+
outputs:
18+
cache-hit: ${{ steps.setup_uv.outputs.cache-hit }}
1619
steps:
1720
- name: Checkout code
1821
uses: actions/checkout@v4
1922

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
2226
with:
23-
python-version: 3.12
27+
enable-cache: true
2428

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
4034

4135
ruff-format:
36+
name: Ruff format check
4237
needs: setup
4338
runs-on: ubuntu-latest
4439
steps:
4540
- name: Checkout code
4641
uses: actions/checkout@v4
4742

48-
- name: Restore virtual environment cache
49-
uses: actions/cache@v4
43+
- name: Install uv + restore cache
44+
uses: astral-sh/setup-uv@v6
5045
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
5647

57-
- name: Check ruff version
58-
run: uv run ruff --version
59-
60-
- name: Run ruff format check
48+
- name: Check ruff formatting
6149
run: uv run ruff format --check .
6250

6351
ruff-lint:
52+
name: Ruff lint check
6453
needs: setup
6554
runs-on: ubuntu-latest
6655
steps:
6756
- name: Checkout code
6857
uses: actions/checkout@v4
6958

70-
- name: Restore virtual environment cache
71-
uses: actions/cache@v4
59+
- name: Install uv + restore cache
60+
uses: astral-sh/setup-uv@v6
7261
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
8163

8264
- name: Run ruff lint
8365
run: uv run ruff check --output-format=github .
8466

8567
mypy-type-check:
68+
name: MyPy type check
8669
needs: setup
8770
runs-on: ubuntu-latest
8871
steps:
8972
- name: Checkout code
9073
uses: actions/checkout@v4
9174

92-
- name: Restore virtual environment cache
93-
uses: actions/cache@v4
75+
- name: Install uv + restore cache
76+
uses: astral-sh/setup-uv@v6
9477
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
10079

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 .
10682

10783
pytest:
84+
name: PyTest
10885
needs: setup
10986
runs-on: ubuntu-latest
11087
steps:
11188
- name: Checkout code
11289
uses: actions/checkout@v4
11390

114-
- name: Restore virtual environment cache
115-
uses: actions/cache@v4
91+
- name: Install uv + restore cache
92+
uses: astral-sh/setup-uv@v6
11693
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
12295

123-
- name: Run pytest
124-
run: pytest tests/
96+
- name: Run tests
97+
run: uv run --frozen pytest tests/
12598

12699
publish:
127100
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)