@@ -5,37 +5,50 @@ HASHICORP_PACKER_PLUGIN_SDK_VERSION?=$(shell go list -m github.com/hashicorp/pac
5
5
COUNT? =1
6
6
TEST? =$(shell go list ./...)
7
7
8
- .PHONY : dev
8
+ prep : phony
9
+ go install honnef.co/go/tools/cmd/staticcheck@latest
9
10
10
- build :
11
+ build : phony
11
12
@go build -o ${BINARY}
12
13
13
- dev : build
14
+ dev : phony build
14
15
@mkdir -p ~ /.packer.d/plugins/
15
16
@mv ${BINARY} ~ /.packer.d/plugins/${BINARY}
16
17
17
- run-example : dev
18
+ run-example : phony dev
18
19
@packer build ./example
19
20
20
- test :
21
- @go test -race -count $(COUNT ) $(TEST ) -timeout=3m
21
+ test : phony
22
+ go mod tidy
23
+ go fmt ./...
24
+ go vet ./...
25
+ staticcheck -checks=" all" -tests ./...
26
+ go test -race -count $(COUNT ) $(TEST ) -timeout=3m
22
27
23
28
# the acceptance tests have a weird habit of messing up the tty (e.g. turning off echo mode, so
24
29
# terminal stops showing what you type). If this happens to you, run `reset` or `stty sane` to fix.
25
- testacc : dev
30
+ testacc : phony dev
26
31
@PACKER_ACC=1 go test -count $(COUNT ) -v $(TEST ) -timeout=120m
27
32
28
- install-packer-sdc : # # Install packer software development command
33
+ install-packer-sdc : phony # # Install packer software development command
29
34
@go install github.com/hashicorp/packer-plugin-sdk/cmd/packer-sdc@${HASHICORP_PACKER_PLUGIN_SDK_VERSION}
30
35
31
- ci-release-docs : install-packer-sdc
36
+ ci-release-docs : phony install-packer-sdc
32
37
@packer-sdc renderdocs -src docs -partials docs-partials/ -dst docs/
33
38
@/bin/sh -c " [ -d docs ] && zip -r docs.zip docs/"
34
39
35
- plugin-check : install-packer-sdc build
40
+ plugin-check : phony install-packer-sdc build
36
41
@packer-sdc plugin-check ${BINARY}
37
42
38
- generate : install-packer-sdc
43
+ generate : phony install-packer-sdc
39
44
@go generate -v ./...
40
45
packer-sdc renderdocs -src ./docs -dst ./.docs -partials ./docs-partials
41
46
# see the .docs folder for a preview of the docs
47
+
48
+ # instead of listing every target in .PHONY, we create one
49
+ # 'phony' target which all the other targets depend on.
50
+ # This saves me from having to remember to add each new target
51
+ # to the .PHONY list, and is a little cleaner than putting
52
+ # `.PHONY: target` before each target
53
+ .PHONY : phony
54
+ phony :
0 commit comments