From 23aedc8524e6b8c33837b8d789539b2f3ae76493 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Sun, 2 Jun 2024 21:30:04 -0400 Subject: [PATCH] Add linting to CI. --- .github/workflows/lint.yml | 32 ++++++++++++++++++++++++++++++++ scripts/lint.sh | 8 ++++++++ 2 files changed, 40 insertions(+) create mode 100644 .github/workflows/lint.yml create mode 100755 scripts/lint.sh diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..3d06008 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,32 @@ +name: API Lint +on: + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-python@v2 + name: Install Python + with: + python-version: '3.8' + + - name: Pip cache + id: pip-cache + uses: actions/cache@v2 + with: + path: ${{ env.pythonLocation }} + key: api-lint-${{ runner.os }}-${{ env.pythonLocation }}-pip-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/requirements-dev.txt') }} + + - name: Install deps + if: steps.pip-cache.outputs.cache-hit != 'true' + run: | + python -m pip install --upgrade pip + python -m pip install -r requirements.txt + python -m pip install -r requirements-dev.txt + + - name: Run linting + run: | + sh ./scripts/lint.sh diff --git a/scripts/lint.sh b/scripts/lint.sh new file mode 100755 index 0000000..848eba3 --- /dev/null +++ b/scripts/lint.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -ex + +mypy . +npx -q pyright@1.1.172 . +ruff check . +ruff format --check .