Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: lint and test with tox, add py sem release #23

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 7 additions & 16 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
# Check http://editorconfig.org for more information
# This is the main config file for this project:
# Root editor config file
root = true

# Common settings
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
charset = utf-8

[*.{py, pyi}]
indent_style = space
indent_size = 4

[Makefile]
# python, js indentation settings
[{*.py,*.js,*.vue,*.css,*.scss,*.html}]
indent_style = tab

[*.md]
trim_trailing_whitespace = false

[*.{diff,patch}]
trim_trailing_whitespace = false
indent_size = 2
max_line_length = 99
76 changes: 76 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
[flake8]
ignore =
B001,
B007,
B009,
B010,
B950,
E101,
E111,
E114,
E116,
E117,
E121,
E122,
E123,
E124,
E125,
E126,
E127,
E128,
E131,
E201,
E202,
E203,
E211,
E221,
E222,
E223,
E224,
E225,
E226,
E228,
E231,
E241,
E242,
E251,
E261,
E262,
E265,
E266,
E271,
E272,
E273,
E274,
E301,
E302,
E303,
E305,
E306,
E402,
E501,
E502,
E701,
E702,
E703,
E741,
F401,
F403,
F405,
W191,
W291,
W292,
W293,
W391,
W503,
W504,
W604,
E711,
E129,
F841,
E713,
E712,
B028,

max-line-length = 200
exclude=,test_*.py
50 changes: 0 additions & 50 deletions .github/workflows/pytest.yaml

This file was deleted.

26 changes: 26 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Release

on:
push:
branches:
- master

jobs:
release:
name: Release
runs-on: ubuntu-latest
concurrency: release
permissions:
id-token: write
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Python Semantic Release
uses: python-semantic-release/python-semantic-release@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
git_committer_name: AgriTheory
git_committer_email: [email protected]
60 changes: 60 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Run Tests

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
checkout:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip
restore-keys: ${{ runner.os }}-pip

tests:
needs: checkout
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest] # other OS?
python-version: ['3.10', '3.11', '3.12']
runs-on: ${{ matrix.os }}
permissions:
contents: write
checks: write
pull-requests: write
steps:
- 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 }}

- name: Install Poetry
uses: snok/install-poetry@v1

- name: Install tox
run: |
python -m pip install --upgrade pip
python -m pip install tox tox-gh-actions
- name: Run linting and tests with tox
run: python -m tox run

# Add coverage comment only if the Python env created the report
- name: Pytest coverage comment
if: ${{ hashFiles('coverage.xml') != '' }}
uses: MishaKav/pytest-coverage-comment@main
with:
pytest-xml-coverage-path: ${{ github.workspace }}/coverage.xml
79 changes: 55 additions & 24 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,36 +1,67 @@
default_language_version:
python: python3.10

default_stages: [commit, push]
exclude: 'node_modules|.git'
default_stages: [pre-commit]
fail_fast: false

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.5.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
files: 'forecast.*'
exclude: '.*json$|.*txt$|.*csv|.*md|.*svg'
- id: no-commit-to-branch
args: ['--branch', 'develop']
- id: check-merge-conflict
- id: check-ast
- id: check-json
- id: check-toml
- id: check-yaml
exclude: ^.github/
- id: end-of-file-fixer
- id: debug-statements

- repo: https://github.com/asottile/pyupgrade
rev: v3.19.1
hooks:
- id: pyupgrade
args: ['--py310-plus']

- repo: https://github.com/agritheory/black
rev: 951ccf4d5bb0d692b457a5ebc4215d755618eb68
hooks:
- id: black
args: ['--line-length', '99']

- repo: local
- repo: https://github.com/PyCQA/isort
rev: 6.0.0
hooks:
- id: isort
name: isort
entry: poetry run isort --settings-path pyproject.toml
types: [python]
language: system

- repo: local
- repo: https://github.com/PyCQA/flake8
rev: 7.1.1
hooks:
- id: pyupgrade
name: pyupgrade
entry: poetry run pyupgrade --py310-plus
types: [python]
language: system
- id: flake8
additional_dependencies: ['flake8-bugbear']

- repo: local
- repo: https://github.com/codespell-project/codespell
rev: v2.4.1
hooks:
- id: black
name: black
entry: poetry run black --config pyproject.toml
types: [python]
language: system
- id: codespell
args: ['--skip', 'poetry.lock', '--']
additional_dependencies:
- tomli

- repo: https://github.com/agritheory/test_utils
rev: v0.17.0
hooks:
- id: update_pre_commit_config

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.15.0
hooks:
- id: mypy
exclude: ^tests/
args: ['--install-types', '--non-interactive', '--ignore-missing-imports']

ci:
autoupdate_schedule: weekly
skip: []
submodules: false
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ make check-style STRICT=1
</details>

<details>
<summary>5. Run all the codestyle formaters</summary>
<summary>5. Run all the codestyle formatters</summary>
<p>

Codestyle uses `pre-commit` hooks, so ensure you've run `make install` before.
Expand Down
3 changes: 3 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[mypy]
ignore_missing_imports = True
disable_error_code = annotation-unchecked
Loading
Loading