Skip to content

Commit

Permalink
automatically set Git hooks in Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysd committed Jun 22, 2024
1 parent a682e35 commit 9fe5134
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
12 changes: 12 additions & 0 deletions .git-hooks/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

set -e -o pipefail

if [[ "$CI" != "" ]]; then
exit
fi

set +x

make test
make lint
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@
/man/actionlint.1.html
/playground-dist
/actionlint-workflow-ast
# IntelliJ IDE Folder
.idea/
/.git-hooks/.timestamp
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SRCS := $(filter-out %_test.go, $(wildcard *.go cmd/actionlint/*.go)) go.mod go.sum
SRCS := $(filter-out %_test.go, $(wildcard *.go cmd/actionlint/*.go)) go.mod go.sum .git-hooks/.timestamp
TESTS := $(filter %_test.go, $(wildcard *.go))
TOOL := $(filter %_test.go, $(wildcard scripts/*/*.go))
TESTDATA := $(wildcard \
Expand All @@ -15,7 +15,7 @@ GO_GEN_SRCS := scripts/generate-popular-actions/main.go \
scripts/generate-webhook-events/main.go \
scripts/generate-availability/main.go

all: clean build test
all: build test lint

.testtimestamp: $(TESTS) $(SRCS) $(TESTDATA) $(TOOL)
go test ./...
Expand Down Expand Up @@ -70,4 +70,8 @@ c clean:
rm -f ./actionlint ./.testtimestamp ./.staticchecktimestamp ./actionlint_fuzz-fuzz.zip ./man/actionlint.1 ./man/actionlint.1.html ./actionlint-workflow-ast
rm -rf ./corpus ./crashers

.git-hooks/.timestamp: .git-hooks/pre-push
[ -z "${CI}" ] && git config core.hooksPath .git-hooks || true
touch .git-hooks/.timestamp

.PHONY: all test clean build lint fuzz man bench b t c l

0 comments on commit 9fe5134

Please sign in to comment.