add lint to ci #28
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
name: Python CI | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
jobs: | |
build-and-test: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest] | |
env: | |
CI: 'true' # Setting an environment variable 'CI' to 'true' - skip plot visualisation | |
PYTHON_VERSION: '3.12' # Define the Python version in single place | |
steps: | |
- name: Check out the repository | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Set up dependencies (Linux) | |
if: runner.os == 'Linux' | |
run: | | |
cd prj/script | |
./venv_create.sh ${{ env.PYTHON_VERSION }} | |
cd ../.. | |
- name: Set up dependencies (Windows) | |
if: runner.os == 'Windows' | |
run: | | |
cd prj\script | |
.\venv_create.cmd ${{ env.PYTHON_VERSION }} | |
cd ..\.. | |
- name: Install dependencies (Linux) | |
if: runner.os == 'Linux' | |
run: | | |
cd prj/script | |
./pip_reqs_install.sh | |
cd ../.. | |
- name: Install dependencies (Windows) | |
if: runner.os == 'Windows' | |
run: | | |
cd prj\script | |
.\pip_reqs_install.cmd | |
cd ..\.. | |
- name: Run tests with pytest (Linux) | |
if: runner.os == 'Linux' | |
run: ./prj/venv/bin/pytest test/ | |
- name: Run tests with pytest (Windows) | |
if: runner.os == 'Windows' | |
run: .\prj\venv\Scripts\pytest.exe test\ | |
- name: Run type checking with mypy (Linux) | |
if: runner.os == 'Linux' | |
run: ./prj/venv/bin/mypy --check-untyped-defs -p test -p src | |
- name: Run type checking with mypy (Windows) | |
if: runner.os == 'Windows' | |
run: .\prj\venv\Scripts\mypy.exe --check-untyped-defs -p test -p src | |
- name: Run linter with pylint (Linux) | |
if: runner.os == 'Linux' | |
run: ./prj/venv/bin/python -m pylint --errors-only src test | |
- name: Run linter with pylint (Windows) | |
if: runner.os == 'Windows' | |
run: .\prj\venv\Scripts\python.exe -m pylint src --errors-only src test |