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

Split GH workflows #2357

Merged
merged 11 commits into from
Dec 6, 2023
4 changes: 2 additions & 2 deletions .changelog/changelog.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ SECURITY:
FEATURES:

{{range $features | sort -}}
{{ template "note" . }}
* {{ template "note" . }}
arybolovlev marked this conversation as resolved.
Show resolved Hide resolved
{{ end -}}
{{- end -}}

{{- if .NotesByType.enhancement }}
ENHANCEMENTS:

{{range .NotesByType.enhancement | sort -}}
{{ template "note" .}}
* {{ template "note" .}}
{{ end -}}
{{- end -}}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/acceptance_tests_aks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/acceptance_tests_eks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/acceptance_tests_gke.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/acceptance_tests_kind.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
name: Essential checkers and linters

on:
push:
branches:
- main
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:
Expand All @@ -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
28 changes: 28 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -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
17 changes: 5 additions & 12 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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..."
Expand All @@ -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
Expand Down Expand Up @@ -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."; \
Expand Down