chore: enable mypy; actions cleanup (#21)

* chore: eenable mypy

* chore: Update MyPy command in typecheck.yml workflow

* fix caching. makefile lint improvements

* chore: Fix sed command in typecheck.yml workflow

* chore: Update sed command in typecheck.yml workflow

* chore: Update Python version to 3.10 in typecheck.yml workflow

* remove pretty

* pipefail
This commit is contained in:
Daniel Chalef 2024-08-22 15:10:24 -07:00 committed by GitHub
parent 1f1652f56c
commit c90b4e01ab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 70 additions and 30 deletions

43
.github/workflows/typecheck.yml vendored Normal file
View file

@ -0,0 +1,43 @@
name: MyPy Type Check
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
jobs:
mypy:
runs-on: depot-ubuntu-22.04
environment: development
steps:
- uses: actions/checkout@v4
- name: Set up Python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.8.0
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --with dev
- name: Run MyPy
shell: bash
run: |
set -o pipefail
poetry run mypy . --show-column-numbers --show-error-codes | sed -E '
s/^(.*):([0-9]+):([0-9]+): (error|warning): (.+) \[(.+)\]/::error file=\1,line=\2,endLine=\2,col=\3,title=\6::\5/;
s/^(.*):([0-9]+):([0-9]+): note: (.+)/::notice file=\1,line=\2,endLine=\2,col=\3,title=Note::\4/;
'

View file

@ -2,9 +2,9 @@ name: Unit Tests
on: on:
push: push:
branches: [ main ] branches: [main]
pull_request: pull_request:
branches: [ main ] branches: [main]
jobs: jobs:
test: test:
@ -12,30 +12,26 @@ jobs:
environment: environment:
name: development name: development
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v4 uses: actions/setup-python@v5
with: with:
python-version: '3.11' python-version: "3.10"
- name: Load cached Poetry installation - name: Load cached Poetry installation
uses: actions/cache@v3 uses: actions/cache@v4
with: with:
path: ~/.local path: ~/.local
key: poetry-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} key: poetry-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
- name: Install Poetry - name: Install Poetry
uses: snok/install-poetry@v1 uses: snok/install-poetry@v1
with: with:
virtualenvs-create: true virtualenvs-create: true
virtualenvs-in-project: true virtualenvs-in-project: true
- name: Load cached dependencies installer-parallel: true
uses: actions/cache@v3 - name: Install dependencies
with: run: poetry install --no-interaction --no-root
path: .venv - name: Run non-integration tests
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} env:
- name: Install dependencies PYTHONPATH: ${{ github.workspace }}
run: poetry install --no-interaction --no-root run: |
- name: Run non-integration tests poetry run pytest -m "not integration"
env:
PYTHONPATH: ${{ github.workspace }}
run: |
poetry run pytest -m "not integration"

View file

@ -22,7 +22,8 @@ format:
# Lint code # Lint code
lint: lint:
$(RUFF) check $(RUFF) check
# $(MYPY) . $(MYPY) --install-types --non-interactive .
$(MYPY) . --show-column-numbers --show-error-codes --pretty
# Run tests # Run tests
test: test: