diff --git a/.changelog/changelog.tmpl b/.changelog/changelog.tmpl index 2fe6be740c..0549c9d4e9 100644 --- a/.changelog/changelog.tmpl +++ b/.changelog/changelog.tmpl @@ -19,7 +19,7 @@ SECURITY: FEATURES: {{range $features | sort -}} -{{ template "note" . }} +* {{ template "note" . }} {{ end -}} {{- end -}} @@ -27,7 +27,7 @@ FEATURES: ENHANCEMENTS: {{range .NotesByType.enhancement | sort -}} -{{ template "note" .}} +* {{ template "note" .}} {{ end -}} {{- end -}} diff --git a/.github/workflows/acceptance_tests_aks.yaml b/.github/workflows/acceptance_tests_aks.yaml index aa2fd4de2e..cf852d6c87 100644 --- a/.github/workflows/acceptance_tests_aks.yaml +++ b/.github/workflows/acceptance_tests_aks.yaml @@ -20,7 +20,7 @@ on: default: 1.5.6 runTests: description: The regex passed to the -run option of `go test` - default: ".*" + default: "^TestAcc" parallelRuns: description: The maximum number of tests to run simultaneously default: 8 @@ -62,7 +62,7 @@ jobs: terraform apply -auto-approve - name: Run Tests env: - TESTARGS: -run '${{ inputs.runTests }}' + TESTARGS: -run ${{ github.event.inputs.runTests || '^TestAcc' }} ARM_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }} run: | make testacc diff --git a/.github/workflows/acceptance_tests_eks.yaml b/.github/workflows/acceptance_tests_eks.yaml index fb8dfbbd75..f1658c4ab7 100644 --- a/.github/workflows/acceptance_tests_eks.yaml +++ b/.github/workflows/acceptance_tests_eks.yaml @@ -23,7 +23,7 @@ on: default: 8 runTests: description: The regex passed to the -run option of `go test` - default: ".*" + default: "^TestAcc" terraformVersion: description: Terraform version default: 1.5.6 @@ -77,7 +77,7 @@ jobs: terraform apply -auto-approve - name: Run Acceptance Test Suite env: - TESTARGS: -run '${{ github.event.inputs.runTests }}' + TESTARGS: -run ${{ github.event.inputs.runTests || '^TestAcc' }} # Do not set TF_ACC_TERRAFORM_PATH or TF_ACC_TERRAFORM_VERSION. # In this case, the framework will search for the Terraform CLI binary based on the operating system PATH. # Eventually, it will use the one we set up. diff --git a/.github/workflows/acceptance_tests_gke.yaml b/.github/workflows/acceptance_tests_gke.yaml index 97ed9bfbed..41e79b406b 100644 --- a/.github/workflows/acceptance_tests_gke.yaml +++ b/.github/workflows/acceptance_tests_gke.yaml @@ -23,7 +23,7 @@ on: default: 8 runTests: description: The regex passed to the -run option of `go test` - default: ".*" + default: "^TestAcc" terraformVersion: description: Terraform version default: 1.5.6 @@ -77,7 +77,7 @@ jobs: terraform apply -auto-approve - name: Run Acceptance Test Suite env: - TESTARGS: -run '${{ github.event.inputs.runTests }}' + TESTARGS: -run ${{ github.event.inputs.runTests || '^TestAcc' }} # Do not set TF_ACC_TERRAFORM_PATH or TF_ACC_TERRAFORM_VERSION. # In this case, the framework will search for the Terraform CLI binary based on the operating system PATH. # Eventually, it will use the one we set up. diff --git a/.github/workflows/acceptance_tests_kind.yaml b/.github/workflows/acceptance_tests_kind.yaml index 2049d8151c..9ecf8a9f14 100644 --- a/.github/workflows/acceptance_tests_kind.yaml +++ b/.github/workflows/acceptance_tests_kind.yaml @@ -8,7 +8,7 @@ on: default: 0.20.0 # Kubernetes version: 1.27.X runTests: description: The regex passed to the -run option of `go test` - default: ".*" + default: "^TestAcc" terraformVersion: description: Terraform version default: 1.5.6 @@ -54,7 +54,7 @@ jobs: - name: Run Acceptance Test Suite env: KUBE_CONFIG_PATH: ${{ env.KUBECONFIG }} - TESTARGS: -run '${{ github.event.inputs.runTests }}' + TESTARGS: -run ${{ github.event.inputs.runTests || '^TestAcc' }} # Do not set TF_ACC_TERRAFORM_PATH or TF_ACC_TERRAFORM_VERSION. # In this case, the framework will search for the Terraform CLI binary based on the operating system PATH. # Eventually, it will use the one we set up. diff --git a/.github/workflows/test.yml b/.github/workflows/checkers-and-linters.yml similarity index 86% rename from .github/workflows/test.yml rename to .github/workflows/checkers-and-linters.yml index 62f535d9fc..e81d51a91a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/checkers-and-linters.yml @@ -1,3 +1,5 @@ +name: Essential checkers and linters + on: push: branches: @@ -5,12 +7,14 @@ on: pull_request: branches: - main + workflow_dispatch: jobs: - test: + checkers-and-linters: runs-on: ubuntu-latest steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + - name: Checkout code + uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - name: Set up Go uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1 with: @@ -22,16 +26,15 @@ jobs: with: username: ${{ secrets.RO_DOCKERHUB_USER }} password: ${{ secrets.RO_DOCKERHUB_TOKEN }} - - name: Checkout code - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - name: Install cookie run: scripts/gogetcookie.sh - - name: Run tests + - name: Run checkers run: | - make website-lint make depscheck make fmtcheck - make test make test-compile - make tests-lint make vet + - name: Run linters + run: | + make website-lint + make tests-lint diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml new file mode 100644 index 0000000000..2c1eff18b0 --- /dev/null +++ b/.github/workflows/unit-tests.yml @@ -0,0 +1,28 @@ +name: Unit Tests + +on: + push: + branches: + - main + pull_request: + branches: + - main + paths: + - 'kubernetes/*.go' + workflow_dispatch: + +jobs: + unit_test: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + - name: Set up Go + uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1 + with: + go-version-file: 'go.mod' + - name: Run unit tests + env: + TESTARGS: -count 1 + run: | + make test diff --git a/GNUmakefile b/GNUmakefile index 6e603306d6..7b5ea1f2e7 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -2,7 +2,7 @@ # This ensures docker volumes are mounted from within provider directory instead. PROVIDER_DIR := $(abspath $(lastword $(dir $(MAKEFILE_LIST)))) TEST := "$(PROVIDER_DIR)/kubernetes" -GOFMT_FILES := $$(find $(PROVIDER_DIR) -name '*.go' |grep -v vendor) +GOFMT_FILES := $$(find $(PROVIDER_DIR) -name '*.go') WEBSITE_REPO := github.com/hashicorp/terraform-website PKG_NAME := kubernetes OS_ARCH := $(shell go env GOOS)_$(shell go env GOARCH) @@ -47,10 +47,6 @@ depscheck: @go mod tidy @git diff --exit-code -- go.mod go.sum || \ (echo; echo "Unexpected difference in go.mod/go.sum files. Run 'go mod tidy' command or revert any go.mod/go.sum changes and commit."; exit 1) - @echo "==> Checking source code with go mod vendor..." - @go mod vendor - @git diff --exit-code -- vendor || \ - (echo; echo "Unexpected difference in vendor/ directory. Run 'go mod vendor' command or revert any go.mod/go.sum/vendor changes and commit."; exit 1) examples-lint: tools @echo "==> Checking _examples dir formatting..." @@ -72,12 +68,9 @@ fmtcheck: errcheck: @./scripts/errcheck.sh - -test: fmtcheck - go test $(TEST) || exit 1 - echo $(TEST) | \ - xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4 +test: fmtcheck vet + go test $(TEST) -vet=off $(TESTARGS) -parallel $(PARALLEL_RUNS) -timeout=30s testacc: fmtcheck vet TF_ACC=1 go test $(TEST) -v -vet=off $(TESTARGS) -parallel $(PARALLEL_RUNS) -timeout 3h @@ -113,8 +106,8 @@ tools: go install github.com/hashicorp/go-changelog/cmd/changelog-entry@latest vet: - @echo "go vet ." - @go vet $$(go list ./... | grep -v vendor/) ; if [ $$? -eq 1 ]; then \ + @echo "go vet ./..." + @go vet $$(go list ./...) ; if [ $$? -eq 1 ]; then \ echo ""; \ echo "Vet found suspicious constructs. Please check the reported constructs"; \ echo "and fix them if necessary before submitting the code for review."; \