Skip to content

Commit 4341957

Browse files
author
Jacob Garber
committed
Add github action for installing python and poetry
Some of the workflows were installing the dependencies using pip, which always grabs the latest allowed package version. This was causing subtle failures in some cases since the new versions may not be compatible (e.g. numpy 2) or have bugs (e.g. pandas). This adds a re-usable action so all the workflows setup python in the same way, and install packages with poetry (which will follow the lock file).
1 parent af991c9 commit 4341957

9 files changed

Lines changed: 40 additions & 56 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: 'Setup python and poetry'
2+
inputs:
3+
python-version:
4+
required: true
5+
runs:
6+
using: "composite"
7+
steps:
8+
- name: Install poetry
9+
shell: bash
10+
run: pipx install poetry
11+
12+
- name: Setup python
13+
uses: actions/setup-python@v6
14+
with:
15+
python-version: ${{ inputs.python-version }}
16+
cache: poetry
17+
18+
- name: Install packages
19+
shell: bash
20+
run: |
21+
poetry env use ${{ inputs.python-version }}
22+
poetry install --extras dev

.github/workflows/coverage.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,12 @@ jobs:
1616
uses: actions/checkout@v4
1717

1818
- name: Setup python
19-
uses: actions/setup-python@v5
19+
uses: ./.github/actions/setup-python
2020
with:
21-
python-version: "3.10"
22-
cache: "pip"
23-
24-
- name: Install package
25-
run: pip install .[dev]
21+
python-version: "3.12"
2622

2723
- name: Run unit tests with coverage
28-
run: pytest -v tests --ignore tests/integration --cov malariagen_data/anoph --cov-report=xml
24+
run: poetry run pytest -v tests --ignore tests/integration --cov malariagen_data/anoph --cov-report=xml
2925

3026
- name: Upload coverage report
3127
uses: codecov/codecov-action@v3

.github/workflows/integration_tests.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,9 @@ jobs:
2121
uses: actions/checkout@v4
2222

2323
- name: Setup python
24-
uses: actions/setup-python@v5
24+
uses: ./.github/actions/setup-python
2525
with:
2626
python-version: ${{ matrix.python-version }}
27-
cache: "pip"
28-
29-
- name: Install package
30-
run: pip install .[dev]
3127

3228
- id: 'auth'
3329
name: 'Set up Google Cloud authentication'
@@ -50,7 +46,7 @@ jobs:
5046
key: gcs_cache_integration_tests_20240922
5147

5248
- name: Run integration tests
53-
run: pytest --durations=20 -v tests/integration
49+
run: poetry run pytest --durations=20 -v tests/integration
5450

5551
- name: Save GCS cache
5652
uses: actions/cache/save@v3

.github/workflows/latest_docs.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,14 @@ jobs:
1212
- name: Check out source 🛒
1313
uses: actions/checkout@v4
1414

15-
- name: Set up Python 🐍
16-
uses: actions/setup-python@v5
15+
- name: Setup python 🐍
16+
uses: ./.github/actions/setup-python
1717
with:
1818
python-version: '3.12'
1919

20-
- name: Install poetry
21-
run: pipx install poetry==1.8.3
22-
2320
- name: Eyeball native environment 👀
2421
run: python --version ; pip --version ; poetry --version ; pwd ; ls -la
2522

26-
- name: Install package dependencies 📜
27-
run: poetry install
28-
2923
- name: Build HTML 🏗️
3024
run: poetry run sphinx-build -b html docs/source docs/build/html
3125

.github/workflows/linting.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,12 @@ jobs:
1616
uses: actions/checkout@v4
1717

1818
- name: Setup python
19-
uses: actions/setup-python@v5
19+
uses: ./.github/actions/setup-python
2020
with:
2121
python-version: '3.12'
22-
cache: 'pip'
2322

2423
- name: Run pre-commit checks
2524
uses: pre-commit/action@v3.0.0
2625

27-
- name: Install package
28-
run: pip install .[dev]
29-
3026
- name: Run mypy
31-
run: |
32-
mypy malariagen_data tests --ignore-missing-imports
27+
run: poetry run mypy malariagen_data tests --ignore-missing-imports

.github/workflows/notebooks.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,9 @@ jobs:
1717
uses: actions/checkout@v4
1818

1919
- name: Setup python
20-
uses: actions/setup-python@v5
20+
uses: ./.github/actions/setup-python
2121
with:
2222
python-version: "3.12"
23-
cache: "pip"
24-
25-
- name: Install package
26-
run: pip install .[dev]
2723

2824
- id: 'auth'
2925
name: 'Set up Google Cloud authentication'
@@ -46,7 +42,7 @@ jobs:
4642
key: gcs_cache_notebooks_20240922
4743

4844
- name: Run notebooks
49-
run: jupyter nbconvert --execute notebooks/*.ipynb --inplace
45+
run: poetry run jupyter nbconvert --execute notebooks/*.ipynb --inplace
5046

5147
- name: Save GCS cache
5248
uses: actions/cache/save@v3

.github/workflows/release.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,10 @@ jobs:
1010
- name: Checkout source
1111
uses: actions/checkout@v4
1212

13-
- name: Install poetry
14-
run: pipx install poetry==1.8.3
15-
1613
- name: Setup python
17-
uses: actions/setup-python@v5
14+
uses: ./.github/actions/setup-python
1815
with:
1916
python-version: '3.12'
20-
cache: 'poetry'
2117

2218
- name: Configure poetry
2319
run: |

.github/workflows/tagged_docs.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,14 @@ jobs:
2424
with:
2525
ref: ${{ env.VERSION_TAG }}
2626

27-
- name: Set up Python 🐍
28-
uses: actions/setup-python@v5
27+
- name: Setup python 🐍
28+
uses: ./.github/actions/setup-python
2929
with:
3030
python-version: '3.12'
3131

32-
- name: Install poetry
33-
run: pipx install poetry==1.8.3
34-
3532
- name: Eyeball native environment 👀
3633
run: python --version ; pip --version ; poetry --version ; pwd ; ls -la
3734

38-
- name: Install package dependencies 📜
39-
run: poetry install
40-
4135
- name: Build HTML 🏗️
4236
run: poetry run sphinx-build -b html docs/source docs/build/html
4337

.github/workflows/tests.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,20 @@ jobs:
1111
strategy:
1212
fail-fast: true
1313
matrix:
14-
python-version: ["3.10"]
15-
numpy-version: ["numpy==1.26.4"]
14+
python-version: ["3.10", "3.11", "3.12"]
1615
runs-on: ubuntu-latest
1716

1817
steps:
1918
- name: Checkout source
2019
uses: actions/checkout@v4
2120

2221
- name: Setup python
23-
uses: actions/setup-python@v5
22+
uses: ./.github/actions/setup-python
2423
with:
2524
python-version: ${{ matrix.python-version }}
26-
cache: "pip"
27-
28-
- name: Install package
29-
run: pip install "${{ matrix.numpy-version }}" .[dev]
3025

3126
- name: Verify NumPy version
32-
run: python -c "import numpy; print('NumPy version:', numpy.__version__)"
27+
run: poetry run python -c "import numpy; print('NumPy version:', numpy.__version__)"
3328

3429
- name: Run unit tests
35-
run: pytest -v tests --ignore tests/integration --typeguard-packages=malariagen_data,malariagen_data.anoph
30+
run: poetry run pytest -v tests --ignore tests/integration --typeguard-packages=malariagen_data,malariagen_data.anoph

0 commit comments

Comments
 (0)