CDPCP-13608 Modify dw acceptance tests (#195) #670
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
name: Test | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
strategy: | |
matrix: | |
go-version: ['1.21', '1.22'] | |
steps: | |
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 | |
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 | |
with: | |
go-version: ${{ matrix.go-version }} | |
cache: false | |
- name: Setup Terraform | |
uses: hashicorp/setup-terraform@97f030cf6dc0b4f5e0da352c7bca9cca34579800 # v3.1.0 | |
with: | |
terraform_version: '1.5.*' | |
terraform_wrapper: false | |
- name: Run linters | |
uses: golangci/[email protected] | |
with: | |
args: --timeout 3m | |
- name: Generate | |
run: make generate | |
- name: Confirm no diff | |
run: | | |
git diff --compact-summary --exit-code || \ | |
(echo "*** Unexpected differences after code generation. Run 'make generate' and commit."; exit 1) | |
- name: Build | |
run: make build | |
lint: | |
name: 'Terraform Provider Quality Gate :: Code analysis' | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 | |
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 | |
with: | |
go-version-file: 'go.mod' | |
- name: Run linters | |
uses: golangci/golangci-lint-action@3cfe3a4abbb849e10058ce4af15d205b6da42804 # v4.0.0 | |
with: | |
args: --timeout 3m | |
test: | |
name: 'Terraform Provider Quality Gate :: Unit test on: OS: ${{ matrix.os }} / Go: ${{ matrix.go-version }}' | |
needs: lint | |
runs-on: ${{ matrix.os }} | |
timeout-minutes: 15 | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- macos-latest | |
- windows-latest | |
- ubuntu-latest | |
go-version: ['1.21', '1.22'] | |
steps: | |
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 | |
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 | |
with: | |
go-version-file: 'go.mod' | |
- name: Run tests | |
run: | | |
go test -count=1 -parallel=4 -timeout 10m -json -v ./... 2>&1 | tee TestResults-${{ matrix.os }}_${{ matrix.go-version }}.log | |
- name: Upload test log | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: TestResults-${{ matrix.os }}_${{ matrix.go-version }}.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 | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 | |
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 | |
with: | |
go-version-file: 'go.mod' | |
- name: Go Coverage | |
uses: gwatts/[email protected] | |
with: | |
coverage-threshold: 32.0 | |
cover-pkg: ./... | |
ignore-pattern: | | |
/cdp-sdk-go/ | |
/main.go$ | |
deadcode: | |
name: 'Terraform Provider Quality Gate :: Dead code analysis' | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 | |
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 | |
with: | |
go-version-file: 'go.mod' | |
- name: Run deadcode | |
run: go install golang.org/x/tools/cmd/deadcode@latest && sh ./deadcode-check.sh |