Skip to content

Commit

Permalink
Merge pull request #17 from Deltares/pixi
Browse files Browse the repository at this point in the history
add pixi, linting, pytest and run it on CI
  • Loading branch information
visr authored Oct 9, 2023
2 parents 8c0d160 + 249f8db commit 5372ca1
Show file tree
Hide file tree
Showing 27 changed files with 19,655 additions and 157 deletions.
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* text=auto eol=lf

# GitHub syntax highlighting
pixi.lock linguist-language=YAML
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
28 changes: 28 additions & 0 deletions .github/workflows/pre-commit_auto_update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Pre-commit

on:
schedule:
# At 03:00 on day 1 of the month
- cron: "0 3 1 * *"
# on demand
workflow_dispatch:

jobs:
auto-update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- uses: browniebroke/pre-commit-autoupdate-action@main
- uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: update/pre-commit-hooks
title: Update pre-commit hooks
commit-message: "Update pre-commit hooks"
body: Update versions of pre-commit hooks to latest version.
author: "GitHub <[email protected]>"
17 changes: 17 additions & 0 deletions .github/workflows/pre-commit_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Pre-commit

on:
pull_request:
merge_group:
push:
branches: [main, update/pre-commit-hooks]

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- uses: pre-commit/[email protected]
27 changes: 27 additions & 0 deletions .github/workflows/python_lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Python Lint
on:
push:
branches: [main]
paths-ignore: [".teamcity/**"]
tags: ["*"]
pull_request:
merge_group:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
mypy:
name: Mypy
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v4
- uses: prefix-dev/[email protected]
with:
pixi-version: "latest"
cache: true
- name: Prepare pixi
run: pixi run install-without-pre-commit
- name: Run mypy on hydamo
run: |
pixi run mypy-hydamo
39 changes: 39 additions & 0 deletions .github/workflows/python_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Python Tests
on:
push:
branches: [main]
paths-ignore: [".teamcity/**"]
tags: ["*"]
pull_request:
merge_group:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: Python ${{ matrix.os }} - ${{ matrix.arch }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macOS-latest
- windows-latest
arch:
- x86
steps:
- uses: actions/checkout@v4

- uses: prefix-dev/[email protected]
with:
pixi-version: "latest"
cache: true
- name: Prepare pixi
run: pixi run install-without-pre-commit

- name: Run tests
run: pixi run test-hydamo

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# pixi environments
.pixi

# visual studio code
.vscode/settings.json

.ipynb_checkpoints
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
htmlcov/
coverage.xml
.coverage
.coverage.*
.pytest_cache/

# mypy
.mypy_cache/
.dmypy.json
dmypy.json
37 changes: 37 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-json
- id: check-yaml
- id: check-toml
- id: check-merge-conflict
- id: check-vcs-permalinks
-
id: end-of-file-fixer
exclude: '.teamcity'
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.291
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/psf/black
rev: 23.9.1
hooks:
- id: black
- id: black-jupyter
- repo: https://github.com/kynan/nbstripout
rev: 0.6.1
hooks:
- id: nbstripout
- repo: https://github.com/crate-ci/typos
rev: v1.16.17
hooks:
- id: typos
# use pass_filenames as a workaround such that
# the excluded files in .typos.toml are respected
# https://github.com/crate-ci/typos/issues/347
pass_filenames: false
2 changes: 2 additions & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[files]
extend-exclude = ["*.csv", "*.json"]
9 changes: 9 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"recommendations": [
"ms-python.python",
"ms-python.black-formatter",
"ms-python.mypy-type-checker",
"charliermarsh.ruff",
"njpwerner.autodocstring"
]
}
10 changes: 10 additions & 0 deletions .vscode/settings_template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"notebook.formatOnSave.enabled": true,
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": true
}
}
}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Stichting Deltares
Copyright (c) Ribasim-NL developers

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
9 changes: 9 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
coverage:
status:
patch:
default:
informational: true

project:
default:
informational: true
11 changes: 11 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[mypy]
plugins = pydantic.mypy, numpy.typing.mypy_plugin, pandera.mypy

warn_unused_configs = True
warn_redundant_casts = True
warn_unused_ignores = True
strict_equality = True
strict_concatenate = True
disallow_subclassing_any = True
disallow_untyped_decorators = True
disallow_any_generics = True
Loading

0 comments on commit 5372ca1

Please sign in to comment.