Skip to content

Commit c269ff8

Browse files
committed
refactor: remove hard-coded versions from CI
1 parent d13437a commit c269ff8

File tree

11 files changed

+68
-39
lines changed

11 files changed

+68
-39
lines changed

.github/workflows/apply-styles.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ jobs:
1616
runs-on: ubuntu-latest
1717
steps:
1818
- uses: actions/checkout@v4
19-
- name: Set up Python 3.11
19+
- name: Set up Python
2020
uses: actions/setup-python@v5
2121
with:
22-
python-version: 3.11
22+
python-version-file: pyproject.toml
2323
- name: Install ruff
2424
run: |
2525
pip3 install ruff==0.1.14

.github/workflows/deploy.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,13 @@ jobs:
5252
tag: ${{ github.event.inputs.version_tag }}
5353
body: ${{ steps.changelog.outputs.changes }}
5454

55-
- name: Set up Python ${{ matrix.python-version }}
55+
- name: Set up Python
5656
uses: actions/setup-python@v5
5757
with:
58-
python-version: 3.11
58+
python-version-file: pyproject.toml
59+
cache: 'pip'
60+
cache-dependency-path: |
61+
requirements_docs.txt
5962
- name: Install dependencies
6063
run: |
6164
python -m pip install --upgrade pip

.github/workflows/docs.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@ jobs:
1313

1414
steps:
1515
- uses: actions/checkout@v4
16-
- name: Set up Python ${{ matrix.python-version }}
16+
- name: Set up Python
1717
uses: actions/setup-python@v5
1818
with:
19-
python-version: 3.11
19+
python-version-file: pyproject.toml
20+
cache: 'pip'
21+
cache-dependency-path: |
22+
requirements_docs.txt
2023
- name: Install dependencies
2124
run: |
2225
python -m pip install --upgrade pip

.github/workflows/lint.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ jobs:
88
runs-on: ubuntu-latest
99
steps:
1010
- uses: actions/checkout@v4
11-
- name: Set up Python 3.11
11+
- name: Set up Python
1212
uses: actions/setup-python@v5
1313
with:
14-
python-version: 3.11
14+
python-version-file: pyproject.toml
1515
- name: Install ruff and requirements
1616
run: |
17-
pip3 install ruff==0.1.14
17+
pip3 install -r <(cat requirements_dev.txt | grep '^ruff==')
1818
- name: Run ruff
1919
run: |
2020
set +e # Do not exit shell on ruff failure

.github/workflows/styles-only-changed.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ jobs:
2222
files: |
2323
**.py
2424
25-
- name: Set up Python 3.11
25+
- name: Set up Python
2626
if: steps.changed-python-files.outputs.any_changed == 'true'
2727
uses: actions/setup-python@v5
2828
with:
29-
python-version: 3.11
29+
python-version-file: pyproject.toml
3030
- name: Install ruff
3131
if: steps.changed-python-files.outputs.any_changed == 'true'
3232
run: |
33-
pip3 install ruff==0.1.14
33+
pip3 install -r <(cat requirements_dev.txt | grep '^ruff==')
3434
- name: Run ruff
3535
if: steps.changed-python-files.outputs.any_changed == 'true'
3636
run: |
@@ -68,15 +68,15 @@ jobs:
6868
files: |
6969
**.py
7070
71-
- name: Set up Python 3.11
71+
- name: Set up Python
7272
if: steps.changed-python-files.outputs.any_changed == 'true'
7373
uses: actions/setup-python@v5
7474
with:
75-
python-version: 3.11
75+
python-version-file: pyproject.toml
7676
- name: Install ruff
7777
if: steps.changed-python-files.outputs.any_changed == 'true'
7878
run: |
79-
pip3 install ruff==0.1.14
79+
pip3 install -r <(cat requirements_dev.txt | grep '^ruff==')
8080
- name: Run ruff isort
8181
if: steps.changed-python-files.outputs.any_changed == 'true'
8282
run: |
@@ -114,15 +114,15 @@ jobs:
114114
files: |
115115
**.py
116116
117-
- name: Set up Python 3.11
117+
- name: Set up Python
118118
if: steps.changed-python-files.outputs.any_changed == 'true'
119119
uses: actions/setup-python@v5
120120
with:
121-
python-version: 3.11
121+
python-version-file: pyproject.toml
122122
- name: Install ruff
123123
if: steps.changed-python-files.outputs.any_changed == 'true'
124124
run: |
125-
pip3 install ruff==0.1.14
125+
pip3 install -r <(cat requirements_dev.txt | grep '^ruff==')
126126
- name: Run ruff
127127
if: steps.changed-python-files.outputs.any_changed == 'true'
128128
run: |

