diff --git a/.circleci/config.yml b/.circleci/config.yml index c70ee481..54cce876 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -60,7 +60,7 @@ jobs: - run: name: Upload code coverage command: ./codecov - + tests_postgres13: docker: - image: cimg/python:3.8.17 @@ -127,18 +127,15 @@ jobs: steps: - checkout + - run: pipenv install pre-commit + - restore_cache: - key: dependencies-{{ .Branch }}-{{ checksum "Pipfile.lock" }} + key: dependencies-{{ .Branch }}-{{ checksum "Pipfile.lock" }}-{{ checksum ".pre-commit-config.yaml" }} - run: name: Install Dependencies command: pipenv sync --dev - - save_cache: - paths: - - ./venv - key: dependencies-{{ .Branch }}-{{ checksum "Pipfile.lock" }} - - run: name: Prospector command: pipenv run prospector -W pylint -W pep257 @@ -156,6 +153,18 @@ jobs: command: | pipenv run bandit -c bandit.yaml -r . + - run: + name: Ruff + command: pipenv run pre-commit run ruff --from-ref origin/HEAD --to-ref HEAD + + - save_cache: + paths: + - ./venv + - ~/.cache/pre-commit + # the cache key changes whenever any of the branch name, Pipfile.lock checksum, or .pre-commit-config.yaml checksum change + key: dependencies-{{ .Branch }}-{{ checksum "Pipfile.lock" }}-{{ checksum ".pre-commit-config.yaml" }} + + workflows: version: 2 test: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bae5439b..c001ff39 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,12 @@ exclude: (exporter/assets/built/|caseworker/assets/built/) repos: + # ruff-pre-commit docs recommend running ruff before black + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.1.4 + hooks: + # Config for ruff lives in pyproject.toml + - id: ruff + args: [ --fix ] - repo: https://github.com/psf/black rev: 22.3.0 hooks: diff --git a/pyproject.toml b/pyproject.toml index 54fd24a7..7877461a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ [tool.black] line-length = 120 -target-version = ['py36', 'py37', 'py38'] +target-version = ['py38'] include = '\.pyi?$' exclude = ''' /( @@ -27,3 +27,6 @@ exclude = ''' [tool.isort] profile = 'black' line_length = 120 # To match Black's line-length above. + +[tool.ruff.lint] +select = ["F401"]