Skip to content

Cover resource_data_record with unit tests #938

Cover resource_data_record with unit tests

Cover resource_data_record with unit tests #938

name: Terraform Provider Checks
on:
pull_request:
paths-ignore:
- 'README.md'
push:
branches:
- main
paths-ignore:
- 'README.md'
jobs:
# ensure go.mod and go.sum are updated
depscheck:
name: Check Dependencies
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit
- name: Check out code into the Go module directory
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Set up Go
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
cache: true
go-version-file: 'go.mod'
id: go
- name: Run 'go mod tidy' and check for differences
run: |
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)
# ensure the code builds
build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit
- name: Check out code into the Go module directory
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Set up Go
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
cache: true
go-version-file: 'go.mod'
id: go
- name: Get dependencies
run: |
go mod download
- name: Build
run: |
go build -v .
# run tfproviderlint
# linter:
# name: Run tfproviderlint
# needs: build
# runs-on: ubuntu-latest
# steps:
# - name: Harden Runner
# uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
# with:
# egress-policy: audit
# - name: Check out code into the Go module directory
# uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
# - name: Set up Go
# uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
# with:
# cache: true
# go-version-file: 'go.mod'
# id: go
# - run: |
# go version
# - name: Install Provider Linter
# run: |
# go install github.com/bflad/tfproviderlint/cmd/tfproviderlint@latest
# - name: Run tfproviderlint
# run: |
# tfproviderlint ./...
# run unit tests
unit_test:
name: Unit Test
needs: build
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit
- name: Check out code into the Go module directory
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Set up Go
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
cache: true
go-version-file: 'go.mod'
id: go
- name: Get dependencies
run: |
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.49.0
go mod download
- name: Run unit tests
run: |
go test -v ./... -run "^TestUnit" -coverprofile=coverage.out
go tool cover -html=coverage.out -o coverage.cov.html
- name: Upload Coverage Artifacts
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: Test Coverage
path: coverage.cov.html
# run acceptance tests and linter
# acceptance_test_and_lint:
# name: Acceptance Test and Lint
# needs: build
# runs-on: ubuntu-latest
# steps:
# - name: Check out code into the Go module directory
# uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
# - name: Set up Go
# uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
# with:
# cache: true
# go-version-file: 'go.mod'
# id: go
# - name: Get dependencies
# run: |
# go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.49.0
# go mod download
# - name: Run acceptance tests and linter
# run: |
# export POWER_PLATFORM_TENANT_ID='${{ secrets.ACCEPTANCE_TESTS_ENV_TENANT_ID }}'
# export POWER_PLATFORM_CLIENT_ID='${{ secrets.ACCEPTANCE_TESTS_ENV_CLIENT_ID }}'
# export POWER_PLATFORM_SECRET='${{ secrets.ACCEPTANCE_TESTS_ENV_CLIENT_SECRET }}'
# export TF_ACC=1
# go test -v ./... -run "^TestAcc" -coverprofile=acc_coverage.out
# go tool cover -html=acc_coverage.out -o acc_coverage.cov.html
# - name: Upload Coverage Artifacts
# uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
# with:
# name: Acceptance Test Coverage
# path: acc_coverage.cov.html
# ensure docs are generated
gencheck:
name: Check Generated Docs
needs: build
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit
- name: Check out code into the Go module directory
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Set up Go
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
cache: true
go-version-file: 'go.mod'
id: go
- name: Generate docs and check for differences
run: |
go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs
tfplugindocs generate --provider-name powerplatform --rendered-provider-name "Power Platform"