.github/workflows/styles.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ jobs:
88
runs-on: ubuntu-latest
99
steps:
1010
- uses: actions/checkout@v4
11-
- name: Set up Python 3.11
11+
- name: Set up Python
1212
uses: actions/setup-python@v5
1313
with:
14-
python-version: 3.11
14+
python-version-file: pyproject.toml
1515
- name: Install ruff
1616
run: |
17-
pip3 install ruff==0.1.14
17+
pip3 install -r <(cat requirements_dev.txt | grep '^ruff==')
1818
- name: Run ruff format
1919
run: |
2020
set +e # Do not exit shell on black failure
@@ -40,13 +40,13 @@ jobs:
4040
runs-on: ubuntu-latest
4141
steps:
4242
- uses: actions/checkout@v4
43-
- name: Set up Python 3.11
43+
- name: Set up Python
4444
uses: actions/setup-python@v5
4545
with:
46-
python-version: 3.11
46+
python-version-file: pyproject.toml
4747
- name: Install ruff
4848
run: |
49-
pip3 install ruff==0.1.14
49+
pip3 install -r <(cat requirements_dev.txt | grep '^ruff==')
5050
- name: Run ruff isort
5151
run: |
5252
set +e # Do not exit shell on app failure

.github/workflows/tests.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,15 @@ jobs:
1212
shell: bash -el {0} # setup-miniconda requires bash
1313
steps:
1414
- uses: actions/checkout@v4
15+
- run: |
16+
pip3 install toml
17+
echo "python_version=$(python3 scripts/get_python_version.py)" >> $GITHUB_OUTPUT
18+
id: get-python-version
1519
- uses: conda-incubator/setup-miniconda@v3
1620
with:
1721
miniforge-version: latest
1822
activate-environment: test
23+
python-version: ${{ steps.get-python-version.outputs.python_version }}
1924
- name: Cache Conda environment
2025
id: cache-conda
2126
uses: actions/cache@v4
@@ -34,7 +39,6 @@ jobs:
3439
- name: Install dependencies
3540
if: steps.cache-conda.outputs.cache-hit != 'true'
3641
run: |
37-
mamba install python=3.11 -y
3842
python -m pip install --upgrade pip
3943
pip3 install -r requirements.txt -r requirements_dev.txt
4044
pip3 install -e .
@@ -72,10 +76,15 @@ jobs:
7276
shell: bash -el {0} # setup-miniconda requires bash
7377
steps:
7478
- uses: actions/checkout@v4
79+
- run: |
80+
pip3 install toml
81+
echo "python_version=$(python3 scripts/get_python_version.py)" >> $GITHUB_OUTPUT
82+
id: get-python-version
7583
- uses: conda-incubator/setup-miniconda@v3
7684
with:
7785
miniforge-version: latest
7886
activate-environment: test
87+
python-version: ${{ steps.get-python-version.outputs.python_version }}
7988
- name: Cache Conda environment
8089
id: cache-conda
8190
uses: actions/cache@v4
@@ -94,7 +103,6 @@ jobs:
94103
- name: Install dependencies
95104
if: steps.cache-conda.outputs.cache-hit != 'true'
96105
run: |
97-
mamba install python=3.11 -y
98106
python -m pip install --upgrade pip
99107
pip3 install -r requirements.txt -r requirements_dev.txt
100108
pip3 install -e .

pyproject.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,11 @@ authors = [
1919
]
2020
readme = "README.md"
2121
license = { file = "LICENSE" }
22-
requires-python = ">=3.10"
22+
requires-python = ">=3.11,<3.12"
2323
classifiers = [
2424
"Programming Language :: Python",
2525
"Programming Language :: Python :: 3",
26-
"Programming Language :: Python :: 3.10",
2726
"Programming Language :: Python :: 3.11",
28-
"Programming Language :: Python :: 3.12",
2927
]
3028
keywords = ["development", "template"]
3129
dependencies = [
@@ -38,7 +36,7 @@ dev = ["black >= 23.9.0"]
3836
test = ["pytest >= 7.4.0", "pytest-cov >= 4.1.0"]
3937

4038
[project.urls]
41-
"Homepage" = "https://github.com/innerverz-ai/python-project-template-2023" # OPTIONALLY CHANGE
39+
"Homepage" = "https://github.com/deargen/python-project-template-2024" # OPTIONALLY CHANGE
4240

4341
[tool.setuptools.packages.find]
4442
where = ["src"]

requirements_dev.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
ruff==0.1.14
2-
pytest==7.4.2
1+
ruff==0.2.0
2+
pytest==8.0.0
33
pytest-cov==4.1.0
44
types-tqdm==4.66.1
55
types-seaborn

scripts/gen_init_py.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,27 @@
11
"""
22
Automatically generate __init__.py files for all subdirectories.
3+
34
Useful before building mkdocs documentation.
45
"""
6+
# flake8: noqa: T201
57

68
import os
79
from pathlib import Path
810

911

1012
def gen_init_py(path):
11-
"""Generate __init__.py files for all subdirectories of path"""
13+
"""Generate __init__.py files for all subdirectories of path."""
1214
for root, _, files in os.walk(path):
1315
if "__init__.py" in files:
1416
continue
15-
if root == path:
17+
if Path(root).samefile(path):
1618
continue
1719
if "__pycache__" in root:
1820
continue
1921
if root.endswith(".egg-info"):
2022
continue
21-
if root.endswith("src/ppmi/masif/data_pipe/data_list"):
22-
continue
23-
if root == str(SRC_DIR):
24-
continue
2523

26-
with open(os.path.join(root, "__init__.py"), "w") as f:
24+
with open(Path(root) / "__init__.py", "w") as f:
2725
print("Generating __init__.py in", root)
2826
f.write("")
2927

0 commit comments

Comments
 (0)