Skip to content

Commit 4f60d01

Browse files
committed
CI: Enable GitHub Actions testing workflow
This replicate the existing Azure DevOps workflow, and adds a couple of new jobs (Python 2.7 on macOS, Python + vanilla Ansible on Linux). The GitHub Actions use container images hosted on GitHub Container Registry (GHCR, ghcr.io/mitogen-hq). These images have been copied straight from the existing Amazon Elastic Cloud Registry (AWS ECR, public.ecr.aws/n5z0e8q9). A short period of parallel running is planned. Then a second PR will remove the Azure DevOps workflow.
1 parent 2721451 commit 4f60d01

File tree

2 files changed

+327
-0
lines changed

2 files changed

+327
-0
lines changed

.github/workflows/tests.yml

Lines changed: 326 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,326 @@
1+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
2+
3+
name: Tests
4+
5+
on:
6+
pull_request:
7+
push:
8+
branches-ignore:
9+
- docs-master
10+
11+
env:
12+
#ANSIBLE_VERBOSITY: 3
13+
#MITOGEN_LOG_LEVEL: DEBUG
14+
MITOGEN_TEST_IMAGE_TEMPLATE: "ghcr.io/mitogen-hq/%(distro)s-test"
15+
16+
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners
17+
# https://github.com/actions/runner-images/blob/main/README.md#software-and-image-support
18+
jobs:
19+
linux:
20+
# https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2004-Readme.md
21+
runs-on: ubuntu-20.04
22+
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
include:
27+
- name: Ans_27_210
28+
tox_env: py27-mode_ansible-ansible2.10
29+
- name: Ans_27_4
30+
tox_env: py27-mode_ansible-ansible4
31+
32+
- name: Ans_36_210
33+
python_version: '3.6'
34+
tox_env: py36-mode_ansible-ansible2.10
35+
- name: Ans_36_4
36+
python_version: '3.6'
37+
tox_env: py36-mode_ansible-ansible4
38+
39+
- name: Ans_311_210
40+
python_version: '3.11'
41+
tox_env: py311-mode_ansible-ansible2.10
42+
- name: Ans_311_3
43+
python_version: '3.11'
44+
tox_env: py311-mode_ansible-ansible3
45+
- name: Ans_311_4
46+
python_version: '3.11'
47+
tox_env: py311-mode_ansible-ansible4
48+
- name: Ans_311_5
49+
python_version: '3.11'
50+
tox_env: py311-mode_ansible-ansible5
51+
- name: Ans_312_6
52+
python_version: '3.12'
53+
tox_env: py312-mode_ansible-ansible6
54+
- name: Ans_312_7
55+
python_version: '3.12'
56+
tox_env: py312-mode_ansible-ansible7
57+
- name: Ans_312_8
58+
python_version: '3.12'
59+
tox_env: py312-mode_ansible-ansible8
60+
- name: Ans_312_9
61+
python_version: '3.12'
62+
tox_env: py312-mode_ansible-ansible9
63+
- name: Ans_312_10
64+
python_version: '3.12'
65+
tox_env: py312-mode_ansible-ansible10
66+
- name: Van_312_10
67+
python_version: '3.12'
68+
tox_env: py312-mode_ansible-ansible10-strategy_linear
69+
70+
- name: Mito_27_centos6
71+
tox_env: py27-mode_mitogen-distro_centos6
72+
- name: Mito_27_centos7
73+
tox_env: py27-mode_mitogen-distro_centos7
74+
- name: Mito_27_centos8
75+
tox_env: py27-mode_mitogen-distro_centos8
76+
- name: Mito_27_debian9
77+
tox_env: py27-mode_mitogen-distro_debian9
78+
- name: Mito_27_debian10
79+
tox_env: py27-mode_mitogen-distro_debian10
80+
- name: Mito_27_debian11
81+
tox_env: py27-mode_mitogen-distro_debian11
82+
- name: Mito_27_ubuntu1604
83+
tox_env: py27-mode_mitogen-distro_ubuntu1604
84+
- name: Mito_27_ubuntu1804
85+
tox_env: py27-mode_mitogen-distro_ubuntu1804
86+
- name: Mito_27_ubuntu2004
87+
tox_env: py27-mode_mitogen-distro_ubuntu2004
88+
89+
- name: Mito_36_centos6
90+
python_version: '3.6'
91+
tox_env: py36-mode_mitogen-distro_centos6
92+
- name: Mito_36_centos7
93+
python_version: '3.6'
94+
tox_env: py36-mode_mitogen-distro_centos7
95+
- name: Mito_36_centos8
96+
python_version: '3.6'
97+
tox_env: py36-mode_mitogen-distro_centos8
98+
- name: Mito_36_debian9
99+
python_version: '3.6'
100+
tox_env: py36-mode_mitogen-distro_debian9
101+
- name: Mito_36_debian10
102+
python_version: '3.6'
103+
tox_env: py36-mode_mitogen-distro_debian10
104+
- name: Mito_36_debian11
105+
python_version: '3.6'
106+
tox_env: py36-mode_mitogen-distro_debian11
107+
- name: Mito_36_ubuntu1604
108+
python_version: '3.6'
109+
tox_env: py36-mode_mitogen-distro_ubuntu1604
110+
- name: Mito_36_ubuntu1804
111+
python_version: '3.6'
112+
tox_env: py36-mode_mitogen-distro_ubuntu1804
113+
- name: Mito_36_ubuntu2004
114+
python_version: '3.6'
115+
tox_env: py36-mode_mitogen-distro_ubuntu2004
116+
117+
- name: Mito_312_centos6
118+
python_version: '3.12'
119+
tox_env: py312-mode_mitogen-distro_centos6
120+
- name: Mito_312_centos7
121+
python_version: '3.12'
122+
tox_env: py312-mode_mitogen-distro_centos7
123+
- name: Mito_312_centos8
124+
python_version: '3.12'
125+
tox_env: py312-mode_mitogen-distro_centos8
126+
- name: Mito_312_debian9
127+
python_version: '3.12'
128+
tox_env: py312-mode_mitogen-distro_debian9
129+
- name: Mito_312_debian10
130+
python_version: '3.12'
131+
tox_env: py312-mode_mitogen-distro_debian10
132+
- name: Mito_312_debian11
133+
python_version: '3.12'
134+
tox_env: py312-mode_mitogen-distro_debian11
135+
- name: Mito_312_ubuntu1604
136+
python_version: '3.12'
137+
tox_env: py312-mode_mitogen-distro_ubuntu1604
138+
- name: Mito_312_ubuntu1804
139+
python_version: '3.12'
140+
tox_env: py312-mode_mitogen-distro_ubuntu1804
141+
- name: Mito_312_ubuntu2004
142+
python_version: '3.12'
143+
tox_env: py312-mode_mitogen-distro_ubuntu2004
144+
145+
steps:
146+
- uses: actions/checkout@v4
147+
- uses: actions/setup-python@v5
148+
with:
149+
python-version: ${{ matrix.python_version }}
150+
if: ${{ matrix.python_version }}
151+
- uses: docker/login-action@v3
152+
with:
153+
registry: ghcr.io
154+
username: ${{ github.actor }}
155+
password: ${{ secrets.GITHUB_TOKEN }}
156+
- name: Install build deps
157+
run: |
158+
set -o errexit -o nounset -o pipefail
159+
160+
sudo apt-get update
161+
sudo apt-get install -y python2-dev python3-pip virtualenv
162+
- name: Show Python versions
163+
run: |
164+
set -o errexit -o nounset -o pipefail
165+
166+
# macOS builders lack a realpath command
167+
type python && python -c"import os.path;print(os.path.realpath('$(type -p python)'))" && python --version
168+
type python2 && python2 -c"import os.path;print(os.path.realpath('$(type -p python2)'))" && python2 --version
169+
type python3 && python3 -c"import os.path;print(os.path.realpath('$(type -p python3)'))" && python3 --version
170+
echo
171+
172+
if [ -e /usr/bin/python ]; then
173+
echo "/usr/bin/python: sys.executable: $(/usr/bin/python -c 'import sys; print(sys.executable)')"
174+
fi
175+
176+
if [ -e /usr/bin/python2 ]; then
177+
echo "/usr/bin/python2: sys.executable: $(/usr/bin/python2 -c 'import sys; print(sys.executable)')"
178+
fi
179+
180+
if [ -e /usr/bin/python2.7 ]; then
181+
echo "/usr/bin/python2.7: sys.executable: $(/usr/bin/python2.7 -c 'import sys; print(sys.executable)')"
182+
fi
183+
- name: Install tooling
184+
run: |
185+
set -o errexit -o nounset -o pipefail
186+
187+
# Tox environment name (e.g. py312-mode_mitogen) -> Python executable name (e.g. python3.12)
188+
PYTHON=$(python -c 'import re; print(re.sub(r"^py([23])([0-9]{1,2}).*", r"python\1.\2", "${{ matrix.tox_env }}"))')
189+
190+
if [[ -z $PYTHON ]]; then
191+
echo 1>&2 "Python interpreter could not be determined"
192+
exit 1
193+
fi
194+
195+
if [[ $PYTHON == "python2.7" && $(uname) == "Darwin" ]]; then
196+
"$PYTHON" -m ensurepip --user --altinstall --no-default-pip
197+
"$PYTHON" -m pip install --user -r "tests/requirements-tox.txt"
198+
elif [[ $PYTHON == "python2.7" ]]; then
199+
curl "https://bootstrap.pypa.io/pip/2.7/get-pip.py" --output "get-pip.py"
200+
"$PYTHON" get-pip.py --user --no-python-version-warning
201+
# Avoid Python 2.x pip masking system pip
202+
rm -f ~/.local/bin/{easy_install,pip,wheel}
203+
"$PYTHON" -m pip install --user -r "tests/requirements-tox.txt"
204+
else
205+
"$PYTHON" -m pip install -r "tests/requirements-tox.txt"
206+
fi
207+
- name: Run tests
208+
env:
209+
GITHUB_ACTOR: ${{ github.actor }}
210+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
211+
run: |
212+
set -o errexit -o nounset -o pipefail
213+
214+
# Tox environment name (e.g. py312-mode_mitogen) -> Python executable name (e.g. python3.12)
215+
PYTHON=$(python -c 'import re; print(re.sub(r"^py([23])([0-9]{1,2}).*", r"python\1.\2", "${{ matrix.tox_env }}"))')
216+
217+
if [[ -z $PYTHON ]]; then
218+
echo 1>&2 "Python interpreter could not be determined"
219+
exit 1
220+
fi
221+
222+
"$PYTHON" -m tox -e "${{ matrix.tox_env }}"
223+
224+
macos:
225+
# https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md
226+
runs-on: macos-12
227+
timeout-minutes: 120
228+
229+
strategy:
230+
fail-fast: false
231+
matrix:
232+
include:
233+
- name: Mito_27
234+
tox_env: py27-mode_mitogen
235+
- name: Mito_312
236+
tox_env: py312-mode_mitogen
237+
238+
- name: Loc_27_210
239+
tox_env: py27-mode_localhost-ansible2.10
240+
- name: Loc_312_10
241+
tox_env: py312-mode_localhost-ansible10
242+
243+
- name: Van_27_210
244+
tox_env: py27-mode_localhost-ansible2.10-strategy_linear
245+
- name: Van_312_10
246+
tox_env: py312-mode_localhost-ansible10-strategy_linear
247+
248+
steps:
249+
- uses: actions/checkout@v4
250+
- uses: actions/setup-python@v5
251+
with:
252+
python-version: ${{ matrix.python_version }}
253+
if: ${{ matrix.python_version }}
254+
- name: Show Python versions
255+
run: |
256+
set -o errexit -o nounset -o pipefail
257+
258+
# macOS builders lack a realpath command
259+
type python && python -c"import os.path;print(os.path.realpath('$(type -p python)'))" && python --version
260+
type python2 && python2 -c"import os.path;print(os.path.realpath('$(type -p python2)'))" && python2 --version
261+
type python3 && python3 -c"import os.path;print(os.path.realpath('$(type -p python3)'))" && python3 --version
262+
echo
263+
264+
if [ -e /usr/bin/python ]; then
265+
echo "/usr/bin/python: sys.executable: $(/usr/bin/python -c 'import sys; print(sys.executable)')"
266+
fi
267+
268+
if [ -e /usr/bin/python2 ]; then
269+
echo "/usr/bin/python2: sys.executable: $(/usr/bin/python2 -c 'import sys; print(sys.executable)')"
270+
fi
271+
272+
if [ -e /usr/bin/python2.7 ]; then
273+
echo "/usr/bin/python2.7: sys.executable: $(/usr/bin/python2.7 -c 'import sys; print(sys.executable)')"
274+
fi
275+
276+
if [ -e /Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 ]; then
277+
# GitHub macOS 12 images: python2.7 is installed, but not on $PATH
278+
echo "/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7: sys.executable: $(/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 -c 'import sys; print(sys.executable)')"
279+
fi
280+
- name: Install tooling
281+
run: |
282+
set -o errexit -o nounset -o pipefail
283+
284+
# Tox environment name (e.g. py312-mode_mitogen) -> Python executable name (e.g. python3.12)
285+
PYTHON=$(python -c 'import re; print(re.sub(r"^py([23])([0-9]{1,2}).*", r"python\1.\2", "${{ matrix.tox_env }}"))')
286+
287+
if [[ -z $PYTHON ]]; then
288+
echo 1>&2 "Python interpreter could not be determined"
289+
exit 1
290+
fi
291+
292+
if [[ $PYTHON == "python2.7" && $(uname) == "Darwin" ]]; then
293+
# GitHub macOS 12 images: python2.7 is installed, but not on $PATH
294+
PYTHON="/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7"
295+
"$PYTHON" -m ensurepip --user --altinstall --no-default-pip
296+
"$PYTHON" -m pip install --user -r "tests/requirements-tox.txt"
297+
elif [[ $PYTHON == "python2.7" ]]; then
298+
curl "https://bootstrap.pypa.io/pip/2.7/get-pip.py" --output "get-pip.py"
299+
"$PYTHON" get-pip.py --user --no-python-version-warning
300+
# Avoid Python 2.x pip masking system pip
301+
rm -f ~/.local/bin/{easy_install,pip,wheel}
302+
"$PYTHON" -m pip install --user -r "tests/requirements-tox.txt"
303+
else
304+
"$PYTHON" -m pip install -r "tests/requirements-tox.txt"
305+
fi
306+
- name: Run tests
307+
env:
308+
GITHUB_ACTOR: ${{ github.actor }}
309+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
310+
run: |
311+
set -o errexit -o nounset -o pipefail
312+
313+
# Tox environment name (e.g. py312-mode_mitogen) -> Python executable name (e.g. python3.12)
314+
PYTHON=$(python -c 'import re; print(re.sub(r"^py([23])([0-9]{1,2}).*", r"python\1.\2", "${{ matrix.tox_env }}"))')
315+
316+
if [[ -z $PYTHON ]]; then
317+
echo 1>&2 "Python interpreter could not be determined"
318+
exit 1
319+
fi
320+
321+
if [[ $PYTHON == "python2.7" && $(uname) == "Darwin" ]]; then
322+
# GitHub macOS 12 images: python2.7 is installed, but not on $PATH
323+
PYTHON="/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7"
324+
fi
325+
326+
"$PYTHON" -m tox -e "${{ matrix.tox_env }}"

docs/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Unreleased
2929
releases before 2.10
3030
* :gh:issue:`1127` :mod:`ansible_mitogen`: Consolidate Python 2 & 3
3131
compatibility
32+
* :gh:issue:`1128` CI: Start migration from Azure DevOps to GitHub Actions
3233

3334

3435
v0.3.10 (2024-09-20)

0 commit comments

Comments
 (0)