Skip to content

Commit

Permalink
cicd: add Ruff linting and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jsstevenson committed Oct 26, 2023
1 parent b632b56 commit dc4684f
Show file tree
Hide file tree
Showing 41 changed files with 3,656 additions and 3,344 deletions.
22 changes: 0 additions & 22 deletions .flake8

This file was deleted.

107 changes: 53 additions & 54 deletions .github/workflows/checks.yaml
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']
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']
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/
18 changes: 10 additions & 8 deletions .pre-commit-config.yaml
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
6 changes: 1 addition & 5 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@ ipykernel = "*"
pytest = "*"
pytest-cov = "*"
pre-commit = "*"
flake8 = "*"
flake8-docstrings = "*"
flake8-quotes = "*"
flake8-import-order = "*"
flake8-annotations = "*"
ruff = ">=0.1.2"
ipython = ">=8.10.0"
jupyterlab = "*"
civicpy = "*"
Expand Down
45 changes: 45 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,48 @@
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta:__legacy__"

[tool.ruff]
# pycodestyle (E, W)
# Pyflakes (F)
# flake8-annotations (ANN)
# flake8-quotes (Q)
# pydocstyle (D)
# pep8-naming (N)
# isort (I)
select = ["E", "W", "F", "ANN", "Q", "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
# Q - flake8-quotes*
# W191 - tab-indentation*
# *ignored for compatibility with formatter
ignore = ["D203", "D205", "D206", "D213", "D400", "D415", "ANN101", "ANN003", "E501", "Q", "W191"]

[tool.ruff.format]
quote-style = "single"

[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"]
"gene/schemas.py" = ["ANN001", "ANN201", "N805"]
"docs/source/conf.py" = ["D100", "I001", "D103", "ANN201", "ANN001"]
6 changes: 1 addition & 5 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,12 @@ dev =
ipython >= 8.10
pre-commit
tox
flake8
flake8-docstrings
flake8-quotes
flake8-import-order
flake8-annotations
mypy
types-requests
types-pyyaml
lxml
xmlformatter
ruff >= 0.1.2

[tool:pytest]
addopts = --ignore setup.py --ignore=analysis/ --cov-report term-missing --cov=therapy
Expand Down
Loading

0 comments on commit dc4684f

Please sign in to comment.