Skip to content

Commit 74f886d

Browse files
committed
Add: Pre commit config & go vuln check
1 parent b5662bb commit 74f886d

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

.pre-commit-config.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Install via pipx `sudo apt install pipx && pipx ensurepath && pipx install pre-commit`
2+
# reload your shell `source ~/.bashrc` and then install via `pre-commit install --hook-type pre-push`.
3+
# This runs basic linting and tests to prevent a failing pipeline
4+
repos:
5+
- repo: local
6+
hooks:
7+
- id: lint-backend
8+
name: Backend Linting
9+
entry: make lint
10+
language: system
11+
pass_filenames: false
12+
always_run: true
13+
stages: [pre-push]
14+
15+
- id: test-backend
16+
name: Backend Tests
17+
entry: make test
18+
language: system
19+
pass_filenames: false
20+
always_run: true
21+
stages: [pre-push]
22+
23+
- id: govulncheck
24+
name: Check for Vulnerabilities
25+
entry: make govulncheck
26+
language: system
27+
pass_filenames: false
28+
always_run: true
29+
stages: [pre-push]
30+
31+
- id: generate-mocks
32+
name: Generate Mocks
33+
entry: bash -c "make generate-code && git diff --exit-code"
34+
language: system
35+
pass_filenames: false
36+
always_run: true
37+
stages: [pre-push]
38+
39+
- id: generate-api-docs
40+
name: Generate API docs
41+
entry: bash -c "make api-docs && git diff --exit-code"
42+
language: system
43+
pass_filenames: false
44+
always_run: true
45+
stages: [pre-push]

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ all: generate-code api-docs lint build test
33
SWAG = github.com/swaggo/swag/cmd/swag@v1.16.4
44
MOCKERY = github.com/vektra/mockery/v3@v3.5.1
55
GOLANGCI-LINT = github.com/golangci/golangci-lint/cmd/golangci-lint@latest
6+
GOVULNCHECK = golang.org/x/vuln/cmd/govulncheck@latest
7+
8+
.PHONY: govulncheck
9+
govulncheck:
10+
go run $(GOVULNCHECK) ./...
611

712
.PHONY: help
813
help: ## show this help.

0 commit comments

Comments
 (0)