diff --git a/.github/workflows/matchers/mypy.json b/.github/workflows/matchers/mypy.json new file mode 100644 index 0000000..cb29a09 --- /dev/null +++ b/.github/workflows/matchers/mypy.json @@ -0,0 +1,18 @@ +{ + "problemMatcher": [ + { + "owner": "mypy", + "severity": "error", + "pattern": [ + { + "regexp": "^(\\S*):(\\d+):(\\d+): ([a-z]+): (.*)$", + "file": 1, + "line": 2, + "column": 3, + "severity": 4, + "message": 5 + } + ] + } + ] +} \ No newline at end of file diff --git a/.github/workflows/mypy.yaml b/.github/workflows/mypy.yaml new file mode 100644 index 0000000..42f1749 --- /dev/null +++ b/.github/workflows/mypy.yaml @@ -0,0 +1,68 @@ +name: mypy + +on: + - pull_request + +jobs: + mypy: + defaults: + run: + shell: bash + strategy: + fail-fast: true + matrix: + os: ["ubuntu-latest", "macos-latest", "windows-latest"] + python-version: ["3.9", "3.10", "3.11"] + runs-on: ${{ matrix.os }} + steps: + #---------------------------------------------- + # check-out repo and set-up python + #---------------------------------------------- + - name: Check out repository + uses: actions/checkout@v4 + - name: Set up python ${{ matrix.python-version }} + id: setup-python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + #---------------------------------------------- + # ----- install poetry ----- + #---------------------------------------------- + - name: Install Poetry + uses: snok/install-poetry@v1 + with: + virtualenvs-create: true + virtualenvs-in-project: true + + #---------------------------------------------- + # install or use cached dependencies + #---------------------------------------------- + - name: Load cached venv + id: cached-poetry-dependencies + uses: actions/cache@v3 + with: + path: .venv + key: venv-${{ runner.os }}-python-${{ 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 --no-root + + # always install current root package + - name: Install library + run: poetry install --no-interaction + + #---------------------------------------------- + # ----- setup matchers & run mypy ----- + #---------------------------------------------- + - name: Setup matchers + run: | + echo "::add-matcher::.github/workflows/matchers/mypy.json" + echo "TERM: changing from $TERM -> xterm" + export TERM=xterm + - name: Run mypy + # NOTE: tomli is sometimes missing, install it explicitly + run: | + source $VENV + pip install tomli + mypy --show-column-numbers . diff --git a/.github/workflows/ruff.yaml b/.github/workflows/ruff.yaml new file mode 100644 index 0000000..3220d0f --- /dev/null +++ b/.github/workflows/ruff.yaml @@ -0,0 +1,65 @@ +name: Ruff + +on: + - pull_request + +jobs: + Ruff: + defaults: + run: + shell: bash + strategy: + fail-fast: true + matrix: + os: ["ubuntu-latest", "macos-latest", "windows-latest"] + python-version: ["3.9", "3.10", "3.11"] + runs-on: ${{ matrix.os }} + steps: + #---------------------------------------------- + # check-out repo and set-up python + #---------------------------------------------- + - name: Check out repository + uses: actions/checkout@v4 + - name: Set up python ${{ matrix.python-version }} + id: setup-python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + #---------------------------------------------- + # ----- install poetry ----- + #---------------------------------------------- + - name: Install Poetry + uses: snok/install-poetry@v1 + with: + virtualenvs-create: true + virtualenvs-in-project: true + + #---------------------------------------------- + # install or use cached dependencies + #---------------------------------------------- + - name: Load cached venv + id: cached-poetry-dependencies + uses: actions/cache@v3 + with: + path: .venv + key: venv-${{ runner.os }}-python-${{ 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 --no-root + + # always install current root package + - name: Install library + run: poetry install --no-interaction + + #---------------------------------------------- + # ----- run ruff ----- + #---------------------------------------------- + - name: Run Ruff Check + run: | + source $VENV + ruff check --output-format=github . + - name: Run Ruff Format Check + run: | + source $VENV + ruff format --check .