Skip to content

Commit

Permalink
chore(ci): cleanup and update project configs
Browse files Browse the repository at this point in the history
  • Loading branch information
bpg committed Sep 7, 2023
1 parent 79eafe4 commit 7dc8e27
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 31 deletions.
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Please mark the following items with an [x] if they apply to your PR.
Leave the [ ] if they are not applicable, or if you have not completed the item.
- [ ] I have added / updated documentation in `/docs` for any user-facing features or additions.
- [ ] I have added / updated templates in `/examples` for any new or updated resources / data sources.
- [ ] I have ran `make examples` to verify that the change works as expected.
- [ ] I have added / updated templates in `/example` for any new or updated resources / data sources.
- [ ] I have ran `make example` to verify that the change works as expected.

<!--- Please keep this note for the community --->
### Community Note
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/semgrep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ on:
push:
branches:
- main
- master
paths:
- .github/workflows/semgrep.yml
schedule:
Expand All @@ -13,7 +12,7 @@ name: Semgrep
jobs:
semgrep:
name: Scan
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
env:
SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }}
container:
Expand Down
26 changes: 1 addition & 25 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,10 @@ jobs:
- name: Build
run: go vet . && go build -v .

# Very noisy, temporarily disabled
# - name: Run coverage
# run: go test -race -coverprofile=coverage.out -covermode=atomic ./...
#
# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v3

# run acceptance tests in a matrix with Terraform core versions
test:
name: Matrix Test
name: Unit Tests
needs: build
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
# list whatever Terraform versions here you would like to support
terraform:
- '1.2.9'
- '1.3.8'
- '1.4.2'
steps:

- name: Check out code into the Go module directory
Expand All @@ -65,13 +48,6 @@ jobs:
- name: Get dependencies
run: go mod download

# - name: TF acceptance tests
# timeout-minutes: 10
# env:
# TF_ACC: "1"
# TF_ACC_TERRAFORM_VERSION: ${{ matrix.terraform }}
# run: go test -v -cover ./...

- name: Unit tests
timeout-minutes: 10
run: go test -v -cover ./...
Expand Down
22 changes: 20 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,44 @@ TERRAFORM_PLUGIN_EXECUTABLE_EXAMPLE=$(TERRAFORM_PLUGIN_OUTPUT_DIRECTORY)/$(NAME)

default: build

.PHONY: clean
clean:
rm -rf ./dist
rm -rf ./cache
rm -rf ./build

.PHONY: build
build:
mkdir -p "$(TERRAFORM_PLUGIN_OUTPUT_DIRECTORY)"
rm -f "$(TERRAFORM_PLUGIN_EXECUTABLE)"
go build -o "$(TERRAFORM_PLUGIN_EXECUTABLE)"

.PHONY: example
example: example-build example-init example-apply example-destroy

.PHONY: example-apply
example-apply:
export TF_CLI_CONFIG_FILE="$(shell pwd -P)/example.tfrc" \
&& export TF_DISABLE_CHECKPOINT="true" \
&& export TF_PLUGIN_CACHE_DIR="$(TERRAFORM_PLUGIN_CACHE_DIRECTORY)" \
&& cd ./example \
&& terraform apply -auto-approve

.PHONY: example-build
example-build:
mkdir -p "$(TERRAFORM_PLUGIN_OUTPUT_DIRECTORY)"
rm -rf "$(TERRAFORM_PLUGIN_EXECUTABLE_EXAMPLE)"
go build -o "$(TERRAFORM_PLUGIN_EXECUTABLE_EXAMPLE)"

.PHONY: example-destroy
example-destroy:
export TF_CLI_CONFIG_FILE="$(shell pwd -P)/example.tfrc" \
&& export TF_DISABLE_CHECKPOINT="true" \
&& export TF_PLUGIN_CACHE_DIR="$(TERRAFORM_PLUGIN_CACHE_DIRECTORY)" \
&& cd ./example \
&& terraform destroy -auto-approve

.PHONY: example-init
example-init:
export TF_CLI_CONFIG_FILE="$(shell pwd -P)/example.tfrc" \
&& export TF_DISABLE_CHECKPOINT="true" \
Expand All @@ -58,40 +65,51 @@ example-init:
&& rm -f .terraform.lock.hcl \
&& terraform init

.PHONY: example-plan
example-plan:
export TF_CLI_CONFIG_FILE="$(shell pwd -P)/example.tfrc" \
&& export TF_DISABLE_CHECKPOINT="true" \
&& export TF_PLUGIN_CACHE_DIR="$(TERRAFORM_PLUGIN_CACHE_DIRECTORY)" \
&& cd ./example \
&& terraform plan

.PHONY: fmt
fmt:
gofmt -s -w $(GOFMT_FILES)

.PHONY: init
init:
go get ./...

.PHONY: test
test:
go test ./...

.PHONY: testacc
testacc:
TF_ACC=1 go test ./...

.PHONY: lint
lint:
go run -modfile=tools/go.mod github.com/golangci/golangci-lint/cmd/golangci-lint run --fix

.PHONY: release-build
release-build:
go run -modfile=tools/go.mod github.com/goreleaser/goreleaser build --clean --skip-validate

.PHONY: docs
docs:
@mkdir -p ./build/docs-gen
@cd ./tools && go generate tools.go

.PHONY: targets
targets: $(TARGETS)

.PHONY: $(TARGETS)
$(TARGETS):
GOOS=$@ GOARCH=amd64 CGO_ENABLED=0 go build \
-o "dist/$@/$(NAME)_v$(VERSION)-custom" \
-a -ldflags '-extldflags "-static"'
zip \
-j "dist/$(NAME)_v$(VERSION)-custom_$@_amd64.zip" \
"dist/$@/$(NAME)_v$(VERSION)-custom"

.PHONY: clean build example example-apply example-destroy example-init example-plan fmt init targets test docs $(TARGETS)

0 comments on commit 7dc8e27

Please sign in to comment.