Skip to content

ci: mypy in linting github action #2976

ci: mypy in linting github action

ci: mypy in linting github action #2976

Workflow file for this run

name: Run Tests
on:
push:
branches: [master, develop]
pull_request:
branches: [master, develop]
schedule:
- cron: "0 7 * * 1"
workflow_dispatch:
jobs:
lint:
name: Linting (pre-commit and mypy)
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v4
- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Set up Python 3.8
uses: actions/setup-python@v5
with:
python-version: "3.8"
- name: Update pip
run: python -m pip install --upgrade pip
- name: Get pip cache dir
id: pip-cache
shell: bash
run: echo "DIR=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: Get current week number
id: get-week
shell: bash
run: echo "WEEK=$(date +'%V')" >> $GITHUB_OUTPUT
- name: Pip cache
uses: actions/cache@v4
with:
path: ${{ steps.pip-cache.outputs.DIR }}
key: ${{ runner.os }}-pip-${{ steps.get-week.outputs.WEEK }}-${{ hashFiles('setup.cfg') }}
- name: Install tox
run: python -m pip install tox
- name: Run linters with tox
run: python -m tox -e linters
tests:
name: Test it!
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.8, "3.12"]
os: [ubuntu-latest, windows-latest]
steps:
- name: Checkout the repo
uses: actions/checkout@v4
- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Update pip
run: python -m pip install --upgrade pip
- name: Get pip cache dir
id: pip-cache
shell: bash
run: echo "DIR=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: Get current week number
id: get-week
shell: bash
run: echo "WEEK=$(date +'%V')" >> $GITHUB_OUTPUT
- name: Pip cache
uses: actions/cache@v4
with:
path: ${{ steps.pip-cache.outputs.DIR }}
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ steps.get-week.outputs.WEEK }}-${{ hashFiles('setup.cfg') }}
- name: Install tox and tox-gh-actions
run: python -m pip install tox tox-gh-actions
- name: Test with tox
run: tox
- name: Upload Unit Test Results
if: always()
uses: actions/upload-artifact@v4
with:
name: unit-test-results-python${{ matrix.python-version }}-${{ matrix.os }}
path: |
test-reports/junit-report.xml
test-reports/coverage.xml
publish-test-results:
name: "Publish Unit Tests Results"
needs: tests
runs-on: ubuntu-latest
if: always()
steps:
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
continue-on-error: true
with:
files: artifacts/*/junit-report.xml
- name: Produce the coverage report for Ubuntu
uses: insightsengineering/coverage-action@v2
with:
# Path to the Cobertura XML report.
path: artifacts/unit-test-results-python3.12-ubuntu-latest/coverage.xml
# Minimum total coverage, if you want to the
# workflow to enforce it as a standard.
# This has no effect if the `fail` arg is set to `false`.
threshold: 70
# Fail the workflow if the minimum code coverage
# reuqirements are not satisfied.
fail: false
# Publish the rendered output as a PR comment
publish: true
# Create a coverage diff report.
diff: true
# Branch to diff against.
# Compare the current coverage to the coverage
# determined on this branch.
diff-branch: develop
# This is where the coverage reports for the
# `diff-branch` are stored.
# Branch is created if it doesn't already exist'.
diff-storage: _xml_coverage_reports
# A custom title that can be added to the code
# coverage summary in the PR comment.
coverage-summary-title: "Code Coverage (Ubuntu)"
# Make the code coverage report togglable
togglable-report: true
- name: Produce the coverage report for Windows
uses: insightsengineering/coverage-action@v2
with:
# Path to the Cobertura XML report.
path: artifacts/unit-test-results-python3.12-windows-latest/coverage.xml
# Minimum total coverage, if you want to the
# workflow to enforce it as a standard.
# This has no effect if the `fail` arg is set to `false`.
threshold: 70
# Fail the workflow if the minimum code coverage
# reuqirements are not satisfied.
fail: false
# Publish the rendered output as a PR comment
publish: true
# Create a coverage diff report.
diff: true
# Branch to diff against.
# Compare the current coverage to the coverage
# determined on this branch.
diff-branch: develop
# This is where the coverage reports for the
# `diff-branch` are stored.
# Branch is created if it doesn't already exist'.
diff-storage: _xml_coverage_reports_win
# A custom title that can be added to the code
# coverage summary in the PR comment.
coverage-summary-title: "Code Coverage (Windows)"
# Make the code coverage report togglable
togglable-report: true
build-docs:
name: Build the docs
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v4
- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Set up Python 3.8
uses: actions/setup-python@v5
with:
python-version: "3.8"
- name: Update pip
run: python -m pip install --upgrade pip
- name: Get pip cache dir
id: pip-cache
shell: bash
run: echo "DIR=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: Get current week number
id: get-week
shell: bash
run: echo "WEEK=$(date +'%V')" >> $GITHUB_OUTPUT
- name: Pip cache
uses: actions/cache@v4
with:
path: ${{ steps.pip-cache.outputs.DIR }}
key: ${{ runner.os }}-pip-${{ steps.get-week.outputs.WEEK }}-${{ hashFiles('setup.cfg') }}
- name: Install pandoc
run: |
curl -s https://api.github.com/repos/jgm/pandoc/releases/latest | grep -o "https.*amd64.deb" | wget -O pandoc.deb -qi -
sudo dpkg -i pandoc.deb && rm pandoc.deb
- name: Install tox
run: |
python -m pip install tox
- name: Testing with tox
run: python -m tox -e docs
check-pypi:
name: Long description check for PyPI
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v4
- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Set up Python 3.8
uses: actions/setup-python@v5
with:
python-version: "3.8"
- name: Update pip
run: python -m pip install --upgrade pip
- name: Get pip cache dir
id: pip-cache
shell: bash
run: echo "DIR=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: Get current week number
id: get-week
shell: bash
run: echo "WEEK=$(date +'%V')" >> $GITHUB_OUTPUT
- name: Pip cache
uses: actions/cache@v4
with:
path: ${{ steps.pip-cache.outputs.DIR }}
key: ${{ runner.os }}-pip-${{ steps.get-week.outputs.WEEK }}-${{ hashFiles('setup.cfg') }}
- name: Install tox and sphinx (to have rst2html.py utility available)
run: |
python -m pip install tox sphinx
- name: Testing with tox
run: python -m tox -e pypi