-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CDPCP-9522 - unit tests for Terraform Provider for CDP
- Loading branch information
Showing
6 changed files
with
771 additions
and
453 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,12 +27,6 @@ jobs: | |
terraform_version: '1.5.*' | ||
terraform_wrapper: false | ||
|
||
- name: Run linters | ||
uses: golangci/golangci-lint-action@639cd343e1d3b897ff35927a75193d57cfcba299 # v3.6.0 | ||
with: | ||
version: latest | ||
args: --timeout 3m | ||
|
||
- name: Generate | ||
run: make generate | ||
|
||
|
@@ -44,7 +38,7 @@ jobs: | |
- name: Build | ||
run: make build | ||
lint: | ||
name: 'Terraform Provider Quality Gate :: Code analysis.' | ||
name: 'Terraform Provider Quality Gate :: Code analysis' | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
@@ -59,8 +53,10 @@ jobs: | |
args: --timeout 3m | ||
|
||
test: | ||
name: 'Terraform Provider Quality Gate :: Unit test on: OS: ${{ matrix.os }} / TF: ${{ matrix.terraform }}' | ||
name: 'Terraform Provider Quality Gate :: Unit test on: OS: ${{ matrix.os }} / Go: ${{ matrix.go-version }}' | ||
needs: lint | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
runs-on: ${{ matrix.os }} | ||
timeout-minutes: 15 | ||
|
||
|
@@ -71,24 +67,34 @@ jobs: | |
- macos-latest | ||
- windows-latest | ||
- ubuntu-latest | ||
terraform: | ||
- '1.4.*' | ||
- '1.5.*' | ||
go-version: ['1.20'] | ||
|
||
steps: | ||
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 | ||
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1 | ||
with: | ||
go-version-file: 'go.mod' | ||
|
||
- name: Setup Terraform ${{ matrix.terraform }} | ||
uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 # v2.0.3 | ||
- name: Set up gotestfmt | ||
uses: gotesttools/gotestfmt-action@v2 | ||
with: | ||
terraform_version: ${{ matrix.terraform }} | ||
terraform_wrapper: false | ||
|
||
- name: Run acceptance test | ||
run: make testacc | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Run tests | ||
if: {{ matrix.os }} != 'windows-latest' | ||
run: | | ||
set -euo pipefail | ||
go test -count=1 -parallel=4 -timeout 10m -json -v ./... 2>&1 | tee TestResults-${{ matrix.os }}_${{ matrix.go-version }}.log | gotestfmt | ||
- name: Run tests | ||
if: {{ matrix.os }} == 'windows-latest' | ||
run: | | ||
go test -count=1 -parallel=4 -timeout 10m -json -v ./... 2>&1 | tee TestResults-${{ matrix.os }}_${{ matrix.go-version }}.log | gotestfmt | ||
- name: Upload test log | ||
uses: actions/upload-artifact@v2 | ||
if: always() | ||
with: | ||
name: test-log | ||
path: TestResults-${{ matrix.os }}_${{ matrix.go-version }}.log | ||
if-no-files-found: error | ||
coverage: | ||
name: 'Terraform Provider Quality Gate :: Unit test coverage.' | ||
needs: test | ||
|
@@ -101,7 +107,7 @@ jobs: | |
- name: Go Coverage | ||
uses: gwatts/[email protected] | ||
with: | ||
coverage-threshold: 6.7 # current (2023.08.07) state, should be increased - ideally up to at least 50% - as soon as possible | ||
coverage-threshold: 9.5 | ||
cover-pkg: ./... | ||
ignore-pattern: | | ||
/cdp-sdk-go/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.