Skip to content

Commit

Permalink
Add CI
Browse files Browse the repository at this point in the history
  • Loading branch information
glatteis committed Jun 25, 2024
1 parent 3902ad8 commit bd7908b
Show file tree
Hide file tree
Showing 8 changed files with 273 additions and 90 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Lint

on: pull_request

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true

env:
PYTHON_VERSION: '3.11'
PRECOMMIT_VERSION: '3.7.1'

jobs:
pre-commit:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

- name: Configure Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install pre-commit
run: pip install pre-commit==${{ env.PRECOMMIT_VERSION }}

- name: Cache pre-commit
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: precommit-${{ hashFiles('.pre-commit-config.yaml') }}

- name: Run pre-commit
run: pre-commit run --all-files
46 changes: 46 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Test

on: pull_request

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true

env:
PYTHON_VERSION: '3.11'
POETRY_VERSION: '1.8.3'

jobs:
test:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

- name: Configure Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: ${{ env.POETRY_VERSION }}
virtualenvs-create: true
virtualenvs-in-project: true

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-v1-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-root --only main,test

- name: Install library
run: poetry install --only main,test

- name: Run tests and generate coverage report
run: make coverage
19 changes: 19 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.4.6
hooks:
- id: ruff
- id: ruff-format

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: pretty-format-json
args: [--autofix, --no-sort-keys]

- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.368
hooks:
- id: pyright
238 changes: 156 additions & 82 deletions poetry.lock

Large diffs are not rendered by default.

17 changes: 13 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "stormvogel"
version = "0.1.0"
Expand All @@ -8,9 +12,14 @@ readme = "README.md"

[tool.poetry.dependencies]
python = "^3.12"
black = "^24.4.2"

[tool.poetry.group.lint.dependencies]
pre-commit = "^3.7.1"
ruff = "^0.4.6"
pyright = "^1.1.368"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
[tool.ruff]
src = ["stormvogel", "examples"]
line-length = 88
target-version = "py311"
fix = true
2 changes: 1 addition & 1 deletion stormvogel/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"""The stormvogel package"""
"""The stormvogel package"""
4 changes: 2 additions & 2 deletions stormvogel/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def get_action(self, name: str) -> Action:
"Called get_action on a model that does not support actions"
)
assert self.actions is not None
if not name in self.actions:
if name not in self.actions:
raise RuntimeError(
f"Tried to get action {name} but that action does not exist"
)
Expand Down Expand Up @@ -258,7 +258,7 @@ def get_states_with(self, label: str):

def get_state_by_id(self, state_id):
"""Get a state by its id."""
if not state_id in self.states:
if state_id not in self.states:
raise RuntimeError("Requested a non-existing state")
return self.states[state_id]

Expand Down
3 changes: 2 additions & 1 deletion stormvogel/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

from model import Model

def show(m: Model) -> any:

def show(m: Model):
pass

0 comments on commit bd7908b

Please sign in to comment.