🧪 Test #201
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
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | |
--- | |
# Terraform Provider testing workflow. | |
name: 🧪 Test | |
# This GitHub action runs your tests for each pull request. | |
# Optionally, you can turn it on using a schedule for regular testing. | |
on: | |
pull_request: | |
branches: | |
- main | |
types: | |
- opened | |
- synchronize | |
schedule: | |
- cron: "0 2 * * *" | |
workflow_dispatch: | |
concurrency: | |
group: ${{ format('{0}-{1}-{2}-{3}-{4}', github.workflow, github.event_name, github.ref, github.base_ref || null, github.head_ref || null) }} | |
cancel-in-progress: true | |
env: | |
FABRIC_TESTACC_WELLKNOWN: ${{ vars.FABRIC_TESTACC_WELLKNOWN }} | |
FABRIC_TIMEOUT: 20m | |
permissions: | |
id-token: write | |
contents: read | |
pull-requests: read | |
jobs: | |
test-auth-spn: | |
name: 🔐 Test Auth (SPN ${{ matrix.method }}) | |
environment: | |
name: development | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
method: [oidc, certificate, secret] | |
steps: | |
- name: ⤵️ Checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: ✔️ Check for changes | |
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 | |
id: changes_check | |
with: | |
filters: | | |
changes: | |
- '**.go' | |
- 'go.mod' | |
- 'go.sum' | |
- '.github/workflows/test.yml' | |
- name: 🚧 Setup Go | |
if: steps.changes_check.outputs.changes == 'true' | |
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 | |
with: | |
go-version-file: go.mod | |
cache: true | |
- name: 🚧 Setup Task | |
if: steps.changes_check.outputs.changes == 'true' | |
uses: arduino/setup-task@b91d5d2c96a56797b48ac1e0e89220bf64044611 # v2.0.0 | |
with: | |
repo-token: ${{ github.token }} | |
- name: ⚙️ Configure TF dev overrides | |
if: steps.changes_check.outputs.changes == 'true' | |
run: .devcontainer/features/tfprovider-local-dev/install.sh | |
env: | |
PROVIDERNAME: microsoft/fabric | |
- name: 🚧 Setup Terraform | |
if: steps.changes_check.outputs.changes == 'true' | |
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2 | |
with: | |
terraform_wrapper: false | |
- name: 🔨 Setup Test tools | |
if: steps.changes_check.outputs.changes == 'true' | |
run: task test:tools | |
- name: 🧪 Run acceptance tests (OIDC) | |
if: ${{ matrix.method == 'oidc' && steps.changes_check.outputs.changes == 'true' }} | |
run: task testacc -- WorkspaceResource_CRUD | |
env: | |
FABRIC_USE_OIDC: true | |
FABRIC_TENANT_ID: ${{ secrets.TESTACC_TENANT_ID }} | |
FABRIC_CLIENT_ID: ${{ secrets.TESTACC_SPN_OIDC_CLIENT_ID }} | |
- name: 🧪 Run acceptance tests (Certificate) | |
if: ${{ matrix.method == 'certificate' && steps.changes_check.outputs.changes == 'true' }} | |
run: task testacc -- WorkspaceResource_CRUD | |
env: | |
FABRIC_TENANT_ID: ${{ secrets.TESTACC_TENANT_ID }} | |
FABRIC_CLIENT_ID: ${{ secrets.TESTACC_SPN_CERT_CLIENT_ID }} | |
FABRIC_CLIENT_CERTIFICATE: ${{ secrets.TESTACC_SPN_CERT_CLIENT_CERTIFICATE }} | |
FABRIC_CLIENT_CERTIFICATE_PASSWORD: ${{ secrets.TESTACC_SPN_CERT_CLIENT_CERTIFICATE_PASSWORD }} | |
- name: 🧪 Run acceptance tests (Secret) | |
if: ${{ matrix.method == 'secret' && steps.changes_check.outputs.changes == 'true' }} | |
run: task testacc -- WorkspaceResource_CRUD | |
env: | |
FABRIC_TENANT_ID: ${{ secrets.TESTACC_TENANT_ID }} | |
FABRIC_CLIENT_ID: ${{ secrets.TESTACC_SPN_SECRET_CLIENT_ID }} | |
FABRIC_CLIENT_SECRET: ${{ secrets.TESTACC_SPN_SECRET_CLIENT_SECRET }} | |
# test-auth-msi: | |
# name: 🔐 Test Auth (MSI ${{ matrix.method }}) | |
# environment: | |
# name: development | |
# runs-on: [self-hosted, containerjob] | |
# strategy: | |
# fail-fast: false | |
# matrix: | |
# method: [system, user] | |
# steps: | |
# - name: ⤵️ Checkout | |
# uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
# - name: ✔️ Check for changes | |
# uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 | |
# id: changes_check | |
# with: | |
# filters: | | |
# changes: | |
# - '**.go' | |
# - 'go.mod' | |
# - 'go.sum' | |
# - name: 🚧 Setup Go | |
# if: steps.changes_check.outputs.changes == 'true' | |
# uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 | |
# with: | |
# go-version-file: go.mod | |
# cache: true | |
# - name: 🚧 Setup Task | |
# if: steps.changes_check.outputs.changes == 'true' | |
# uses: arduino/setup-task@b91d5d2c96a56797b48ac1e0e89220bf64044611 # v2.0.0 | |
# with: | |
# repo-token: ${{ github.token }} | |
# - name: ⚙️ Configure TF dev overrides | |
# if: steps.changes_check.outputs.changes == 'true' | |
# run: .devcontainer/features/tfprovider-local-dev/install.sh | |
# env: | |
# PROVIDERNAME: microsoft/fabric | |
# - name: 🚧 Setup Terraform | |
# if: steps.changes_check.outputs.changes == 'true' | |
# uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2 | |
# with: | |
# terraform_wrapper: false | |
# - name: 🔨 Setup Test tools | |
# if: steps.changes_check.outputs.changes == 'true' | |
# run: task test:tools | |
# - name: 🧪 Run acceptance tests (User Assigned) | |
# if: ${{ matrix.method == 'user' && steps.changes_check.outputs.changes == 'true' }} | |
# run: task testacc -- WorkspaceResource_CRUD | |
# env: | |
# FABRIC_USE_MSI: true | |
# FABRIC_TENANT_ID: ${{ secrets.TESTACC_TENANT_ID }} | |
# FABRIC_CLIENT_ID: ${{ secrets.TESTACC_MSI_CLIENT_ID }} | |
# - name: 🧪 Run acceptance tests (System Assigned) | |
# if: ${{ matrix.method == 'system' && steps.changes_check.outputs.changes == 'true' }} | |
# run: task testacc -- WorkspaceResource_CRUD | |
# env: | |
# FABRIC_USE_MSI: true | |
# FABRIC_TENANT_ID: ${{ secrets.TESTACC_TENANT_ID }} | |
checkbuild: | |
name: 🏗️ Check Build | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
permissions: | |
contents: read | |
pull-requests: read | |
steps: | |
- name: ⤵️ Checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: ✔️ Check for changes | |
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 | |
id: changes_check | |
with: | |
filters: | | |
changes: | |
- '**.go' | |
- 'go.mod' | |
- 'go.sum' | |
- '.github/workflows/test.yml' | |
- name: 🚧 Setup Go | |
if: steps.changes_check.outputs.changes == 'true' | |
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 | |
with: | |
go-version-file: go.mod | |
cache: true | |
- name: 🚧 Setup Task | |
if: steps.changes_check.outputs.changes == 'true' | |
uses: arduino/setup-task@b91d5d2c96a56797b48ac1e0e89220bf64044611 # v2.0.0 | |
with: | |
repo-token: ${{ github.token }} | |
- name: 🔀 Get dependencies | |
if: steps.changes_check.outputs.changes == 'true' | |
run: task deps | |
- name: 🔀 Check for differences | |
if: steps.changes_check.outputs.changes == 'true' | |
run: | | |
git diff --exit-code -- go.mod go.sum || \ | |
(echo; echo "Unexpected difference in go.mod/go.sum files. Run 'task deps' command or revert any go.mod/go.sum changes and commit."; git diff --exit-code) | |
- name: ✔️ Run GoVulnCheck | |
if: steps.changes_check.outputs.changes == 'true' | |
run: | | |
task install:govulncheck | |
task govulncheck | |
- name: ✔️ Run Go linters | |
if: steps.changes_check.outputs.changes == 'true' | |
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1 | |
with: | |
version: latest | |
only-new-issues: true | |
skip-cache: true | |
skip-save-cache: true | |
args: --out-format=github-actions | |
- name: 🚧 Setup Terraform | |
if: steps.changes_check.outputs.changes == 'true' | |
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2 | |
with: | |
terraform_wrapper: false | |
- name: ✔️ Run tfproviderlintx | |
if: steps.changes_check.outputs.changes == 'true' | |
run: | | |
task install:tfproviderlintx | |
task tfproviderlintx | |
- name: ✔️ Run Terraform linters | |
if: steps.changes_check.outputs.changes == 'true' | |
run: | | |
task lint:tf-tools | |
task lint:tf | |
- name: 🔀 Check for differences | |
run: | | |
git diff --compact-summary --exit-code || \ | |
(echo; echo "Unexpected difference in code. Run 'task lint' command and commit."; git diff --exit-code) | |
- name: ✔️ Validate GoReleaser config | |
uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf # v6.1.0 | |
with: | |
version: "~> v2" | |
args: check --verbose | |
- name: 🏗️ Build snapshot binaries | |
if: steps.changes_check.outputs.changes == 'true' | |
uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf # v6.1.0 | |
with: | |
version: "~> v2" | |
args: build --snapshot --clean --verbose | |
checkdocs: | |
name: 📃 Check Docs | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- name: ⤵️ Checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: 🚧 Setup Go | |
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 | |
with: | |
go-version-file: go.mod | |
cache: true | |
- name: 🚧 Setup Task | |
uses: arduino/setup-task@b91d5d2c96a56797b48ac1e0e89220bf64044611 # v2.0.0 | |
with: | |
repo-token: ${{ github.token }} | |
- name: 🔨 Setup tools | |
run: | | |
task install:tfplugindocs | |
task install:markdownlint | |
task install:copywrite | |
- name: ✔️ Run Files linters | |
run: task lint:files | |
- name: 🔀 Check for differences | |
run: | | |
git diff --compact-summary --exit-code || \ | |
(echo; echo "Unexpected difference. Run 'task lint:files' command and commit."; git diff --exit-code) | |
- name: 📃 Generate docs | |
run: task docs | |
- name: 🔀 Check for differences | |
run: | | |
git diff --compact-summary --exit-code || \ | |
(echo; echo "Unexpected difference in directories after code generation. Run 'task docs' command and commit."; git diff --exit-code) | |
# Run tests in a matrix with Terraform CLI versions | |
test: | |
name: 🧪 Run Tests (${{ matrix.cli }} ${{ matrix.version }}) | |
# needs: checkbuild | |
environment: | |
name: development | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
permissions: | |
contents: read | |
actions: read | |
checks: write | |
pull-requests: write | |
id-token: write | |
outputs: | |
changes: ${{ steps.changes_check.outputs.changes }} | |
strategy: | |
fail-fast: false | |
matrix: | |
cli: [terraform, tofu] | |
version: ["1.7", "1.8", "1.9"] | |
exclude: | |
- cli: terraform | |
version: "1.7" | |
- cli: tofu | |
version: "1.9" | |
steps: | |
- name: ⤵️ Checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
fetch-depth: 0 | |
- name: ✔️ Check for changes | |
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 | |
id: changes_check | |
with: | |
filters: | | |
changes: | |
- '**.go' | |
- 'go.mod' | |
- 'go.sum' | |
- '.github/workflows/test.yml' | |
- name: 🚧 Setup Go | |
if: steps.changes_check.outputs.changes == 'true' || github.event_name != 'pull_request' || github.event_name != 'pull_request_target' | |
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 | |
with: | |
go-version-file: go.mod | |
cache: true | |
- name: 🚧 Setup Terraform | |
if: matrix.cli == 'terraform' && (steps.changes_check.outputs.changes == 'true' || github.event_name != 'pull_request' || github.event_name != 'pull_request_target') | |
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2 | |
with: | |
terraform_version: ${{ matrix.version }} | |
terraform_wrapper: false | |
- name: ⚙️ Configure Terraform | |
if: matrix.cli == 'terraform' && (steps.changes_check.outputs.changes == 'true' || github.event_name != 'pull_request' || github.event_name != 'pull_request_target') | |
run: | | |
terraform -version | |
- name: 🚧 Setup OpenTofu | |
uses: opentofu/setup-opentofu@12f4debbf681675350b6cd1f0ff8ecfbda62027b # v1.0.4 | |
if: matrix.cli == 'tofu' && (steps.changes_check.outputs.changes == 'true' || github.event_name != 'pull_request' || github.event_name != 'pull_request_target') | |
with: | |
tofu_version: ${{ matrix.version }} | |
tofu_wrapper: false | |
- name: ⚙️ Configure OpenTofu | |
if: matrix.cli == 'tofu' && (steps.changes_check.outputs.changes == 'true' || github.event_name != 'pull_request' || github.event_name != 'pull_request_target') | |
run: | | |
echo "TERRAFORM_CLI=$(which tofu)" >> $GITHUB_ENV | |
echo "REGISTRY_HOST=registry.opentofu.org" >> $GITHUB_ENV | |
echo "TF_ACC_TERRAFORM_PATH=$(which tofu)" >> $GITHUB_ENV | |
echo "TF_ACC_PROVIDER_HOST=registry.opentofu.org" >> $GITHUB_ENV | |
tofu -version | |
- name: ⚙️ Set CLI version | |
if: steps.changes_check.outputs.changes == 'true' || github.event_name != 'pull_request' || github.event_name != 'pull_request_target' | |
run: | | |
version=$(echo "${{ matrix.version }}" | sed 's/\./_/g') | |
echo "CLI_VERSION=$version" >> $GITHUB_ENV | |
- name: 🚧 Setup Task | |
if: steps.changes_check.outputs.changes == 'true' || github.event_name != 'pull_request' || github.event_name != 'pull_request_target' | |
uses: arduino/setup-task@b91d5d2c96a56797b48ac1e0e89220bf64044611 # v2.0.0 | |
with: | |
repo-token: ${{ github.token }} | |
- name: 🔀 Download Go dependencies | |
if: steps.changes_check.outputs.changes == 'true' || github.event_name != 'pull_request' || github.event_name != 'pull_request_target' | |
run: task deps:download | |
- name: 🔨 Setup Test tools | |
if: steps.changes_check.outputs.changes == 'true' || github.event_name != 'pull_request' || github.event_name != 'pull_request_target' | |
run: task test:tools | |
- name: 🧪 Run tests | |
if: matrix.cli == 'terraform' && (steps.changes_check.outputs.changes == 'true' || github.event_name != 'pull_request' || github.event_name != 'pull_request_target') | |
run: task test | |
timeout-minutes: 30 | |
env: | |
FABRIC_TESTACC_SKIP_NO_SPN: true | |
FABRIC_USE_OIDC: true | |
FABRIC_TENANT_ID: ${{ secrets.TESTACC_TENANT_ID }} | |
FABRIC_CLIENT_ID: ${{ secrets.TESTACC_SPN_TF_CLIENT_ID }} | |
- name: 🧪 Run tests | |
if: matrix.cli == 'tofu' && (steps.changes_check.outputs.changes == 'true' || github.event_name != 'pull_request' || github.event_name != 'pull_request_target') | |
run: task test | |
timeout-minutes: 30 | |
env: | |
FABRIC_TESTACC_SKIP_NO_SPN: true | |
FABRIC_USE_OIDC: true | |
FABRIC_TENANT_ID: ${{ secrets.TESTACC_TENANT_ID }} | |
FABRIC_CLIENT_ID: ${{ secrets.TESTACC_SPN_OT_CLIENT_ID }} | |
- name: 📤 Upload test results | |
if: always() && (steps.changes_check.outputs.changes == 'true' || github.event_name != 'pull_request' || github.event_name != 'pull_request_target') | |
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | |
with: | |
name: ${{ format('{0}-{1}-test-results', matrix.cli, env.CLI_VERSION) }} | |
path: testresults.xml | |
if-no-files-found: warn | |
overwrite: true | |
- name: 📤 Upload coverage results | |
if: always() && (steps.changes_check.outputs.changes == 'true' || github.event_name != 'pull_request' || github.event_name != 'pull_request_target') | |
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | |
with: | |
name: ${{ format('{0}-{1}-test-coverage-results', matrix.cli, env.CLI_VERSION) }} | |
path: | | |
coverage.html | |
coverage.json | |
coverage.out | |
coverage.txt | |
coverage.xml | |
if-no-files-found: warn | |
overwrite: true | |
- name: 📢 Publish test results | |
if: always() && (steps.changes_check.outputs.changes == 'true' || github.event_name != 'pull_request' || github.event_name != 'pull_request_target') | |
uses: dorny/test-reporter@31a54ee7ebcacc03a09ea97a7e5465a47b84aea5 # v1.9.1 | |
with: | |
name: 📜 Test results (${{ matrix.cli }} ${{ matrix.version }}) | |
reporter: jest-junit | |
path: testresults.xml | |
- name: ⚙️ Get Coverage summary | |
if: always() && (steps.changes_check.outputs.changes == 'true' || github.event_name != 'pull_request' || github.event_name != 'pull_request_target') | |
uses: irongut/CodeCoverageSummary@51cc3a756ddcd398d447c044c02cb6aa83fdae95 # v1.3.0 | |
with: | |
filename: coverage.xml | |
badge: true | |
fail_below_min: true | |
format: markdown | |
hide_branch_rate: false | |
hide_complexity: false | |
indicators: true | |
output: both | |
thresholds: "40 60" | |
- name: 📤 Upload Coverage summary | |
if: always() && (steps.changes_check.outputs.changes == 'true' || github.event_name != 'pull_request' || github.event_name != 'pull_request_target') | |
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | |
with: | |
name: ${{ format('{0}-{1}-test-coverage-summary', matrix.cli, env.CLI_VERSION) }} | |
path: | | |
code-coverage-results.md | |
if-no-files-found: warn | |
overwrite: true | |
coverage-summary: | |
if: always() && (needs.test.outputs.changes == 'true' || github.event_name != 'pull_request' || github.event_name != 'pull_request_target') | |
name: 📔 Coverage Summary | |
needs: test | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
issues: write | |
pull-requests: write | |
steps: | |
- name: 📥 Download | |
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 | |
with: | |
pattern: terraform-1_9-test-coverage* | |
merge-multiple: true | |
- name: 📝 Publish | |
run: cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY | |
- name: 📤 Upload results to Codecov | |
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
file: coverage.out | |
- name: 🔎 Find comment | |
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target' | |
uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3.1.0 | |
id: fc | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
comment-author: github-actions[bot] | |
body-includes: Minimum allowed line rate is | |
- name: 📝 Create comment | |
if: steps.fc.outputs.comment-id == '' && (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') | |
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0 | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
body-path: code-coverage-results.md | |
- name: 📝 Update comment | |
if: steps.fc.outputs.comment-id != '' && (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') | |
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0 | |
with: | |
comment-id: ${{ steps.fc.outputs.comment-id }} | |
body-path: code-coverage-results.md | |
edit-mode: replace | |
# Returns success if all matrix jobs in test are successful - otherwise, it returns a failure. | |
# Use this as a PR status check for GitHub Policy Service instead of individual matrix entry checks. | |
check-test-matrix: | |
if: always() | |
name: 🧪 Check Tests | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- name: ✅ OK | |
if: ${{ !(contains(needs.*.result, 'failure')) }} | |
run: exit 0 | |
- name: 🛑 Failure | |
if: ${{ contains(needs.*.result, 'failure') }} | |
run: exit 1 |