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 }} 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. 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 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