Skip to content

Commit 3cfe5b5

Browse files
authored
Merge pull request #128 from jakub-nt/ubuntu-bump
Bump runner Ubuntu version, while handling legacy Python versions
2 parents 0e6e020 + fa18b9d commit 3cfe5b5

File tree

5 files changed

+195
-132
lines changed

5 files changed

+195
-132
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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: Install dependencies
24+
run: |
25+
python -m pip install flake8 pytest setuptools wheel
26+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
27+
shell: bash

.github/workflows/black-format.yml

+59-59
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,67 @@
11
name: Automatically format with Black and submit PR
22

33
on:
4-
push:
5-
branches:
6-
- master
4+
push:
5+
branches:
6+
- master
77

8-
workflow_dispatch:
8+
workflow_dispatch:
99

1010
jobs:
1111
format:
12-
runs-on: ubuntu-20.04
12+
runs-on: ubuntu-24.04
1313
steps:
14-
- name: Checks-out repository
15-
uses: actions/checkout@v4
16-
- name: Set up Python 3.12
17-
uses: actions/setup-python@v5
18-
with:
19-
python-version: "3.12"
20-
- name: Install black
21-
run: |
22-
python -m pip install --upgrade pip
23-
python -m pip install black
24-
- name: Reformat with black
25-
run: |
26-
shopt -s globstar
27-
black cf_remote/*.py cf_remote/**/*.py tests/*.py tests/**/*.py > black_output.txt 2>&1
28-
- name: Check if there are changes
29-
run: |
30-
git diff --exit-code || touch git_diff_exists
31-
if [ -f git_diff_exists ]; then echo "Changes need to be commited"; else echo "No changes to commit"; fi
32-
- name: Create commit message
33-
if: hashFiles('git_diff_exists') != ''
34-
run: |
35-
echo "Reformatted python code using Black formatter" >> commit_message.txt
36-
echo "" >> commit_message.txt
37-
echo "Output from black:" >> commit_message.txt
38-
echo "" >> commit_message.txt
39-
echo '```' >> commit_message.txt
40-
cat black_output.txt >> commit_message.txt
41-
echo '```' >> commit_message.txt
42-
- name: Commit changes
43-
if: hashFiles('git_diff_exists') != ''
44-
run: |
45-
git config user.name 'GitHub'
46-
git config user.email '<[email protected]>'
47-
shopt -s globstar
48-
git add cf_remote/*.py cf_remote/**/*.py tests/*.py tests/**/*.py
49-
git commit -F commit_message.txt
50-
- id: commit-message-from-file
51-
name: Parse commit message from file into variable
52-
if: hashFiles('git_diff_exists') != ''
53-
run: |
54-
body=$(cat commit_message.txt)
55-
body="${body//$'\n'/'%0A'}"
56-
echo ::set-output name=body::$body
57-
- name: Create Pull Request
58-
if: hashFiles('git_diff_exists') != ''
59-
uses: cfengine/create-pull-request@v6
60-
with:
61-
title: Reformatted python code using Black formatter
62-
body: ${{ steps.commit-message-from-file.outputs.body }}
63-
reviewers: |
64-
olehermanse
65-
larsewi
66-
vpodzime
67-
branch: formatting-action
14+
- name: Checks-out repository
15+
uses: actions/checkout@v4
16+
- name: Set up Python 3.12
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: "3.12"
20+
- name: Install black
21+
run: |
22+
python -m pip install --upgrade pip
23+
python -m pip install black
24+
- name: Reformat with black
25+
run: |
26+
shopt -s globstar
27+
black cf_remote/*.py cf_remote/**/*.py tests/*.py tests/**/*.py > black_output.txt 2>&1
28+
- name: Check if there are changes
29+
run: |
30+
git diff --exit-code || touch git_diff_exists
31+
if [ -f git_diff_exists ]; then echo "Changes need to be commited"; else echo "No changes to commit"; fi
32+
- name: Create commit message
33+
if: hashFiles('git_diff_exists') != ''
34+
run: |
35+
echo "Reformatted python code using Black formatter" >> commit_message.txt
36+
echo "" >> commit_message.txt
37+
echo "Output from black:" >> commit_message.txt
38+
echo "" >> commit_message.txt
39+
echo '```' >> commit_message.txt
40+
cat black_output.txt >> commit_message.txt
41+
echo '```' >> commit_message.txt
42+
- name: Commit changes
43+
if: hashFiles('git_diff_exists') != ''
44+
run: |
45+
git config user.name 'GitHub'
46+
git config user.email '<[email protected]>'
47+
shopt -s globstar
48+
git add cf_remote/*.py cf_remote/**/*.py tests/*.py tests/**/*.py
49+
git commit -F commit_message.txt
50+
- id: commit-message-from-file
51+
name: Parse commit message from file into variable
52+
if: hashFiles('git_diff_exists') != ''
53+
run: |
54+
body=$(cat commit_message.txt)
55+
body="${body//$'\n'/'%0A'}"
56+
echo ::set-output name=body::$body
57+
- name: Create Pull Request
58+
if: hashFiles('git_diff_exists') != ''
59+
uses: cfengine/create-pull-request@v6
60+
with:
61+
title: Reformatted python code using Black formatter
62+
body: ${{ steps.commit-message-from-file.outputs.body }}
63+
reviewers: |
64+
olehermanse
65+
larsewi
66+
vpodzime
67+
branch: formatting-action

.github/workflows/black.yml

+18-18
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,30 @@ name: Black
55

66
on:
77
push:
8-
branches: [ master ]
8+
branches: [master]
99
pull_request:
10-
branches: [ master ]
10+
branches: [master]
1111

1212
jobs:
1313
check:
14-
runs-on: ubuntu-20.04
14+
runs-on: ubuntu-24.04
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
python-version: [3.12]
18+
python-version: ["3.12"]
1919

