Skip to content

Commit

Permalink
cicd: update style checks and test coverage dependencies, init
Browse files Browse the repository at this point in the history
  • Loading branch information
jsstevenson committed Sep 27, 2023
1 parent 58e3832 commit b576ed2
Show file tree
Hide file tree
Showing 18 changed files with 106 additions and 431 deletions.
27 changes: 4 additions & 23 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,30 +50,11 @@ jobs:

lint:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
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
steps:
- uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: python3 -m pip install ".[dev]"

- name: flake8 check
run: flake8 disease/ tests/ setup.py

- name: black check
run: black --check disease/ tests/ setup.py
- name: black
uses: psf/black@stable

- name: isort check
run: isort --profile black --check disease/ tests/ setup.py
- name: ruff
uses: chartboost/ruff-action@v1
38 changes: 17 additions & 21 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
# 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
rev: v1.4.0
hooks:
- id: flake8
additional_dependencies: [flake8-docstrings]
- id: check-added-large-files
args: ['--maxkb=2500']
- id: detect-private-key
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
args: ["--check"]
language_version: python3.10
- repo: https://github.com/pycqa/isort
rev: 5.6.4
hooks:
- id: isort
args: ["--profile", "black", "--check"]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v1.4.0
hooks:
- id: check-added-large-files
- id: detect-private-key
- id: trailing-whitespace
- id: end-of-file-fixer
- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black
language_version: python3.11
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.280
hooks:
- id: ruff
args: [ --fix, --exit-non-zero-on-fix ]
8 changes: 2 additions & 6 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,14 @@ owlready2 = "*"
rdflib = "*"
pytest = "*"
pytest-cov = "*"
flake8 = "*"
flake8-docstrings = "*"
black = "*"
isort = "*"
pre-commit = "*"
coveralls = "*"
coverage = "*"
ipykernel = "*"
matplotlib = "*"
lxml = "*"
xmlformatter = "*"
psycopg = {version = "*", extras=["binary"]}
black = "*"
ruff = "*"

[packages]
pydantic = "*"
Expand Down
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,15 @@ pip install -e ".[pg,etl,dev,test]"

### Init coding style tests

Code style is managed by [flake8](https://github.com/PyCQA/flake8) and checked prior to commit.
Code style is managed by [Ruff](https://github.com/astral-sh/ruff) and [Black](https://github.com/psf/black) and checked prior to commit.

We use [pre-commit](https://pre-commit.com/#usage) to run conformance tests.
This performs checks for:

This ensures:

* Check code style
* Check for added large files
* Detect AWS Credentials
* Detect Private Key
* Code style
* File endings
* Added large files
* AWS credentials
* Private keys

Before first commit run:

Expand Down
6 changes: 3 additions & 3 deletions disease/cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""This module provides a CLI util to make updates to normalizer database."""
"""Provides a CLI util to make updates to normalizer database."""
import os
from pathlib import Path
from timeit import default_timer as timer
Expand Down Expand Up @@ -89,7 +89,7 @@ def update_from_remote(data_url: Optional[str], db_url: str) -> None:
type=click.Path(exists=True, path_type=Path),
)
@click.option("--db_url", help="URL endpoint for the application database.")
def dump_database(output_directory: Path, db_url: str):
def dump_database(output_directory: Path, db_url: str) -> None:
"""Dump data from database into file.
\f
Expand Down Expand Up @@ -176,7 +176,7 @@ def _load_source(
start_load = timer()

# used to get source class name from string
SourceClass = eval(n.value)
SourceClass = eval(n.value) # noqa: N806

source = SourceClass(database=db)
processed_ids += source.perform_etl(use_existing=from_local)
Expand Down
Loading

0 comments on commit b576ed2

Please sign in to comment.