Feat/53 handle different languages #364
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | |
name: Tests, Code Quality and Documentation | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
pull_request: | |
branches: | |
- main | |
- dev | |
workflow_dispatch: | |
jobs: | |
test: | |
runs-on: ${{ matrix.os }} | |
timeout-minutes: 10 | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ["3.10", "3.11"] | |
os: [ubuntu-latest, macOS-latest, windows-latest] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Run poetry image | |
uses: abatilo/actions-poetry@v3.0.0 | |
with: | |
poetry-version: ${{ vars.POETRY_VERSION }} | |
- name: Install dependencies | |
run: | | |
poetry install --with dev | |
- name: Run tests | |
run: | | |
poetry run pytest --cov=pystatis --vcr-record=none tests | |
code-quality: | |
runs-on: ${{ matrix.os }} | |
timeout-minutes: 10 | |
strategy: | |
fail-fast: false | |
matrix: | |
# only support specific python version, as guidelines differ beween (minor) versions | |
python-version: ["3.11.7"] | |
os: [ubuntu-latest] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Run poetry image | |
uses: abatilo/actions-poetry@v3.0.0 | |
with: | |
poetry-version: ${{ vars.POETRY_VERSION }} | |
- name: Install dependencies | |
run: poetry install --with dev | |
- name: Run black | |
run: poetry run black . --check | |
- name: Run isort | |
run: poetry run isort . --check-only | |
- name: Run flake8 | |
run: poetry run flake8 src --output-file=flake8_report.txt | |
- name: Run pylint | |
run: poetry run pylint src --recursive=y | |
- name: Run bandit | |
run: poetry run bandit -r src | |
- name: Run Safety CLI to check for vulnerabilities | |
uses: pyupio/safety-action@v1 | |
with: | |
api-key: ${{ secrets.SAFETY_API_KEY }} | |
continue-on-error: true # Do not fail this action if vulnerabilities are found | |
args: --detailed-output # To always see detailed output from this action | |
- name: Run mypy | |
run: poetry run mypy src | |
sphinx-documentation-and-coverage: | |
runs-on: ${{ matrix.os }} | |
timeout-minutes: 10 | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ["${{ vars.PYTHON_VERSION}}"] | |
os: [ubuntu-latest] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Run poetry image | |
uses: abatilo/actions-poetry@v3.0.0 | |
with: | |
poetry-version: ${{ vars.POETRY_VERSION }} | |
- name: Install dependencies | |
run: | | |
poetry install --with dev | |
- name: Build documentation | |
run: | | |
cd docs | |
poetry run make clean | |
poetry run make html | |
- name: Upload documentation as artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: docs | |
path: docs/build/html/* | |
retention-days: 5 | |
- name: Generate and filter test coverage report | |
run: | | |
poetry run coverage run -m pytest --vcr-record=none tests | |
poetry run coverage json -o assets/coverage.json | |
cov=$(jq -r '.totals.percent_covered_display' assets/coverage.json) | |
echo "{\"label\":\"Test Coverage\",\"message\":\"${cov}%\",\"schemaVersion\":1,\"color\":\"hsl(120, 100%, 40%)\"}" > assets/coverage_badge.json | |
# compromise: Due to versioning issues, only display | |
# coverage (report) for main (on/push/branches/main) | |
- name: Prepare files | |
# if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
run: | | |
set -e | |
mkdir -p output/publish | |
cp assets/coverage_badge.json output/publish/ |