@@ -29,13 +29,10 @@ jobs:
2929 - tox_env : py27-m_ans-ans4
3030
3131 - tox_env : py36-m_ans-ans2.10
32- python_version : ' 3.6'
3332 - tox_env : py36-m_ans-ans4
34- python_version : ' 3.6'
3533
3634 - tox_env : py27-m_mtg
3735 - tox_env : py36-m_mtg
38- python_version : ' 3.6'
3936
4037 steps :
4138 - uses : actions/checkout@v4
@@ -44,90 +41,38 @@ jobs:
4441 registry : ghcr.io
4542 username : ${{ github.actor }}
4643 password : ${{ secrets.GITHUB_TOKEN }}
47- - name : Install build deps
44+ - run : .ci/show_python_versions
45+ - name : Install deps
46+ id : install-deps
4847 run : |
4948 set -o errexit -o nounset -o pipefail
50-
51- PYTHON=$(python -c 'import re; print(re.sub(r"^py([23])([0-9]{1,2}).*", r"python\1.\2", "${{ matrix.tox_env }}"))')
52-
53- if [[ -z $PYTHON ]]; then
54- echo 1>&2 "Python interpreter could not be determined"
55- exit 1
56- fi
49+ source .ci/bash_functions
50+ PYTHON="$(toxenv-python '${{ matrix.tox_env }}')"
5751
5852 sudo apt-get update
5953
6054 if [[ $PYTHON == "python2.7" ]]; then
6155 sudo apt install -y python2-dev sshpass virtualenv
62- elif [[ $PYTHON == "python3.6" ]]; then
63- sudo apt install -y gcc-10 make libbz2-dev liblzma-dev libreadline-dev libsqlite3-dev libssl-dev sshpass virtualenv zlib1g-dev
64- curl --fail --silent --show-error --location https://pyenv.run | bash
65- CC=gcc-10 ~/.pyenv/bin/pyenv install --force 3.6
66- else
67- echo 1>&2 "Python interpreter $PYTHON not available"
68- exit 1
69- fi
70- - name : Show Python versions
71- run : |
72- set -o errexit -o nounset -o pipefail
73-
74- # macOS builders lack a realpath command
75- type python && python -c"import os.path;print(os.path.realpath('$(type -p python)'))" && python --version
76- type python2 && python2 -c"import os.path;print(os.path.realpath('$(type -p python2)'))" && python2 --version
77- type python3 && python3 -c"import os.path;print(os.path.realpath('$(type -p python3)'))" && python3 --version
78- echo
79-
80- if [ -e /usr/bin/python ]; then
81- echo "/usr/bin/python: sys.executable: $(/usr/bin/python -c 'import sys; print(sys.executable)')"
82- fi
83-
84- if [ -e /usr/bin/python2 ]; then
85- echo "/usr/bin/python2: sys.executable: $(/usr/bin/python2 -c 'import sys; print(sys.executable)')"
86- fi
87-
88- if [ -e /usr/bin/python2.7 ]; then
89- echo "/usr/bin/python2.7: sys.executable: $(/usr/bin/python2.7 -c 'import sys; print(sys.executable)')"
90- fi
91- - name : Install tooling
92- run : |
93- set -o errexit -o nounset -o pipefail
94-
95- # Tox environment name (e.g. py312-m_mtg) -> Python executable name (e.g. python3.12)
96- PYTHON=$(python -c 'import re; print(re.sub(r"^py([23])([0-9]{1,2}).*", r"python\1.\2", "${{ matrix.tox_env }}"))')
97-
98- if [[ -z $PYTHON ]]; then
99- echo 1>&2 "Python interpreter could not be determined"
100- exit 1
101- fi
102-
103- if [[ $PYTHON == "python2.7" ]]; then
10456 curl "https://bootstrap.pypa.io/pip/2.7/get-pip.py" --output "get-pip.py"
10557 "$PYTHON" get-pip.py --user --no-python-version-warning
10658 # Avoid Python 2.x pip masking system pip
10759 rm -f ~/.local/bin/{easy_install,pip,wheel}
10860 elif [[ $PYTHON == "python3.6" ]]; then
61+ sudo apt install -y gcc-10 make libbz2-dev liblzma-dev libreadline-dev libsqlite3-dev libssl-dev sshpass virtualenv zlib1g-dev
62+ curl --fail --silent --show-error --location https://pyenv.run | bash
63+ CC=gcc-10 ~/.pyenv/bin/pyenv install --force 3.6
10964 PYTHON="$HOME/.pyenv/versions/3.6.15/bin/python3.6"
11065 fi
11166
11267 "$PYTHON" -m pip install -r "tests/requirements-tox.txt"
68+ echo "python=$PYTHON" >> $GITHUB_OUTPUT
11369 - name : Run tests
11470 env :
11571 GITHUB_ACTOR : ${{ github.actor }}
11672 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
11773 run : |
11874 set -o errexit -o nounset -o pipefail
119-
120- # Tox environment name (e.g. py312-m_mtg) -> Python executable name (e.g. python3.12)
121- PYTHON=$(python -c 'import re; print(re.sub(r"^py([23])([0-9]{1,2}).*", r"python\1.\2", "${{ matrix.tox_env }}"))')
122-
123- if [[ -z $PYTHON ]]; then
124- echo 1>&2 "Python interpreter could not be determined"
125- exit 1
126- fi
127-
128- if [[ $PYTHON == "python3.6" ]]; then
129- PYTHON="$HOME/.pyenv/versions/3.6.15/bin/python3.6"
130- fi
75+ PYTHON="${{ steps.install-deps.outputs.python }}"
13176
13277 "$PYTHON" -m tox -e "${{ matrix.tox_env }}"
13378
@@ -183,60 +128,26 @@ jobs:
183128 registry : ghcr.io
184129 username : ${{ github.actor }}
185130 password : ${{ secrets.GITHUB_TOKEN }}
186- - name : Install build deps
131+ - run : .ci/show_python_versions
132+ - name : Install deps
133+ id : install-deps
187134 run : |
188135 set -o errexit -o nounset -o pipefail
136+ source .ci/bash_functions
137+ PYTHON="$(toxenv-python '${{ matrix.tox_env }}')"
189138
190139 sudo apt-get update
191140 sudo apt-get install -y sshpass virtualenv
192- - name : Show Python versions
193- run : |
194- set -o errexit -o nounset -o pipefail
195-
196- # macOS builders lack a realpath command
197- type python && python -c"import os.path;print(os.path.realpath('$(type -p python)'))" && python --version
198- type python2 && python2 -c"import os.path;print(os.path.realpath('$(type -p python2)'))" && python2 --version
199- type python3 && python3 -c"import os.path;print(os.path.realpath('$(type -p python3)'))" && python3 --version
200- echo
201-
202- if [ -e /usr/bin/python ]; then
203- echo "/usr/bin/python: sys.executable: $(/usr/bin/python -c 'import sys; print(sys.executable)')"
204- fi
205-
206- if [ -e /usr/bin/python2 ]; then
207- echo "/usr/bin/python2: sys.executable: $(/usr/bin/python2 -c 'import sys; print(sys.executable)')"
208- fi
209-
210- if [ -e /usr/bin/python2.7 ]; then
211- echo "/usr/bin/python2.7: sys.executable: $(/usr/bin/python2.7 -c 'import sys; print(sys.executable)')"
212- fi
213- - name : Install tooling
214- run : |
215- set -o errexit -o nounset -o pipefail
216-
217- # Tox environment name (e.g. py312-m_mtg) -> Python executable name (e.g. python3.12)
218- PYTHON=$(python -c 'import re; print(re.sub(r"^py([23])([0-9]{1,2}).*", r"python\1.\2", "${{ matrix.tox_env }}"))')
219-
220- if [[ -z $PYTHON ]]; then
221- echo 1>&2 "Python interpreter could not be determined"
222- exit 1
223- fi
224141
225142 "$PYTHON" -m pip install -r "tests/requirements-tox.txt"
143+ echo "python=$PYTHON" >> $GITHUB_OUTPUT
226144 - name : Run tests
227145 env :
228146 GITHUB_ACTOR : ${{ github.actor }}
229147 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
230148 run : |
231149 set -o errexit -o nounset -o pipefail
232-
233- # Tox environment name (e.g. py312-m_mtg) -> Python executable name (e.g. python3.12)
234- PYTHON=$(python -c 'import re; print(re.sub(r"^py([23])([0-9]{1,2}).*", r"python\1.\2", "${{ matrix.tox_env }}"))')
235-
236- if [[ -z $PYTHON ]]; then
237- echo 1>&2 "Python interpreter could not be determined"
238- exit 1
239- fi
150+ PYTHON="${{ steps.install-deps.outputs.python }}"
240151
241152 "$PYTHON" -m tox -e "${{ matrix.tox_env }}"
242153
@@ -265,61 +176,25 @@ jobs:
265176 with :
266177 python-version : ${{ matrix.python_version }}
267178 if : ${{ matrix.python_version }}
268- - name : Show Python versions
269- run : |
270- set -o errexit -o nounset -o pipefail
271-
272- # macOS builders lack a realpath command
273- type python && python -c"import os.path;print(os.path.realpath('$(type -p python)'))" && python --version
274- type python2 && python2 -c"import os.path;print(os.path.realpath('$(type -p python2)'))" && python2 --version
275- type python3 && python3 -c"import os.path;print(os.path.realpath('$(type -p python3)'))" && python3 --version
276- echo
277-
278- if [ -e /usr/bin/python ]; then
279- echo "/usr/bin/python: sys.executable: $(/usr/bin/python -c 'import sys; print(sys.executable)')"
280- fi
281-
282- if [ -e /usr/bin/python2 ]; then
283- echo "/usr/bin/python2: sys.executable: $(/usr/bin/python2 -c 'import sys; print(sys.executable)')"
284- fi
285-
286- if [ -e /usr/bin/python2.7 ]; then
287- echo "/usr/bin/python2.7: sys.executable: $(/usr/bin/python2.7 -c 'import sys; print(sys.executable)')"
288- fi
289-
290- if [ -e /Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 ]; then
291- # GitHub macOS 12 images: python2.7 is installed, but not on $PATH
292- 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)')"
293- fi
179+ - run : .ci/show_python_versions
294180 - run : .ci/install_sshpass ${{ matrix.sshpass_version }}
295181 if : ${{ matrix.sshpass_version }}
296- - name : Install tooling
182+ - name : Install deps
183+ id : install-deps
297184 run : |
298185 set -o errexit -o nounset -o pipefail
299-
300- # Tox environment name (e.g. py312-m_mtg) -> Python executable name (e.g. python3.12)
301- PYTHON=$(python -c 'import re; print(re.sub(r"^py([23])([0-9]{1,2}).*", r"python\1.\2", "${{ matrix.tox_env }}"))')
302-
303- if [[ -z $PYTHON ]]; then
304- echo 1>&2 "Python interpreter could not be determined"
305- exit 1
306- fi
186+ source .ci/bash_functions
187+ PYTHON="$(toxenv-python '${{ matrix.tox_env }}')"
307188
308189 "$PYTHON" -m pip install -r "tests/requirements-tox.txt"
190+ echo "python=$PYTHON" >> $GITHUB_OUTPUT
309191 - name : Run tests
310192 env :
311193 GITHUB_ACTOR : ${{ github.actor }}
312194 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
313195 run : |
314196 set -o errexit -o nounset -o pipefail
315-
316- # Tox environment name (e.g. py312-m_mtg) -> Python executable name (e.g. python3.12)
317- PYTHON=$(python -c 'import re; print(re.sub(r"^py([23])([0-9]{1,2}).*", r"python\1.\2", "${{ matrix.tox_env }}"))')
318-
319- if [[ -z $PYTHON ]]; then
320- echo 1>&2 "Python interpreter could not be determined"
321- exit 1
322- fi
197+ PYTHON="${{ steps.install-deps.outputs.python }}"
323198
324199 "$PYTHON" -m tox -e "${{ matrix.tox_env }}"
325200
0 commit comments