Skip to content

Commit a4ac073

Browse files
committed
refactor: Use environment variables for Python version and cache type in CI workflow
1 parent fd95fce commit a4ac073

File tree

1 file changed

+27
-9
lines changed

1 file changed

+27
-9
lines changed

.github/workflows/ci.yaml

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ on:
1010
- main
1111
- develop
1212

13+
env:
14+
PYTHON_VERSION: 3.12
15+
PYTHON_CACHE_TYPE: 'poetry'
16+
1317
jobs:
1418
# これ以降のジョブでキャッシュが使えるようにする
1519
setup:
@@ -18,12 +22,11 @@ jobs:
1822
- name: Checkout code
1923
uses: actions/checkout@v4
2024

21-
- &setup-python
22-
name: Set up Python
25+
- name: Set up Python
2326
uses: actions/setup-python@v5
2427
with:
25-
python-version: 3.12
26-
cache: 'poetry'
28+
python-version: ${{ env.PYTHON_VERSION }}
29+
cache: ${{ env.PYTHON_CACHE_TYPE }}
2730

2831
ruff-format:
2932
needs: setup
@@ -32,7 +35,11 @@ jobs:
3235
- name: Checkout code
3336
uses: actions/checkout@v4
3437

35-
- *setup-python
38+
- name: Set up Python
39+
uses: actions/setup-python@v5
40+
with:
41+
python-version: ${{ env.PYTHON_VERSION }}
42+
cache: ${{ env.PYTHON_CACHE_TYPE }}
3643

3744
- name: Check ruff version
3845
run: poetry run ruff --version
@@ -47,7 +54,11 @@ jobs:
4754
- name: Checkout code
4855
uses: actions/checkout@v4
4956

50-
- *setup-python
57+
- name: Set up Python
58+
uses: actions/setup-python@v5
59+
with:
60+
python-version: ${{ env.PYTHON_VERSION }}
61+
cache: ${{ env.PYTHON_CACHE_TYPE }}
5162

5263
- name: Check ruff version
5364
run: poetry run ruff --version
@@ -62,7 +73,11 @@ jobs:
6273
- name: Checkout code
6374
uses: actions/checkout@v4
6475

65-
- *setup-python
76+
- name: Set up Python
77+
uses: actions/setup-python@v5
78+
with:
79+
python-version: ${{ env.PYTHON_VERSION }}
80+
cache: ${{ env.PYTHON_CACHE_TYPE }}
6681

6782
- name: Check mypy version
6883
run: poetry run mypy --version
@@ -77,9 +92,12 @@ jobs:
7792
- name: Checkout code
7893
uses: actions/checkout@v4
7994

80-
- *setup-python
95+
- name: Set up Python
96+
uses: actions/setup-python@v5
97+
with:
98+
python-version: ${{ env.PYTHON_VERSION }}
99+
cache: ${{ env.PYTHON_CACHE_TYPE }}
81100

82101
- name: Run pytest
83102
run: |
84-
source .venv/bin/activate
85103
poetry run pytest tests/

0 commit comments

Comments
 (0)