mirror of
https://github.com/linux-system-roles/network.git
synced 2026-01-23 18:35:13 +00:00
This is fixed by tox-lsr 3.2.2 - all actions that use tox-lsr are updated to 3.2.2, not just the python unit tests, even though the fix is only related to pytest. All roles are updated to use tox-lsr 3.2.2 for the sake of consistency even if not affected by the pytest issue. Something changed recently in the way github actions provisions systems which means some of the directories are not readable by the python unit test actions. In addition, the python unit tests were causing a lot of unnecessary directory traversal doing collection/discovery of unit test files, because of using `pytest -c /path/to/tox-lsr/pytest.ini` Unfortunately, with `pytest`, the directory of the config file is the root directory for the tests and tests discovery, and there is no way around this. Therefore, the only solution is to copy the tox-lsr `pytest.ini` to the `tests/unit` directory, which makes that the test root directory. See also https://github.com/linux-system-roles/tox-lsr/pull/160 Signed-off-by: Rich Megginson <rmeggins@redhat.com>
97 lines
2.8 KiB
YAML
97 lines
2.8 KiB
YAML
---
|
|
# yamllint disable rule:line-length
|
|
name: Python Unit Tests
|
|
on: # yamllint disable-line rule:truthy
|
|
pull_request:
|
|
merge_group:
|
|
branches:
|
|
- main
|
|
types:
|
|
- checks_requested
|
|
push:
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
permissions:
|
|
contents: read
|
|
jobs:
|
|
python:
|
|
strategy:
|
|
matrix:
|
|
pyver_os:
|
|
- ver: "2.7"
|
|
os: ubuntu-20.04
|
|
- ver: "3.6"
|
|
os: ubuntu-20.04
|
|
- ver: "3.8"
|
|
os: ubuntu-latest
|
|
- ver: "3.9"
|
|
os: ubuntu-latest
|
|
- ver: "3.10"
|
|
os: ubuntu-latest
|
|
- ver: "3.11"
|
|
os: ubuntu-latest
|
|
runs-on: ${{ matrix.pyver_os.os }}
|
|
steps:
|
|
- name: Update git
|
|
run: |
|
|
set -euxo pipefail
|
|
sudo apt update
|
|
sudo apt install -y git
|
|
|
|
- name: checkout PR
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Python 2.7
|
|
if: ${{ matrix.pyver_os.ver == '2.7' }}
|
|
run: |
|
|
set -euxo pipefail
|
|
sudo apt install -y python2.7
|
|
|
|
- name: Set up Python 3
|
|
if: ${{ matrix.pyver_os.ver != '2.7' }}
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: ${{ matrix.pyver_os.ver }}
|
|
|
|
- name: Install platform dependencies, python, tox, tox-lsr
|
|
run: |
|
|
set -euxo pipefail
|
|
python -m pip install --upgrade pip
|
|
pip install "git+https://github.com/linux-system-roles/tox-lsr@3.2.2"
|
|
# If you have additional OS dependency packages e.g. libcairo2-dev
|
|
# then put them in .github/config/ubuntu-requirements.txt, one
|
|
# package per line.
|
|
if [ -f .github/config/ubuntu-requirements.txt ]; then
|
|
sudo apt-get install -y $(cat .github/config/ubuntu-requirements.txt)
|
|
fi
|
|
|
|
- name: Run unit tests
|
|
run: |
|
|
set -euxo pipefail
|
|
toxpyver=$(echo "${{ matrix.pyver_os.ver }}" | tr -d .)
|
|
toxenvs="py${toxpyver}"
|
|
# NOTE: The use of flake8, pylint, black with specific
|
|
# python envs is arbitrary and must be changed in tox-lsr
|
|
# We really should either do those checks using the latest
|
|
# version of python, or in every version of python
|
|
case "$toxpyver" in
|
|
27) toxenvs="${toxenvs},coveralls,flake8,pylint" ;;
|
|
36) toxenvs="${toxenvs},coveralls,black" ;;
|
|
*) toxenvs="${toxenvs},coveralls" ;;
|
|
esac
|
|
TOXENV="$toxenvs" lsr_ci_runtox
|
|
|
|
- name: Upload coverage reports to Codecov
|
|
uses: codecov/codecov-action@v4
|
|
|
|
python-26:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: checkout PR
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Run py26 tests
|
|
uses: linux-system-roles/lsr-gh-action-py26@1.0.2
|
|
env:
|
|
TOX_LSR: "git+https://github.com/linux-system-roles/tox-lsr@2.13.2"
|