Skip to content

Commit a8b0dbb

Browse files
authored
Merge pull request #141 from sarakthon/python-compatibility
CFE-4657: Set up GH Action which tests old python in cfengine/modules
2 parents ea97a70 + 72e3528 commit a8b0dbb

2 files changed

Lines changed: 56 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: "Set up legacy Python"
2+
description: "Sets up a specified Python version in a virtual environment using `pyenv`, installs dependencies, and caches the environment"
3+
inputs:
4+
python-version:
5+
required: true
6+
description: "The Python version to set up"
7+
8+
runs:
9+
using: "composite"
10+
steps:
11+
- uses: actions/cache@v4
12+
id: pyenv-cache
13+
with:
14+
path: |
15+
/opt/hostedtoolcache/pyenv_root/2.4.20/x64/versions/${{ inputs.python-version }}
16+
key: ${{ inputs.python-version }}-${{ hashFiles('requirements.txt') }}
17+
- name: Set up Python ${{ inputs.python-version }} using pyenv
18+
uses: gabrielfalcao/pyenv-action@32ef4d2c861170ce17ded56d10329d83f4c8f797
19+
if: steps.pyenv-cache.outputs.cache-hit != 'true'
20+
with:
21+
default: "${{ inputs.python-version }}"
22+
command: pip install -U pip
23+
- name: Add Python ${{ inputs.python-version }} to PATH
24+
run: echo "/opt/hostedtoolcache/pyenv_root/2.4.20/x64/versions/${{ inputs.python-version }}/bin" >> $GITHUB_PATH
25+
shell: bash
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install flake8 pytest setuptools wheel
29+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
30+
shell: bash

.github/workflows/python-tests.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Python tests
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
jobs:
10+
test-legacy:
11+
runs-on: ubuntu-24.04
12+
permissions:
13+
contents: read
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
python-version: ["3.5.10", "3.6.15", "3.7.10", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Set up legacy Python ${{ matrix.python-version }}
22+
uses: ./.github/actions/set-up-legacy-python
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
- name: Test cfengine_module_library is importable
26+
run: python -c "import sys; sys.path.insert(0, 'libraries/python'); import cfengine_module_library; print('OK', sys.version)"

0 commit comments

Comments
 (0)