Skip to content

fix(azure-connection): Resources using client secret must be updated … #2348

fix(azure-connection): Resources using client secret must be updated …

fix(azure-connection): Resources using client secret must be updated … #2348

Workflow file for this run

name: Tests
# This workflow
# - runs the unit tests and create coverage report
# - runs static code analysis (linting)
# - runs integration tests in parallel chunks
# - reports the code coverage and linting errors to Sonar
on:
push:
branches:
- '**'
jobs:
unit-tests:
name: Run Unit Tests
runs-on: ubuntu-latest
steps:
- name: ⬇️ Check out code into the Go module directory
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 #v6.0.1
- name: 🛠️ Set up Go 1.x
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # 6.1.0
with:
go-version-file: ./go.mod
- name: 📊 Install gotestsum
run: go install gotest.tools/gotestsum@3f7ff0ec4aeb6f95f5d67c998b71f272aa8a8b41 #v1.12.1
- name: Run Unit Tests
env:
GOPROXY: "https://proxy.golang.org"
run: gotestsum --format testdox --format-icons hivis -- -coverprofile=cov.out -tags=unit -v ./...
- name: ⬆️ Archive code coverage results
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 #v5.0.0
with:
name: code-coverage-report
path: cov.out
lint:
name: Run Static Code Analysis
runs-on: ubuntu-latest
permissions:
contents: read
checks: write
steps:
- name: ⬇️ Check out code into the Go module directory
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 #v6.0.1
- name: 🛠️ Set up Go 1.x
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c #v6.1.0
with:
go-version-file: ./go.mod
- name: 🔎 golangci-lint
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 #v9.2.0
with:
install-mode: 'goinstall' # install mode goinstall in order to use hashes for the version
version: eabc2638a66daf5bb6c6fb052a32fa3ef7b6600d #v2.1.6
args: '--output.checkstyle.path=lint-report.xml --issues-exit-code=0' # if issues are found, don't exit with "1". Sonar decides if it fails or not
- name: ⬆️ Archive lint results
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 #v5.0.0
with:
name: lint-report
path: lint-report.xml
integration-tests:
name: Integration Tests - ${{ matrix.config.name }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# several tests are split into chunks with about 20 tests
# A dynamic matrix can't be used because there is a limit of 256 entries
config:
- { name: "app", path: "./dynatrace/api/app/..." }
- { name: "automation", path: "./dynatrace/api/automation/..." }
- { name: "cluster", path: "./dynatrace/api/cluster/..." }
- { name: "documents", path: "./dynatrace/api/documents/..." }
- { name: "grail", path: "./dynatrace/api/grail/..." }
- { name: "iam", path: "./dynatrace/api/iam/..." }
- { name: "openpipeline", path: "./dynatrace/api/openpipeline/..." }
- { name: "platform", path: "./dynatrace/api/platform/..." }
- { name: "service", path: "./dynatrace/api/service/..." }
- { name: "slo", path: "./dynatrace/api/slo/..." }
- { name: "v1 (a-d)", path: "$(go list ./dynatrace/api/v1/... | grep -E '^.+/dynatrace/api/v1/[a-d][^/]*/?')" }
- { name: "v1 (e-z)", path: "$(go list ./dynatrace/api/v1/... | grep -E '^.+/dynatrace/api/v1/[e-z][^/]*/?')" }
- { name: "v2", path: "./dynatrace/api/v2/..." }
- { name: "builtin (a-b)", path: "$(go list ./dynatrace/api/builtin/... | grep -E '^.+/dynatrace/api/builtin/[a-b][^/]*/?')" }
- { name: "builtin (c-e)", path: "$(go list ./dynatrace/api/builtin/... | grep -E '^.+/dynatrace/api/builtin/[c-e][^/]*/?')" }
- { name: "builtin (f-m)", path: "$(go list ./dynatrace/api/builtin/... | grep -E '^.+/dynatrace/api/builtin/[f-m][^/]*/?')" }
- { name: "builtin (n-o)", path: "$(go list ./dynatrace/api/builtin/... | grep -E '^.+/dynatrace/api/builtin/[n-o][^/]*/?')" }
- { name: "builtin (p-s)", path: "$(go list ./dynatrace/api/builtin/... | grep -E '^.+/dynatrace/api/builtin/[p-s][^/]*/?')" }
- { name: "builtin (t-z)", path: "$(go list ./dynatrace/api/builtin/... | grep -E '^.+/dynatrace/api/builtin/[t-z][^/]*/?')" }
steps:
- name: ⬇️ Check out code into the Go module directory
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 #v6.0.1
- name: 🛠️ Set up Go 1.x
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # 6.1.0
with:
go-version-file: ./go.mod
- uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd
with:
terraform_wrapper: false
- name: Run Integration Tests - ${{ matrix.config.name }}
if: success() || failure()
env:
GOPROXY: "https://proxy.golang.org"
TF_ACC: "true"
DYNATRACE_DEBUG: "true"
DYNATRACE_HTTP_OAUTH_PREFERENCE: "true"
DT_NO_REPAIR_INPUT: "false"
DYNATRACE_ENV_URL: ${{ secrets.DYNATRACE_ENV_URL }}
DYNATRACE_API_TOKEN: ${{ secrets.DYNATRACE_API_TOKEN }}
DT_CLIENT_ID: ${{ secrets.DT_CLIENT_ID }}
DT_CLIENT_SECRET: ${{ secrets.DT_CLIENT_SECRET }}
DT_ACCOUNT_ID: ${{ secrets.DT_ACCOUNT_ID }}
run: go test -tags=integration -v -p 1 ${{ matrix.config.path }}
sonar_scan:
name: SonarQube lint and test coverage
if: ${{ always() }} # always runs after lint and test have completed, regardless of whether they were successful
needs: [ unit-tests, lint ]
permissions:
contents: read
checks: write
runs-on: ubuntu-latest
steps:
- name: ⬇️ Check out code into the Go module directory
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 #v6.0.1
with:
# Disabling shallow clones is recommended for improving the relevancy of reporting
fetch-depth: 0
- name: ⬇️ Download coverage artifact
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 #v6.0.0
with:
name: code-coverage-report
- name: ⬇️ Download lint artifact
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 #v6.0.0
with:
name: lint-report
- name: 🏷️ Get latest tag
id: get_latest_tag
run: |
echo "GIT_TAG=$(git describe --tags --abbrev=0)" >> "$GITHUB_OUTPUT"
- name: 🔍 SonarQube Scan
uses: SonarSource/sonarqube-scan-action@fd88b7d7ccbaefd23d8f36f73b59db7a3d246602 # nosemgrep false detection of commit v6.0.0
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: >
"-Dsonar.projectVersion=${{steps.get_latest_tag.outputs.GIT_TAG}}"