Skip to content

Commit

Permalink
Merge pull request #125 from imperialCHEPI/precommit
Browse files Browse the repository at this point in the history
Add `pre-commit` config and check hooks in CI
  • Loading branch information
alexdewar committed Jun 20, 2023
2 parents d53866c + 6566502 commit 3bc9d94
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]

build:
name: Build and test
runs-on: ${{ matrix.os }}
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/pre-commit_autoupdate.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
- uses: actions/[email protected]
- uses: browniebroke/pre-commit-autoupdate-action@main
- uses: peter-evans/[email protected]
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.
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 3bc9d94

Please sign in to comment.