Skip to content

Commit

Permalink
Add Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
pellared committed Apr 16, 2024
1 parent bf8aa2d commit 51ce2e6
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ jobs:
with:
fail: true

make:
runs-on: ubuntu-22.04
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
go-version: '1.22'
check-latest: true
- run: make ci

compatibility-test:
strategy:
matrix:
Expand Down
51 changes: 51 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Copyright Splunk Inc.
# SPDX-License-Identifier: Apache-2.0

GO = go

SHELL := /bin/bash
.DEFAULT_GOAL := precommit

.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

define print-target
@printf "Executing target: \033[36m$@\033[0m\n"
endef

.PHONY: precommit
precommit: ## build pipeline
precommit: mod gen test

.PHONY: ci
ci: ## CI build pipeline
ci: precommit check-clean-work-tree

.PHONY: mod
mod: ## go mod tidy
$(call print-target)
$(GO) mod tidy

.PHONY: gen
gen: ## go generate
$(call print-target)
$(GO) generate ./...

.PHONY: test
test: ## go test
$(call print-target)
$(GO) test -race -covermode=atomic -coverprofile=coverage.out -coverpkg=./... ./...

.PHONY: check-clean-work-tree
check-clean-work-tree: ## git diff
$(call print-target)
if ! git diff --quiet; then \
echo; \
echo 'Working tree is not clean, did you forget to run "make precommit"?'; \
echo; \
git status; \
exit 1; \
fi


0 comments on commit 51ce2e6

Please sign in to comment.