Skip to content

Commit 57391bf

Browse files
committed
Improve Python version handling and fix poetry installation
Signed-off-by: Tobias Wolf <[email protected]>
1 parent 18e1814 commit 57391bf

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-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: Set up Python ${{ inputs.python_version }}
4042
uses: actions/setup-python@v5
4143
with:
42-
python-version: "3.13"
43-
cache: ${{ steps.env-check.outputs.cache_type }}
44+
python-version: ${{ inputs.python_version }}
45+
cache: ${{ steps.env-check.outputs.package_tool }}
46+
47+
- name: Install Poetry
48+
if: steps.env-check.outputs.package_tool == 'poetry'
49+
uses: snok/install-poetry@v1
4450

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

.github/workflows/pytests.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,14 @@ jobs:
2020
- name: Setup Gardenlinux
2121
uses: ./.github/actions/setup
2222

23-
- name: Install Poetry
24-
uses: snok/install-poetry@v1
25-
2623
- name: Install dependencies
2724
run: poetry install --with dev
2825

2926
- name: Prepare environment
3027
run: make install-test
3128

3229
- name: Run tests
33-
run: |
30+
run: |
3431
export GLOCI_REGISTRY_TOKEN="invalid"
3532
make test-coverage-ci
3633

0 commit comments

Comments
 (0)