From e4da6604412e065cbe0b6a6f6647cfa04798ab32 Mon Sep 17 00:00:00 2001 From: Alex Dewar Date: Mon, 19 Jun 2023 13:21:32 +0100 Subject: [PATCH 1/4] Add .pre-commit-config.yaml Initially I've gone with a few conservative hooks. --- .pre-commit-config.yaml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..2bcb602eb --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,7 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-merge-conflict + - id: check-json + - id: check-yaml From 3cd342bb83bca1adcc42fa4eea993e6996038b20 Mon Sep 17 00:00:00 2001 From: Alex Dewar Date: Mon, 19 Jun 2023 13:31:23 +0100 Subject: [PATCH 2/4] Run pre-commit hooks as part of CI --- .github/workflows/ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index af8f80afb..8c5d3e731 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,6 +10,13 @@ on: workflow_dispatch: jobs: + qa: + name: Run pre-commit hooks + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: pre-commit/action@v3.0.0 + build: name: Build and test runs-on: ${{ matrix.os }} From feba9bb81f268500782fe6e6af2033f5db0bbf63 Mon Sep 17 00:00:00 2001 From: Alex Dewar Date: Mon, 19 Jun 2023 18:03:40 +0100 Subject: [PATCH 3/4] Add GitHub Action to update pre-commit hooks --- .github/workflows/pre-commit_autoupdate.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/pre-commit_autoupdate.yml diff --git a/.github/workflows/pre-commit_autoupdate.yml b/.github/workflows/pre-commit_autoupdate.yml new file mode 100644 index 000000000..a9d9a9e6e --- /dev/null +++ b/.github/workflows/pre-commit_autoupdate.yml @@ -0,0 +1,20 @@ +name: Pre-commit auto-update + +on: + schedule: + - cron: "0 0 * * 1" # midnight every Monday + +jobs: + auto-update: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3.1.0 + - uses: actions/setup-python@v4.3.0 + - uses: browniebroke/pre-commit-autoupdate-action@main + - uses: peter-evans/create-pull-request@v5.0.1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + branch: update/pre-commit-hooks + title: Update pre-commit hooks + commit-message: "chore: update pre-commit hooks" + body: Update versions of pre-commit hooks to latest version. From 65665025eee488b517f9e432dd21571992ef5750 Mon Sep 17 00:00:00 2001 From: Alex Dewar Date: Mon, 19 Jun 2023 18:13:51 +0100 Subject: [PATCH 4/4] Add note about pre-commit to README --- README.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index dd3f661b3..7af691c4e 100644 --- a/README.md +++ b/README.md @@ -93,8 +93,24 @@ cmake --build --preset='debug-build-linux' ctest --preset='core-test-linux' ``` -All available options are defined using CMake *presets* in the `CMakePresets.json` file, which also declare *build presets* to be used via the CMake command line arguments. +All available options are defined using CMake *presets* in the `CMakePresets.json` file, +which also declare *build presets* to be used via the CMake command line arguments. +### Optional: Running `pre-commit` hooks + +It is recommended that developers install [`pre-commit`](https://pre-commit.com/) to +make use of [the hooks](./.pre-commit-config.yaml) we have installed for this +repository. (Note that this step is only for Health-GPS developers, not end users!) + +Once you have [installed `pre-commit`](https://pre-commit.com/#installation), you should +install the hooks into your local clone of the Health-GPS repository, like so: + +```cmd +> pre-commit install +``` + +Now, every time attempt to make a git commit, your changes will be checked against the +`pre-commit` hooks. # License