Skip to content

Testing

This projects provides a few different tests and checks.

In general, we have two files which defines all the tests:

To easily run these tests locally, use:

./scripts/test.sh

If you only want to run the pre-commit hooks manually, use:

pre-commit run --all-files

Running the GitLab CI locally is a bit more complicated. Is also requires Node.js as well as Docker installed and configured.

npm exec gitlab-ci-local
# or run a single job, e.g. pre-commit
npm exec gitlab-ci-local -- pre-commit

Python Code Tests

Static code checks using ruff:

# linter
python -m ruff check slki
python -m ruff check scripts
# formatter
python -m ruff format --diff slki
python -m ruff format --diff scripts

To run automatic static code fixes, use:

# linter
python -m ruff check --fix slki
python -m ruff check --fix scripts
# formatter
python -m ruff format slki
python -m ruff format scripts

Static type checks using mypy:

python -m mypy slki
python -m mypy scripts

Bash Script Checks

find scripts -type f -name "*.sh" -exec shellcheck --external-sources --shell bash --source-path scripts {} +

Markdown Checks

Verify documentation (markdown) compliance w.r.t. markdown linting rules further specified inside the .markdownlint-cli2.jsonc configuration file.

npm exec markdownlint-cli2 -- "./docs/**/*.md" "./README.md"

License Checks

python -m licensecheck
python -m reuse lint

Vulnerability Checks

python -m tox --recreate -e vulnerability