Skip to content

Commit

Permalink
add workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
se-jaeger committed Feb 27, 2024
1 parent 3b1f349 commit 3483079
Show file tree
Hide file tree
Showing 3 changed files with 151 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/matchers/mypy.json
Original file line number Diff line number Diff line change
@@ -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
}
]
}
]
}
68 changes: 68 additions & 0 deletions .github/workflows/mypy.yaml
Original file line number Diff line number Diff line change
@@ -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 .
65 changes: 65 additions & 0 deletions .github/workflows/ruff.yaml
Original file line number Diff line number Diff line change
@@ -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 .

0 comments on commit 3483079

Please sign in to comment.