From c90b4e01abf034f2076d21d2feaebbfc57086cb3 Mon Sep 17 00:00:00 2001 From: Daniel Chalef <131175+danielchalef@users.noreply.github.com> Date: Thu, 22 Aug 2024 15:10:24 -0700 Subject: [PATCH] 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 --- .github/workflows/typecheck.yml | 43 +++++++++++++++++++++++++ .github/workflows/unit_tests.yml | 54 +++++++++++++++----------------- Makefile | 3 +- 3 files changed, 70 insertions(+), 30 deletions(-) create mode 100644 .github/workflows/typecheck.yml diff --git a/.github/workflows/typecheck.yml b/.github/workflows/typecheck.yml new file mode 100644 index 00000000..87c751b3 --- /dev/null +++ b/.github/workflows/typecheck.yml @@ -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/; + ' diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 3009fd3a..6ca524b9 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -2,9 +2,9 @@ name: Unit Tests on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] jobs: test: @@ -12,30 +12,26 @@ jobs: environment: name: development steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.11' - - name: Load cached Poetry installation - uses: actions/cache@v3 - with: - path: ~/.local - key: poetry-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} - - name: Install Poetry - uses: snok/install-poetry@v1 - with: - virtualenvs-create: true - virtualenvs-in-project: true - - name: Load cached dependencies - uses: actions/cache@v3 - with: - path: .venv - key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} - - name: Install dependencies - run: poetry install --no-interaction --no-root - - name: Run non-integration tests - env: - PYTHONPATH: ${{ github.workspace }} - run: | - poetry run pytest -m "not integration" \ No newline at end of file + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.10" + - name: Load cached Poetry installation + uses: actions/cache@v4 + with: + path: ~/.local + key: poetry-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} + - name: Install Poetry + uses: snok/install-poetry@v1 + with: + virtualenvs-create: true + virtualenvs-in-project: true + installer-parallel: true + - name: Install dependencies + run: poetry install --no-interaction --no-root + - name: Run non-integration tests + env: + PYTHONPATH: ${{ github.workspace }} + run: | + poetry run pytest -m "not integration" diff --git a/Makefile b/Makefile index 5666d2a7..4c9be1b3 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,8 @@ format: # Lint code lint: $(RUFF) check -# $(MYPY) . + $(MYPY) --install-types --non-interactive . + $(MYPY) . --show-column-numbers --show-error-codes --pretty # Run tests test: