powerplatform_user support environment without dataverse #481
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: Terraform Provider Tests | |
on: | |
workflow_dispatch: | |
schedule: | |
# run at 4 AM UTC every day | |
- cron: '0 4 * * *' | |
pull_request: | |
push: | |
branches: | |
- main | |
concurrency: | |
group: acceptancetests | |
cancel-in-progress: false | |
permissions: | |
id-token: write # This is required for requesting the JWT | |
contents: read # This is required for actions/checkout | |
jobs: | |
should_run: | |
runs-on: ubuntu-latest | |
if: github.event_name != 'pull_request' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'run-acceptance-tests')) | |
outputs: | |
acceptance_tests: ${{ steps.set_acceptance_tests.outputs.acceptance_tests }} | |
steps: | |
- id: set_acceptance_tests | |
name: Only run acceptance tests if necessary | |
run: echo "::set-output name=acceptance_tests::true" | |
# ensure go.mod and go.sum are updated | |
depscheck: | |
name: Check Dependencies | |
runs-on: ubuntu-latest | |
needs: should_run | |
if: ${{ needs.should_run.outputs.acceptance_tests == 'true' }} | |
steps: | |
- name: Harden Runner | |
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.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@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 | |
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 | |
needs: should_run | |
if: ${{ needs.should_run.outputs.acceptance_tests == 'true' }} | |
timeout-minutes: 5 | |
steps: | |
- name: Harden Runner | |
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.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@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 | |
with: | |
cache: true | |
go-version-file: 'go.mod' | |
id: go | |
- name: Get dependencies | |
run: | | |
go mod download | |
- name: Build | |
run: | | |
go build -v . | |
tests: | |
name: Running Test | |
needs: [build, should_run] | |
if: ${{ needs.should_run.outputs.acceptance_tests == 'true' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Harden Runner | |
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.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@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 | |
with: | |
cache: true | |
go-version-file: 'go.mod' | |
id: go | |
- name: Get dependencies | |
run: | | |
go install github.com/golangci/golangci-lint/cmd/[email protected] | |
go mod download | |
- name: "Set up Terraform" | |
uses: hashicorp/setup-terraform@v3 | |
- name: Install Power Platform Tools | |
if: success() || failure() | |
uses: microsoft/powerplatform-actions/actions-install@v1 | |
- name: Environments cleanup | |
if: success() || failure() | |
shell: pwsh | |
run: | | |
dotnet tool install --global Microsoft.PowerApps.CLI.Tool | |
pac auth create --githubFederated --tenant ${{ secrets.ACCEPTANCE_TESTS_ENV_TENANT_ID }} --applicationId ${{ secrets.ACCEPTANCE_TESTS_ENV_CLIENT_ID }} | |
$environmentsList = (pac admin list --name "TestAcc" --json | ConvertFrom-Json) | |
$environmentsList | ForEach-Object -Parallel { | |
if ($_.DisplayName.StartsWith("TestAcc")){ | |
Write-Output $_.DisplayName | |
pac admin delete -env $_.EnvironmentID | |
} | |
} -ThrottleLimit 15 | |
- name: Run tests | |
env: | |
TF_LOG: WARN | |
TF_ACC: 1 | |
POWER_PLATFORM_USE_OIDC: true | |
POWER_PLATFORM_TENANT_ID: ${{ secrets.ACCEPTANCE_TESTS_ENV_TENANT_ID }} | |
POWER_PLATFORM_CLIENT_ID: ${{ secrets.ACCEPTANCE_TESTS_ENV_CLIENT_ID }} | |
ARM_USE_OIDC: true | |
ARM_CLIENT_ID: ${{ secrets.ACCEPTANCE_TESTS_ENV_CLIENT_ID }} | |
ARM_TENANT_ID: ${{ secrets.ACCEPTANCE_TESTS_ENV_TENANT_ID }} | |
ARM_SUBSCRIPTION_ID: ${{ secrets.ACCEPTANCE_TESTS_ENV_SUBSCRIPTION_ID }} | |
run: | | |
go clean -testcache | |
go test -p 3 -v ./... -run ^TestAccUserResource_Validate_Create_Environment_User_With_Dataverse$ -coverprofile=test-coverage.out -timeout 300m | |
go tool cover -html=test-coverage.out -o test-coverage.cov.html | |
- name: Upload Coverage Artifacts | |
if: success() || failure() | |
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | |
with: | |
name: Test Coverage | |
path: test-coverage.cov.html | |
- name: Upload results to Codecov | |
uses: codecov/codecov-action@v5 | |
with: | |
file: test-coverage.out | |
token: ${{ secrets.CODECOV_TOKEN }} |