Skip to content

Commit 1bac212

Browse files
committed
Improve Python version handling and fix poetry installation
Signed-off-by: Tobias Wolf <[email protected]>
1 parent 5c91941 commit 1bac212

File tree

2 files changed

+29
-21
lines changed

2 files changed

+29
-21
lines changed

.github/actions/setup/action.yml

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,48 @@ inputs:
55
version:
66
description: GardenLinux Python library version
77
default: "0.8.9"
8+
python_version:
9+
description: Python version to setup
10+
default: "3.13"
811

912
outputs:
1013
version:
14+
description: GardenLinux Python library version
15+
value: ${{ inputs.version }}
16+
python_version:
17+
description: Python version to setup
18+
value: ${{ inputs.python_version }}
19+
package_tool:
1120
description: "Detected Python cache strategy."
12-
value: ${{ steps.env-check.outputs.cache_type }}
21+
value: ${{ steps.env-check.outputs.package_tool }}
1322

1423
runs:
1524
using: composite
1625
steps:
17-
- name: Verify requirements.txt for "actions/setup-python" with enabled "pip" cache
18-
shell: bash
19-
run: |
20-
if [ ! -f "requirements.txt" ]; then
21-
echo "gardenlinux @ git+https://github.com/gardenlinux/python-gardenlinux-lib.git@${{ inputs.version }}" | tee -a requirements.txt
22-
fi
23-
24-
- name: Evaluate Python Environment
26+
- name: Evaluate Python environment
2527
id: env-check
2628
shell: bash
2729
run: |
2830
# Determine cache type based on available lockfile
2931
if [ -f poetry.lock ]; then
30-
echo "cache_type=poetry" >> $GITHUB_OUTPUT
32+
echo "package_tool=poetry" >> $GITHUB_OUTPUT
3133
elif [ -f requirements.txt ]; then
32-
echo "cache_type=pip" >> $GITHUB_OUTPUT
34+
echo "package_tool=pip" >> $GITHUB_OUTPUT
3335
else
34-
# no lockfile present: create empty requirements.txt and use pip caching
35-
touch requirements.txt
36-
echo "cache_type=pip" >> $GITHUB_OUTPUT
36+
# no lockfile present: create one and use pip caching
37+
echo "gardenlinux @ git+https://github.com/gardenlinux/python-gardenlinux-lib.git@${{ inputs.version }}" | tee -a requirements.txt
38+
echo "package_tool=pip" >> $GITHUB_OUTPUT
3739
fi
3840
39-
- name: Set up Python 3.13
41+
- name: Install Poetry
42+
if: steps.env-check.outputs.package_tool == 'poetry'
43+
uses: snok/install-poetry@v1
44+
45+
- name: Set up Python ${{ inputs.python_version }}
4046
uses: actions/setup-python@v5
4147
with:
42-
python-version: "3.13"
43-
cache: ${{ steps.env-check.outputs.cache_type }}
48+
python-version: ${{ inputs.python_version }}
49+
cache: ${{ steps.env-check.outputs.package_tool }}
4450

4551
- name: Install GardenLinux Python library
4652
shell: bash

.github/workflows/pytests.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ jobs:
1111
test:
1212
name: Run tests and collect coverage
1313
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
python_version: [ "3.13" ]
1417
steps:
1518
- name: Checkout
1619
uses: actions/checkout@v4
@@ -19,9 +22,8 @@ jobs:
1922

2023
- name: Setup Gardenlinux
2124
uses: ./.github/actions/setup
22-
23-
- name: Install Poetry
24-
uses: snok/install-poetry@v1
25+
with:
26+
python_version: ${{ matrix.python_version }}
2527

2628
- name: Install dependencies
2729
run: poetry install --with dev
@@ -30,7 +32,7 @@ jobs:
3032
run: make install-test
3133

3234
- name: Run tests
33-
run: |
35+
run: |
3436
export GLOCI_REGISTRY_TOKEN="invalid"
3537
make test-coverage-ci
3638

0 commit comments

Comments
 (0)