fix: update BTP CLI and Terraform Version with Re-recorded Test Fixtures #1666
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
# Terraform Provider testing workflow. | |
name: Terraform Provider Tests | |
# This GitHub action runs your tests for each pull request and push. | |
# Optionally, you can turn it on using a schedule for regular testing. | |
on: | |
pull_request: | |
types: | |
- opened | |
- reopened | |
- synchronize | |
- ready_for_review | |
paths-ignore: | |
- '*.md' | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- '*.md' | |
workflow_dispatch: | |
workflow_call: | |
# Testing only needs permissions to read the repository contents. | |
permissions: | |
contents: read | |
# Define the latest Terraform version to use for upload of coverage report | |
env: | |
SONAR_CLOUD_TF_VERSION: 19 | |
jobs: | |
# Ensure project builds before running testing matrix | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
steps: | |
- uses: actions/checkout@v4 # v4.0.0 | |
- uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0 | |
with: | |
go-version-file: 'go.mod' | |
cache: true | |
- run: go mod download | |
- run: go build -v . | |
- name: Run linters | |
uses: golangci/golangci-lint-action@ec5d18412c0aeab7936cb16880d708ba2a64e1ae # v3.7.1 | |
with: | |
version: latest | |
generate: | |
if: github.event.pull_request.draft == false | |
name: Docu Generation | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 # v4.0.0 | |
- uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0 | |
with: | |
go-version-file: 'go.mod' | |
cache: true | |
- run: go generate ./... | |
- name: git diff | |
run: | | |
git diff --compact-summary --exit-code || \ | |
(echo; echo "Unexpected difference in directories after code generation. Run 'go generate ./...' command and commit."; exit 1) | |
fixtureDriftDetect: | |
if: github.event.pull_request.draft == false | |
name: Fixture Drift Detection | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 # v4.0.0 | |
with: | |
fetch-depth: 0 | |
- run: .github/scripts/fixtureDriftDetect.sh internal/provider/fixtures/ | |
# Run acceptance tests in a matrix with Terraform CLI versions | |
test: | |
if: github.event.pull_request.draft == false | |
name: Terraform Provider Acceptance Tests | |
needs: build | |
runs-on: ubuntu-latest | |
# Timeout for tests set to 25 minutes to safeguard long running tests (specifically for service instances) | |
timeout-minutes: 25 | |
strategy: | |
fail-fast: false | |
matrix: | |
# list whatever Terraform versions here you would like to support | |
terraform: | |
- '1.6.*' #end of security support under BSL 31 Dec 2025 | |
- '1.7.*' #end of security support under BSL 31 Dec 2026 | |
- '1.8.*' #end of security support under BSL 31 Dec 2026 | |
- '1.9.*' #end of security support under BSL 31 Dec 2026 | |
# - '1.10.*' | |
steps: | |
- uses: actions/checkout@v4 # v4.0.0 | |
- uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0 | |
with: | |
go-version-file: 'go.mod' | |
cache: true | |
- uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2 | |
with: | |
terraform_version: ${{ matrix.terraform }} | |
terraform_wrapper: false | |
- run: go mod download | |
- env: | |
TF_ACC: "1" | |
run: go test -v -cover -coverprofile=cover.out -timeout=1800s -parallel=4 ./... | |
timeout-minutes: 20 | |
# Determine stripped version of Terraform | |
- run: echo "CURRENT_TF_VERSION=$(echo ${{ matrix.terraform }} | sed 's/[^a-zA-Z0-9]//g')" >> $GITHUB_ENV | |
# Upload coverage report for latest Terraform version only to avoid nameing issues in upload (see also https://github.com/actions/upload-artifact/tree/v4/?tab=readme-ov-file#breaking-changes) | |
- uses: actions/upload-artifact@v4 | |
if: ${{ env.CURRENT_TF_VERSION == env.SONAR_CLOUD_TF_VERSION}} | |
with: | |
name: coverage-report | |
path: cover.out | |
sonarcloud: | |
if: github.event.pull_request.draft == false | |
name: SonarCloud | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
- uses: actions/download-artifact@v4 | |
with: | |
name: coverage-report | |
- name: SonarCloud Scan | |
uses: SonarSource/sonarqube-scan-action@v4 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |