Skip to content

Commit ae7f759

Browse files
authored
Validate plugin from the packer-sdc plugin-validate command (#54)
* install packer-sdc at the version from deps * use make plugin-check in releaser * goreleaser: run plugin-check before release
1 parent c14a0ec commit ae7f759

2 files changed

Lines changed: 20 additions & 21 deletions

File tree

.goreleaser.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,13 @@ before:
1010
# As part of the release doc files are included as a separate deliverable for
1111
# consumption by Packer.io. To include a separate docs.zip uncomment the following command.
1212
- make ci-release-docs
13+
# Check plugin compatibility with required version of the Packer SDK
14+
- make plugin-check
1315
builds:
1416
# A separated build to run the packer-plugins-check only once for a linux_amd64 binary
1517
-
1618
id: plugin-check
1719
mod_timestamp: '{{ .CommitTimestamp }}'
18-
hooks:
19-
post:
20-
# This will check plugin compatibility against latest version of Packer
21-
- cmd: |
22-
go install github.com/hashicorp/packer/cmd/packer-plugins-check@latest &&
23-
packer-plugins-check -load={{ .Name }}
24-
dir: "{{ dir .Path}}"
2520
flags:
2621
- -trimpath #removes all file system paths from the compiled executable
2722
ldflags:

GNUmakefile

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,34 @@ BINARY=packer-plugin-${NAME}
33

44
COUNT?=1
55
TEST?=$(shell go list ./...)
6+
HASHICORP_PACKER_PLUGIN_SDK_VERSION?=$(shell go list -m github.com/hashicorp/packer-plugin-sdk | cut -d " " -f2)
67

78
.PHONY: dev
89

910
build:
1011
@go build -o ${BINARY}
1112

12-
generate:
13-
@go install github.com/hashicorp/packer-plugin-sdk/cmd/packer-sdc@latest
14-
@go generate -v ./...
15-
16-
ci-release-docs:
17-
@go install github.com/hashicorp/packer-plugin-sdk/cmd/packer-sdc@latest
18-
@packer-sdc renderdocs -src docs -partials docs-partials/ -dst docs/
19-
@/bin/sh -c "[ -d docs ] && zip -r docs.zip docs/"
20-
2113
dev: build
2214
@mkdir -p ~/.packer.d/plugins/
2315
@mv ${BINARY} ~/.packer.d/plugins/${BINARY}
2416

25-
run-example: dev
26-
@packer build ./example
27-
2817
test:
29-
@go test -count $(COUNT) $(TEST) -timeout=3m
18+
@go test -race -count $(COUNT) $(TEST) -timeout=3m
19+
20+
install-packer-sdc: ## Install packer sofware development command
21+
@go install github.com/hashicorp/packer-plugin-sdk/cmd/packer-sdc@${HASHICORP_PACKER_PLUGIN_SDK_VERSION}
22+
23+
ci-release-docs: install-packer-sdc
24+
@packer-sdc renderdocs -src docs -partials docs-partials/ -dst docs/
25+
@/bin/sh -c "[ -d docs ] && zip -r docs.zip docs/"
26+
27+
plugin-check: install-packer-sdc build
28+
@packer-sdc plugin-check ${BINARY}
3029

3130
testacc: dev
32-
@PACKER_ACC=1 go test -count $(COUNT) -v $(TEST) -timeout=120m
31+
@PACKER_ACC=1 go test -count $(COUNT) -v $(TEST) -timeout=120m
32+
33+
generate: install-packer-sdc
34+
@go generate ./...
35+
packer-sdc renderdocs -src ./docs -dst ./.docs -partials ./docs-partials
36+
# checkout the .docs folder for a preview of the docs

0 commit comments

Comments
 (0)