ci: towards testing non-LTS ubuntu versions

This commit is contained in:
Erik Sundell
2021-10-17 18:36:34 +02:00
parent e1b39cc4d3
commit 2dfe4b8211
3 changed files with 73 additions and 39 deletions

View File

@@ -26,7 +26,16 @@ on:
jobs:
unit-tests:
name: ${{ matrix.name }}
runs-on: ubuntu-${{ matrix.ubuntu_version }}
# runs-on can only be configured to the LTS releases of ubuntu (18.04,
# 20.04, ...), so if we want to test against the latest non-LTS release, we
# must compromise when configuring runs-on and configure runs-on to be the
# latest LTS release instead.
#
# This can have consequences because actions like actions/setup-python will
# mount cached installations associated with the chosen runs-on environment.
#
runs-on: ${{ format('ubuntu-{0}', matrix.runs_on || matrix.ubuntu_version) }}
container: ubuntu:${{ matrix.ubuntu_version }}
strategy:
@@ -34,11 +43,11 @@ jobs:
matrix:
include:
- name: "Unit tests: Ubuntu 18.04, Py 3.6"
ubuntu_version: 18.04
python_version: 3.6
ubuntu_version: "18.04"
python_version: "3.6"
- name: "Unit tests: Ubuntu 20.04, Py 3.9"
ubuntu_version: 20.04
python_version: 3.9
ubuntu_version: "20.04"
python_version: "3.9"
steps:
- uses: actions/checkout@v2
@@ -47,16 +56,31 @@ jobs:
python-version: ${{ matrix.python_version }}
- name: Install venv, git and setup venv
timeout-minutes: 2
run: |
apt-get update --yes && apt-get install --yes python3-venv git
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install --yes \
python3-venv \
git
python3 -m venv /srv/venv
echo '/srv/venv/bin' >> $GITHUB_PATH
- name: Cache pip deps
# WARNING: This action loads a cache of pip dependencies based on the
# declared key, and it will save a cache for that key on job
# completion. Make sure to update the key to bust the cache
# properly if you make a change that should influence it.
- name: Load cached Python dependencies
uses: actions/cache@v2
with:
path: /srv/venv/
key: pip-${{ matrix.ubuntu_version }}-${{ matrix.python_version }}-${{ hashFiles('*setup.py', '*dev-requirements.txt') }}
key: >-
pip-
${{ matrix.runs_on }}-
${{ matrix.ubuntu_version }}-
${{ matrix.python_version }}-
${{ hashFiles('setup.py', 'dev-requirements.txt', '.github/workflows/unit-test.yaml') }}
- name: Install Python dependencies
run: |
@@ -66,9 +90,7 @@ jobs:
pip freeze
- name: Run unit tests
run: |
pytest --verbose --maxfail=2 --color=yes --cov=tljh tests/
run: pytest --verbose --maxfail=2 --color=yes --cov=tljh tests/
- name: Upload code coverage stats
run: |
codecov
run: codecov