tox: add tox
`tox` is a standard testing tool for Python projects, this allows you to test locally with all your installed Python version with the following command: `tox -m test -p all` To run the tests in parallel for all supported Python versions. To run linters or type analysis: ``` tox -m lint -p all tox -m type -p all ``` This commit *also* disables the `import-error` warning from `pylint`, not all Python versions have the system-installed Python libraries available and they can't be fetched from PyPI. Some linters have been added and the general order linters run in has been changed. This allows for quicker test failure when running `tox -m lint`. As a consequence the `test_pylint` test has been removed as it's role can now be fulfilled by `tox`. Other assorted linter fixes due to newer versions: - use a str.join method (`consider-using-join`) - fix various (newer) mypy and pylint issues - comments starting with `#` and no space due to `autopep8` This also changes our CI to use the new `tox` setup and on top of that pins the versions of linters used. This might move into separate requirements.txt files later on to allow for easier updating of those dependencies.
This commit is contained in:
parent
a7b75bea3b
commit
d60690ce46
23 changed files with 193 additions and 184 deletions
72
.github/workflows/check.yml
vendored
Normal file
72
.github/workflows/check.yml
vendored
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
name: Checks
|
||||
|
||||
on: [pull_request, push]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
spelling_checker:
|
||||
name: "Spelling"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: codespell-project/actions-codespell@master
|
||||
with:
|
||||
ignore_words_list: msdos, pullrequest
|
||||
skip: ./.git,coverity,rpmbuild,samples
|
||||
|
||||
python_code_linters:
|
||||
name: "Python Linters"
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
linter:
|
||||
- "ruff"
|
||||
- "pylint"
|
||||
- "autopep8"
|
||||
- "isort"
|
||||
steps:
|
||||
- name: "Clone Repository"
|
||||
uses: actions/checkout@v3
|
||||
- name: "Run Linters"
|
||||
uses: osbuild/containers/src/actions/privdocker@552e30cf1b4ed19c6ddaa57f96c342b3dff4227b
|
||||
with:
|
||||
image: ghcr.io/osbuild/osbuild-ci:latest-202304251412
|
||||
run: |
|
||||
tox -e "${{ matrix.linter }}"
|
||||
|
||||
python_code_types:
|
||||
name: "Python Typing"
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
typer:
|
||||
- "mypy"
|
||||
steps:
|
||||
- name: "Clone Repository"
|
||||
uses: actions/checkout@v3
|
||||
- name: "Run Linters"
|
||||
uses: osbuild/containers/src/actions/privdocker@552e30cf1b4ed19c6ddaa57f96c342b3dff4227b
|
||||
with:
|
||||
image: ghcr.io/osbuild/osbuild-ci:latest-202304251412
|
||||
run: |
|
||||
tox -e "${{ matrix.typer }}"
|
||||
|
||||
shell_linters:
|
||||
name: "Shell Linters"
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: "Clone Repository"
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: "Differential ShellCheck"
|
||||
uses: redhat-plumbers-in-action/differential-shellcheck@v3
|
||||
with:
|
||||
severity: warning
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
24
.github/workflows/differential-shellcheck.yml
vendored
24
.github/workflows/differential-shellcheck.yml
vendored
|
|
@ -1,24 +0,0 @@
|
|||
name: "Differential ShellCheck"
|
||||
on:
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
name: "Differential Shell Check"
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: "Clone Repository"
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: "Differential ShellCheck"
|
||||
uses: redhat-plumbers-in-action/differential-shellcheck@v3
|
||||
with:
|
||||
severity: warning
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
name: Checks
|
||||
name: Generate
|
||||
|
||||
on: [pull_request, push]
|
||||
|
||||
jobs:
|
||||
documentation:
|
||||
name: "📚 Documentation"
|
||||
generate_documentation:
|
||||
name: "Documentation"
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: docker.io/library/python:3.7
|
||||
|
|
@ -33,8 +33,8 @@ jobs:
|
|||
test -d docs
|
||||
test -f docs/osbuild.1
|
||||
|
||||
test_data:
|
||||
name: "Regenerate Test Data"
|
||||
generate_test_data:
|
||||
name: "Test Data"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: "Clone Repository"
|
||||
|
|
@ -42,17 +42,7 @@ jobs:
|
|||
- name: "Regenerate Test Data"
|
||||
uses: osbuild/containers/src/actions/privdocker@552e30cf1b4ed19c6ddaa57f96c342b3dff4227b
|
||||
with:
|
||||
image: ghcr.io/osbuild/osbuild-ci:latest-202304110753
|
||||
image: ghcr.io/osbuild/osbuild-ci:latest-202304251412
|
||||
run: |
|
||||
make test-data
|
||||
git diff --exit-code -- ./test/data
|
||||
|
||||
codespell:
|
||||
name: "Spell check"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: codespell-project/actions-codespell@master
|
||||
with:
|
||||
ignore_words_list: msdos, pullrequest
|
||||
skip: ./.git,coverity,rpmbuild,samples
|
||||
|
|
@ -4,7 +4,7 @@ on: [pull_request, push]
|
|||
|
||||
jobs:
|
||||
test_suite:
|
||||
name: "Test Suite"
|
||||
name: "Unittest"
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
|
|
@ -19,17 +19,21 @@ jobs:
|
|||
- "test.run.test_noop"
|
||||
- "test.run.test_sources"
|
||||
- "test.run.test_stages"
|
||||
- "test.src"
|
||||
environment:
|
||||
- "py36"
|
||||
- "py37"
|
||||
- "py38"
|
||||
- "py39"
|
||||
- "py310"
|
||||
- "py311"
|
||||
- "py312"
|
||||
steps:
|
||||
- name: "Clone Repository"
|
||||
uses: actions/checkout@v3
|
||||
- name: "Run Tests"
|
||||
- name: "Run"
|
||||
uses: osbuild/containers/src/actions/privdocker@552e30cf1b4ed19c6ddaa57f96c342b3dff4227b
|
||||
with:
|
||||
image: ghcr.io/osbuild/osbuild-ci:latest-202304110753
|
||||
image: ghcr.io/osbuild/osbuild-ci:latest-202304251412
|
||||
run: |
|
||||
python3 -m pytest \
|
||||
--pyargs "${{ matrix.test }}" \
|
||||
--rootdir=. \
|
||||
--cov-report=xml --cov=osbuild \
|
||||
-v
|
||||
TEST_CATEGORY="${{ matrix.test }}" \
|
||||
tox -e "${{ matrix.environment }}"
|
||||
Loading…
Add table
Add a link
Reference in a new issue