-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cicd: add Ruff linting and formatting (#376)
Co-authored-by: Kori Kuzma <korikuzma@gmail.com>
- Loading branch information
1 parent
2f27f36
commit a1d10d4
Showing
48 changed files
with
1,970 additions
and
1,635 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,64 @@ | ||
name: checks | ||
on: [push, pull_request] | ||
jobs: | ||
test: | ||
name: test py${{ matrix.python-version }} | ||
runs-on: ubuntu-latest | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.DUMMY_AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.DUMMY_AWS_SECRET_ACCESS_KEY }} | ||
AWS_DEFAULT_REGION: us-east-2 | ||
AWS_DEFAULT_OUTPUT: text | ||
DISEASE_NORM_DB_URL: http://localhost:8002 | ||
THERAPY_NORM_DB_URL: http://localhost:8002 | ||
THERAPY_TEST: true | ||
strategy: | ||
matrix: | ||
python-version: ['3.8', '3.9', '3.10', '3.11'] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
test: | ||
name: test py${{ matrix.python-version }} | ||
runs-on: ubuntu-latest | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.DUMMY_AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.DUMMY_AWS_SECRET_ACCESS_KEY }} | ||
AWS_DEFAULT_REGION: us-east-2 | ||
AWS_DEFAULT_OUTPUT: text | ||
DISEASE_NORM_DB_URL: http://localhost:8002 | ||
THERAPY_NORM_DB_URL: http://localhost:8002 | ||
THERAPY_TEST: true | ||
strategy: | ||
matrix: | ||
python-version: ["3.8", "3.9", "3.10", "3.11"] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install dependencies | ||
run: | | ||
python3 -m pip install ".[dev,test]" | ||
- name: Install dependencies | ||
run: | | ||
python3 -m pip install ".[dev,test]" | ||
- name: Build local DynamoDB | ||
run: | | ||
chmod +x ./tests/scripts/dynamodb_run.sh | ||
./tests/scripts/dynamodb_run.sh | ||
- name: Build local DynamoDB | ||
run: | | ||
chmod +x ./tests/scripts/dynamodb_run.sh | ||
./tests/scripts/dynamodb_run.sh | ||
- name: Run tests | ||
run: python3 -m pytest | ||
lint: | ||
name: lint py${{ matrix.python-version }} | ||
runs-on: ubuntu-latest | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.DUMMY_AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.DUMMY_AWS_SECRET_ACCESS_KEY }} | ||
AWS_DEFAULT_REGION: us-east-2 | ||
AWS_DEFAULT_OUTPUT: text | ||
strategy: | ||
matrix: | ||
python-version: ['3.8', '3.9', '3.10', '3.11'] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Run tests | ||
run: python3 -m pytest | ||
lint: | ||
name: lint py${{ matrix.python-version }} | ||
runs-on: ubuntu-latest | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.DUMMY_AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.DUMMY_AWS_SECRET_ACCESS_KEY }} | ||
AWS_DEFAULT_REGION: us-east-2 | ||
AWS_DEFAULT_OUTPUT: text | ||
strategy: | ||
matrix: | ||
python-version: ["3.8", "3.9", "3.10", "3.11"] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install dependencies | ||
run: python3 -m pip install ".[dev,test]" | ||
- name: Install dependencies | ||
run: python3 -m pip install ".[dev,test]" | ||
|
||
- name: Check style | ||
run: python3 -m flake8 therapy/ tests/ setup.py | ||
|
||
- name: Check type correctness | ||
if: ${{ always() }} | ||
run: python3 -m mypy --ignore-missing-imports therapy/ | ||
- name: Check style | ||
run: python3 -m ruff check . && ruff format --check . | ||
|
||
- name: Check type correctness | ||
if: ${{ always() }} | ||
run: python3 -m mypy --ignore-missing-imports therapy/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
# See https://pre-commit.com for more information | ||
# See https://pre-commit.com/hooks.html for more hooks | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v1.4.0 | ||
hooks: | ||
- id: flake8 | ||
additional_dependencies: [flake8-docstrings, flake8-quotes, flake8-import-order, flake8-annotations] | ||
- id: check-added-large-files | ||
args: ['--maxkb=2500'] | ||
- id: detect-private-key | ||
- id: check-added-large-files | ||
- id: detect-private-key | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
rev: v0.1.2 | ||
hooks: | ||
- id: ruff | ||
- id: ruff-format |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,43 @@ | ||
[build-system] | ||
requires = ["setuptools", "wheel"] | ||
build-backend = "setuptools.build_meta:__legacy__" | ||
|
||
[tool.ruff] | ||
# pycodestyle (E, W) | ||
# Pyflakes (F) | ||
# flake8-annotations (ANN) | ||
# pydocstyle (D) | ||
# pep8-naming (N) | ||
# isort (I) | ||
select = ["E", "W", "F", "ANN", "D", "N", "I"] | ||
|
||
fixable = ["I", "F401"] | ||
|
||
# D203 - one-blank-line-before-class | ||
# D205 - blank-line-after-summary | ||
# D206 - indent-with-spaces* | ||
# D213 - multi-line-summary-second-line | ||
# D400 - ends-in-period | ||
# D415 - ends-in-punctuation | ||
# ANN101 - missing-type-self | ||
# ANN003 - missing-type-kwargs | ||
# E501 - line-too-long | ||
# W191 - tab-indentation* | ||
# *ignored for compatibility with formatter | ||
ignore = ["D203", "D205", "D206", "D213", "D400", "D415", "ANN101", "ANN003", "E501", "Q", "W191"] | ||
|
||
[tool.ruff.per-file-ignores] | ||
# ANN001 - missing-type-function-argument | ||
# ANN2 - missing-return-type | ||
# ANN201 - Missing type annotation | ||
# ANN102 - missing-type-cls | ||
# D103 - Missing docstring in public function | ||
# F821 - undefined-name | ||
# F401 - unused-import | ||
# I001 - Import block unsorted or unformatted | ||
# N805 - invalid-first-argument-name-for-method | ||
"tests/*" = ["ANN001", "ANN102", "ANN2"] | ||
"setup.py" = ["F821"] | ||
"*__init__.py" = ["F401"] | ||
"therapy/schemas.py" = ["ANN001", "ANN201", "N805"] | ||
"docs/source/conf.py" = ["D100", "I001", "D103", "ANN201", "ANN001"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.