diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 932967f..85124b0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -83,6 +83,40 @@ jobs: files: ./coverage.xml token: ${{ secrets.CODECOV_TOKEN }} + skip-linters: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + container: + - debian:bookworm-slim + - debian:testing-slim + - debian:unstable-slim + - ubuntu:jammy + - ubuntu:noble + - ubuntu:oracular + container: + image: ${{ matrix.container }} + steps: + - name: Install dependencies + run: > + apt-get update && + apt-get install --no-install-recommends --yes ca-certificates git + pylint python3 python3-coverage python3-ruamel.yaml + - uses: actions/checkout@v4 + - name: Run unit tests + run: | + SKIP_LINTERS=1 python3 -m coverage run -m unittest discover -v + python3 -m coverage xml + - name: Install dependencies for Codecov + run: apt-get install --no-install-recommends --yes curl gpg gpg-agent + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 + with: + fail_ci_if_error: true + files: ./coverage.xml + token: ${{ secrets.CODECOV_TOKEN }} + system-testing: runs-on: ubuntu-latest strategy: diff --git a/tests/test_black.py b/tests/test_black.py index 0da729a..425ebeb 100644 --- a/tests/test_black.py +++ b/tests/test_black.py @@ -14,6 +14,7 @@ """Run black code formatter in check mode.""" +import os import subprocess import sys import unittest @@ -28,6 +29,7 @@ class BlackTestCase(unittest.TestCase): source files is provided by the get_source_files() function. """ + @unittest.skipIf(os.environ.get("SKIP_LINTERS"), "requested via SKIP_LINTERS env variable") def test_black(self): """Test: Run black code formatter on Python source code.""" diff --git a/tests/test_flake8.py b/tests/test_flake8.py index dbf7bd3..8477abd 100644 --- a/tests/test_flake8.py +++ b/tests/test_flake8.py @@ -14,6 +14,7 @@ """Run flake8 check.""" +import os import subprocess import sys import unittest @@ -29,6 +30,7 @@ class Flake8TestCase(unittest.TestCase): get_source_files() function. """ + @unittest.skipIf(os.environ.get("SKIP_LINTERS"), "requested via SKIP_LINTERS env variable") def test_flake8(self): """Test: Run flake8 on Python source code.""" cmd = [sys.executable, "-m", "flake8", "--max-line-length=99"] + get_source_files() diff --git a/tests/test_isort.py b/tests/test_isort.py index 569f5bb..a358389 100644 --- a/tests/test_isort.py +++ b/tests/test_isort.py @@ -14,6 +14,7 @@ """Run isort to check if Python import definitions are sorted.""" +import os import subprocess import sys import unittest @@ -28,6 +29,7 @@ class IsortTestCase(unittest.TestCase): is provided by the get_source_files() function. """ + @unittest.skipIf(os.environ.get("SKIP_LINTERS"), "requested via SKIP_LINTERS env variable") def test_isort(self): """Test: Run isort on Python source code.""" diff --git a/tests/test_pylint.py b/tests/test_pylint.py index a72e3cd..e0058dc 100644 --- a/tests/test_pylint.py +++ b/tests/test_pylint.py @@ -38,6 +38,8 @@ def test_pylint(self): """Test: Run pylint on Python source code.""" cmd = [sys.executable, "-m", "pylint", "--rcfile=" + CONFIG, "--"] + get_source_files() + if os.environ.get("SKIP_LINTERS"): + cmd.insert(4, "--errors-only") if unittest_verbosity() >= 2: sys.stderr.write(f"Running following command:\n{' '.join(cmd)}\n") with subprocess.Popen( diff --git a/tests/test_shellcheck.py b/tests/test_shellcheck.py index b52a81b..a5fd058 100644 --- a/tests/test_shellcheck.py +++ b/tests/test_shellcheck.py @@ -14,6 +14,7 @@ """Run shellcheck on Shell code.""" +import os import subprocess import sys import unittest @@ -29,6 +30,7 @@ class ShellcheckTestCase(unittest.TestCase): on Shell source code. """ + @unittest.skipIf(os.environ.get("SKIP_LINTERS"), "requested via SKIP_LINTERS env variable") def test_shellcheck(self): """Test: Run shellcheck on Shell source code.""" cmd = ["shellcheck"] + [get_path(s) for s in SHELL_SCRIPTS]