2020
steps:
21-
- uses: actions/checkout@v4
22-
- name: Set up Python ${{ matrix.python-version }}
23-
uses: actions/setup-python@v5
24-
with:
25-
python-version: ${{ matrix.python-version }}
26-
- name: Install dependencies
27-
run: |
28-
python -m pip install --upgrade pip
29-
python -m pip install black
30-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
31-
- name: Check formatting with black
32-
run: |
33-
shopt -s globstar
34-
black --check cf_remote/*.py cf_remote/**/*.py tests/*.py tests/**/*.py
21+
- uses: actions/checkout@v4
22+
- name: Set up Python ${{ matrix.python-version }}
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: ${{ matrix.python-version }}
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install --upgrade pip
29+
python -m pip install black
30+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
31+
- name: Check formatting with black
32+
run: |
33+
shopt -s globstar
34+
black --check cf_remote/*.py cf_remote/**/*.py tests/*.py tests/**/*.py

.github/workflows/python-publish.yml

+17-17
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@ jobs:
1313
runs-on: ubuntu-latest
1414

1515
steps:
16-
- uses: actions/checkout@v3
17-
- name: Set up Python
18-
uses: actions/setup-python@v5
19-
with:
20-
python-version: '3.x'
21-
- name: Install dependencies
22-
run: |
23-
python -m pip install --upgrade pip
24-
pip install setuptools wheel twine
25-
- name: Build and publish
26-
env:
27-
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
28-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
29-
run: |
30-
git fetch --all --tags
31-
python setup.py sdist bdist_wheel
32-
twine upload dist/*
16+
- uses: actions/checkout@v4
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: '3.x'
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install setuptools wheel twine
25+
- name: Build and publish
26+
env:
27+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
28+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
29+
run: |
30+
git fetch --all --tags
31+
python setup.py sdist bdist_wheel
32+
twine upload dist/*

.github/workflows/tests.yml

+74-38
Original file line numberDiff line numberDiff line change
@@ -5,52 +5,88 @@ name: Tests
55

66
on:
77
push:
8-
branches: [ master ]
8+
branches: [master]
99
pull_request:
10-
branches: [ master ]
10+
branches: [master]
1111

1212
jobs:
13-
python_version:
14-
runs-on: ubuntu-20.04
13+
test:
14+
runs-on: ubuntu-24.04
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
- name: Set up Python ${{ matrix.python-version }}
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: ${{ matrix.python-version }}
28+
- name: Install dependencies
29+
run: |
30+
python -m pip install --upgrade pip
31+
python -m pip install flake8 pytest setuptools wheel
32+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
33+
- name: Lint with flake8
34+
run: |
35+
# stop the build if there are Python syntax errors or undefined names
36+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
37+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
38+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
39+
- name: Test with pytest
40+
run: |
41+
pytest
42+
- name: Install
43+
run: |
44+
python setup.py sdist bdist_wheel
45+
pip install dist/cf_remote-*.whl
46+
- name: Sanity check
47+
run: cf-remote -V
48+
- name: Run docker test
49+
run: |
50+
bash tests/docker/0*.sh
51+
- name: Run unsafe tests
52+
run: |
53+
bash tests/unsafe/0*.sh
54+
test-legacy:
55+
runs-on: ubuntu-24.04
1556
env:
1657
# Temporary workaround for Python 3.5 failures - May 2024, see CFE-4395
1758
PIP_TRUSTED_HOST: "pypi.python.org pypi.org files.pythonhosted.org"
1859
strategy:
1960
fail-fast: false
2061
matrix:
21-
python-version: [3.5, 3.6, 3.7, 3.8, 3.9]
62+
python-version: ["3.5.10", "3.6.15", "3.7.10"]
2263

2364
steps:
24-
- uses: actions/checkout@v3
25-
with:
26-
fetch-depth: 0
27-
- name: Set up Python ${{ matrix.python-version }}
28-
uses: actions/setup-python@v5
29-
with:
30-
python-version: ${{ matrix.python-version }}
31-
- name: Install dependencies
32-
run: |
33-
python -m pip install --upgrade pip
34-
python -m pip install flake8 pytest setuptools wheel
35-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
36-
- name: Lint with flake8
37-
run: |
38-
# stop the build if there are Python syntax errors or undefined names
39-
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
40-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
41-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
42-
- name: Test with pytest
43-
run: |
44-
pytest
45-
- name: Install
46-
run: |
47-
python setup.py sdist bdist_wheel
48-
pip install dist/cf_remote-*.whl
49-
- name: Sanity check
50-
run: cf-remote -V
51-
- name: Run docker test
52-
run: |
53-
bash tests/docker/0*.sh
54-
- name: Run unsafe tests
55-
run: |
56-
bash tests/unsafe/0*.sh
65+
- uses: actions/checkout@v4
66+
with:
67+
fetch-depth: 0
68+
- name: Set up legacy Python ${{ matrix.python-version }}
69+
uses: ./.github/actions/set-up-legacy-python
70+
with:
71+
python-version: ${{ matrix.python-version }}
72+
- name: Lint with flake8
73+
run: |
74+
# stop the build if there are Python syntax errors or undefined names
75+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
76+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
77+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
78+
- name: Test with pytest
79+
run: |
80+
pytest
81+
- name: Install
82+
run: |
83+
python setup.py sdist bdist_wheel
84+
pip install dist/cf_remote-*.whl
85+
- name: Sanity check
86+
run: cf-remote -V
87+
- name: Run docker test
88+
run: |
89+
bash tests/docker/0*.sh
90+
- name: Run unsafe tests
91+
run: |
92+
bash tests/unsafe/0*.sh

0 commit comments

Comments
 (0)