Skip to content

Commit

Permalink
Standardize Linode DX Makefile; cleanup duplicated integration tests (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
zliang-akamai authored Feb 26, 2024
1 parent 1f6fcae commit d8759cc
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 173 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ run:
concurrency: 4

# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 10m
timeout: 15m

# exit code when at least one issue was found, default is 1
issues-exit-code: 1
Expand Down
58 changes: 42 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,47 +1,73 @@
NAME=linode
BINARY=packer-plugin-${NAME}
GOFMT_FILES?=$$(find . -name '*.go')
COUNT?=1
TEST?=$(shell go list ./builder/...)
UNIT_TEST_TARGET?=$(shell go list ./builder/...)
HASHICORP_PACKER_PLUGIN_SDK_VERSION?=$(shell go list -m github.com/hashicorp/packer-plugin-sdk | cut -d " " -f2)
PACKER_SDC_REPO ?= github.com/hashicorp/packer-plugin-sdk/cmd/packer-sdc
.DEFAULT_GOAL = dev

.PHONY: dev

build: fmtcheck
@go build -o ${BINARY}
# install is an alias of dev
.PHONY: install
install: dev

.PHONY: dev
dev: build
@mkdir -p ~/.packer.d/plugins/
@mv ${BINARY} ~/.packer.d/plugins/${BINARY}

test: dev fmtcheck
@PACKER_ACC=1 go test -count $(COUNT) ./... -v -timeout=100m
.PHONY: build
build: fmtcheck
@go build -o ${BINARY}

.PHONY: test
test: dev fmtcheck acctest

.PHONY: install-packer-sdc
install-packer-sdc: ## Install packer sofware development command
@go install github.com/hashicorp/packer-plugin-sdk/cmd/packer-sdc@${HASHICORP_PACKER_PLUGIN_SDK_VERSION}
@go install ${PACKER_SDC_REPO}@${HASHICORP_PACKER_PLUGIN_SDK_VERSION}

.PHONY: plugin-check
plugin-check: install-packer-sdc build
@packer-sdc plugin-check ${BINARY}

.PHONY: unit-test
unit-test: dev
go test -count $(COUNT) -v $(TEST) -timeout=10m
@go test -count $(COUNT) -v $(UNIT_TEST_TARGET) -timeout=10m

int-test: dev
@go test -v test/integration/e2e_test.go
# int-test is an alias of acctest
.PHONY: int-test
int-test: acctest

.PHONY: acctest
acctest: dev
@PACKER_ACC=1 go test -count $(COUNT) ./... -v -timeout=100m

.PHONY: generate
generate: install-packer-sdc
@go generate ./...
@rm -rf .docs
@packer-sdc renderdocs -src "docs" -partials docs-partials/ -dst ".docs/"
@./.web-docs/scripts/compile-to-webdocs.sh "." ".docs" ".web-docs" "linode"
@rm -r ".docs"

.PHONY: fmtcheck
fmtcheck:
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"

.PHONY: lint
lint: fmtcheck
golangci-lint run --timeout 15m0s
@golangci-lint run

fmt:
gofmt -w $(GOFMT_FILES)
gofumpt -w .
.PHONY: format
format:
@gofumpt -w .

.PHONY: deps
deps: install-packer-sdc
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
@go install mvdan.cc/gofumpt@latest

.PHONY: clean
clean:
@rm -rf .docs
@rm -rf ./packer-plugin-linode
4 changes: 2 additions & 2 deletions builder/linode/builder_acc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ const testBuilderAccBasic = `
{
"builders": [{
"type": "linode",
"region": "us-ord",
"region": "us-mia",
"instance_type": "g6-nanode-1",
"image": "linode/debian11",
"image": "linode/debian12",
"ssh_username": "root",
"cloud_init": true
}]
Expand Down
135 changes: 0 additions & 135 deletions test/integration/e2e_test.go

This file was deleted.

19 changes: 0 additions & 19 deletions test/integration/template/test_image_template.json

This file was deleted.

0 comments on commit d8759cc

Please sign in to comment.