From 676a67897a067c79051e8a7b96aa218a58ccee6b Mon Sep 17 00:00:00 2001 From: Antony Milne Date: Fri, 24 Nov 2023 12:40:36 +0000 Subject: [PATCH 1/3] Enable pre-commit.ci autofixes --- .pre-commit-config.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index df8064356..153d0b765 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -86,3 +86,21 @@ repos: description: Detect hardcoded secrets using Gitleaks entry: gitleaks detect --verbose --redact --baseline-path .gitleaks-report.json language: golang + +# Configuration for https://pre-commit.ci/. +ci: + autoupdate_schedule: monthly + # Skip all hooks that just do checks without actually fixing anything. + skip: + - check-added-large-files + - check-merge-conflict + - check-case-conflict + - check-yaml + - check-json + - check-datafiles + - check-forbidden-words + - check-branch-name + - codespell + - bandit + - mypy + - gitleaks From 804408001a4d67744c072badc56372c2c77f90b5 Mon Sep 17 00:00:00 2001 From: Antony Milne <49395058+antonymilne@users.noreply.github.com> Date: Tue, 19 Dec 2023 12:47:55 +0000 Subject: [PATCH 2/3] Update contributing.md Signed-off-by: Antony Milne <49395058+antonymilne@users.noreply.github.com> --- vizro-core/docs/pages/development/contributing.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vizro-core/docs/pages/development/contributing.md b/vizro-core/docs/pages/development/contributing.md index 264e59e45..bc4b9c517 100644 --- a/vizro-core/docs/pages/development/contributing.md +++ b/vizro-core/docs/pages/development/contributing.md @@ -111,12 +111,14 @@ target-version = ["py37"] line-length = 120 ``` -Linting checks are enforced in CI. To run pre-commit hooks locally, there are two options: +We use [`pre-commit ci`](https://pre-commit.ci/) to automatically fix all the linting checks that we can (e.g. `black` formatting) when a PR is pushed. Other linting failures (e.g. `mypy`) need manual intervention from the developer. + +To run pre-commit hooks locally, there are two options: 1. Run `hatch run pre-commit install` to automatically run the hooks on every commit (you can always skip the checks with `git commit --no-verify`). In case this fails due to `gitleaks`, please read below for an explanation and how to install `go`. 2. Run `hatch run lint` to run `pre-commit` hooks on all files. (You can run e.g. `hatch run lint mypy -a` to only run specific linters, here mypy, on all files.) -Note that Hatch's `default` environment specifies `pre-commit` as a dependency but otherwise _does not_ specify dependencies for linting tools such as `black`. These are controlled by [.pre-commit-config.yaml](https://github.com/mckinsey/vizro/blob/main/.pre-commit-config.yaml) and can be updated when required with `pre-commit autoupdate`. +Note that Hatch's `default` environment specifies `pre-commit` as a dependency but otherwise _does not_ specify dependencies for linting tools such as `black`. These are controlled by [.pre-commit-config.yaml](https://github.com/mckinsey/vizro/blob/main/.pre-commit-config.yaml) and can be updated when required with `pre-commit autoupdate`. Once per month, `pre-commit ci` raises a PR to do so. ## Secret scans From 6323ac7eb5a312d93976f856f660b0711787f071 Mon Sep 17 00:00:00 2001 From: Antony Milne Date: Tue, 19 Dec 2023 12:51:30 +0000 Subject: [PATCH 3/3] Add changelog --- ...20231219_125122_antony.milne_pre_commit.md | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 vizro-core/changelog.d/20231219_125122_antony.milne_pre_commit.md diff --git a/vizro-core/changelog.d/20231219_125122_antony.milne_pre_commit.md b/vizro-core/changelog.d/20231219_125122_antony.milne_pre_commit.md new file mode 100644 index 000000000..f1f65e73c --- /dev/null +++ b/vizro-core/changelog.d/20231219_125122_antony.milne_pre_commit.md @@ -0,0 +1,48 @@ + + + + + + + + +