Skip to content

Simplified unit test to address review comments #244

Simplified unit test to address review comments

Simplified unit test to address review comments #244

Workflow file for this run

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.20']
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version: ${{ matrix.go-version }}
- name: Setup Terraform
uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 # v2.0.3
with:
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
- 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@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version-file: 'go.mod'
- name: Run linters
uses: golangci/golangci-lint-action@639cd343e1d3b897ff35927a75193d57cfcba299 # v3.6.0
with:
version: latest
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.20']
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
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@v2
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@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version-file: 'go.mod'
- name: Go Coverage
uses: gwatts/go-coverage-action@v1.3.0
with:
coverage-threshold: 18.2
cover-pkg: ./...
ignore-pattern: |
/cdp-sdk-go/
/main.go$