-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from trinitronx/add-pre-commit-hook
Add pre commit hook
- Loading branch information
Showing
4 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: pre-commit | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
- main | ||
paths: | ||
- '.pre-commit-config.yaml' | ||
- '.pre-commit-hooks.yaml' | ||
- 'Makefile' | ||
- 'makefile' | ||
- 'GNUmakefile' | ||
- '**.mk' | ||
- '**.make' | ||
push: | ||
paths: | ||
- '.pre-commit-config.yaml' | ||
- '.pre-commit-hooks.yaml' | ||
- 'Makefile' | ||
- 'makefile' | ||
- 'GNUmakefile' | ||
- '**.mk' | ||
- '**.make' | ||
|
||
jobs: | ||
pre-commit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v3 | ||
- name: Set up Go 1.17 | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.17 | ||
id: go | ||
- uses: pre-commit/[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
exclude: | | ||
(?x)^( | ||
vendor/.* | ||
)$ | ||
repos: | ||
- repo: https://github.com/mrtazz/checkmake.git | ||
rev: 0.2.2 | ||
hooks: | ||
- id: checkmake | ||
exclude: | | ||
(?x)^( | ||
vendor/.*| | ||
fixtures/missing_phony\.make | ||
)$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
- id: checkmake | ||
name: Makefile linter/analyzer | ||
entry: checkmake | ||
language: golang | ||
pass_filenames: true | ||
files: | | ||
(?x)^( | ||
(GNU)?[Mm]akefile| | ||
.*\.mk| | ||
.*\.make | ||
)$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,68 @@ Then run it with your Makefile attached, below is an example of it assuming the | |
docker run -v "$PWD"/Makefile:/Makefile checker | ||
``` | ||
|
||
## `pre-commit` usage | ||
|
||
This repo includes a `pre-commit` hook, which you may choose to use in your own | ||
repos. Simply add a `.pre-commit-config.yaml` to your repo's top-level directory | ||
|
||
```yaml | ||
repos: | ||
- repo: https://github.com/mrtazz/checkmake.git | ||
rev: 0.2.2 | ||
hooks: | ||
- id: checkmake | ||
``` | ||
Then, run `pre-commit` as usual. For example: | ||
|
||
```sh | ||
pre-commit run --all-files | ||
``` | ||
|
||
You may also choose to run this as a GitHub Actions workflow. To do this, add a | ||
`.github/workflows/pre-commit.yml` workflow to your repo: | ||
|
||
```yaml | ||
name: pre-commit | ||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
- main | ||
paths: | ||
- '.pre-commit-config.yaml' | ||
- '.pre-commit-hooks.yaml' | ||
- 'Makefile' | ||
- 'makefile' | ||
- 'GNUmakefile' | ||
- '**.mk' | ||
- '**.make' | ||
push: | ||
paths: | ||
- '.pre-commit-config.yaml' | ||
- '.pre-commit-hooks.yaml' | ||
- 'Makefile' | ||
- 'makefile' | ||
- 'GNUmakefile' | ||
- '**.mk' | ||
- '**.make' | ||
jobs: | ||
pre-commit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v3 | ||
- name: Set up Go 1.17 | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.17 | ||
id: go | ||
- uses: pre-commit/[email protected] | ||
``` | ||
|
||
## Installation | ||
|
||
### Requirements | ||
|