Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): cleanup and update project configs #549

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

**Additional context**
Add any other context about the problem here.
- Single or clustered Proxmox:

Check notice on line 31 in .github/ISSUE_TEMPLATE/bug_report.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

.github/ISSUE_TEMPLATE/bug_report.md#L31

Lists should be surrounded by blank lines

Check warning on line 31 in .github/ISSUE_TEMPLATE/bug_report.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

.github/ISSUE_TEMPLATE/bug_report.md#L31

[list-item-indent] Incorrect list-item indent: add 2 spaces
- Provider version (ideally it should be the latest version):
- Terraform version:
- OS (where you run Terraform from):
Expand Down
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)