mirror of
https://github.com/linux-system-roles/network.git
synced 2026-01-23 02:15:17 +00:00
There are now separate github actions for the various tests, instead of all of them being done as part of the tox tests in tox.yml - ansible-lint, ansible-test, etc. Use the officially supported github actions e.g. for ansible-lint, ansible-test, rather than using our own from `tox-lsr` and trying to keep up with the latest changes. Developers will still be able to use `tox-lsr` on their local development environments to run these tests in the same way that they are run in github actions, so that errors found when submitting PRs can be reproduced and corrected locally without too many github UI roundtrips. Using separate github actions, and especially the official github actions which generally have support for in-line comments, should help greatly with readability and troubleshooting test results. Python tests are removed from roles that do not use python. Python tests are now done by python-unit-tests.yml which also does the black, flake8, and pylint tests. Signed-off-by: Rich Megginson <rmeggins@redhat.com>
67 lines
2.2 KiB
YAML
67 lines
2.2 KiB
YAML
---
|
|
# yamllint disable rule:line-length
|
|
name: Python Unit Tests
|
|
on: # yamllint disable-line rule:truthy
|
|
pull_request:
|
|
push:
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
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-get update
|
|
sudo apt-get install -y git
|
|
- name: checkout PR
|
|
uses: actions/checkout@v3
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v4
|
|
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@2.13.1"
|
|
# 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
|