Skip to content

Commit 8de8798

Browse files
committed
ci: add Azure workflow scoping OIDC tests via azureoidc build tag
Addresses review feedback on PR #1794: #1794 (comment) Replaces the brittle enumerated `-run '^(TestA|TestB)$'` regex with a new `azureoidc` build tag. Tests opt in by adding the tag, so adding or removing OIDC-compatible tests no longer requires editing the workflow. - TerraformAzureContainerAppExample and TerraformAzureKeyVaultExample carry `azure || azureoidc`, so they remain part of the default `azure` build while also being selectable via the narrower OIDC tag. - Workflow runs `go test -tags azureoidc ./test/azure/...`.
1 parent 63b6377 commit 8de8798

3 files changed

Lines changed: 103 additions & 4 deletions

File tree

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: Azure Integration Tests
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- 'modules/azure/**'
8+
- 'test/azure/**'
9+
- 'examples/azure/**'
10+
- 'go.mod'
11+
- 'go.sum'
12+
- 'mise.toml'
13+
- '.github/workflows/azure-integration-tests.yml'
14+
pull_request:
15+
paths:
16+
- 'modules/azure/**'
17+
- 'test/azure/**'
18+
- 'examples/azure/**'
19+
- 'go.mod'
20+
- 'go.sum'
21+
- 'mise.toml'
22+
- '.github/workflows/azure-integration-tests.yml'
23+
workflow_dispatch:
24+
25+
concurrency:
26+
group: azure-integration-tests-${{ github.ref }}
27+
# Do not cancel in-flight runs: tests provision real Azure resources and
28+
# rely on `defer terraform.Destroy` for cleanup. Cancellation can orphan
29+
# resource groups.
30+
cancel-in-progress: false
31+
32+
jobs:
33+
azure-integration-tests:
34+
name: Azure Integration Tests
35+
if: >-
36+
github.event_name != 'pull_request' ||
37+
github.event.pull_request.head.repo.full_name == github.repository
38+
runs-on: ubuntu-latest
39+
timeout-minutes: 60
40+
permissions:
41+
id-token: write
42+
contents: read
43+
44+
steps:
45+
- uses: actions/checkout@v4
46+
47+
- name: Install mise
48+
uses: jdx/mise-action@v3
49+
with:
50+
version: 2025.12.10
51+
experimental: true
52+
env:
53+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
55+
- name: Go module cache
56+
uses: actions/cache@v4
57+
with:
58+
path: |
59+
~/go/pkg/mod
60+
~/.cache/go-build
61+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
62+
restore-keys: |
63+
${{ runner.os }}-go-
64+
65+
- name: Download Go modules
66+
run: go mod download
67+
68+
- name: Azure login (OIDC)
69+
uses: azure/login@v2
70+
with:
71+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
72+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
73+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
74+
75+
- name: Run Azure integration tests
76+
env:
77+
ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
78+
ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
79+
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
80+
ARM_USE_OIDC: "true"
81+
run: |
82+
set -o pipefail
83+
mkdir -p /tmp/logs
84+
# Scope: tests that opt into OIDC via the `azureoidc` build tag.
85+
# To add a new OIDC-compatible test, give the test file the build
86+
# constraint `//go:build azure || azureoidc` (matching `// +build`
87+
# line: `azure azureoidc`). AzureRM 2.x examples cannot authenticate
88+
# via OIDC and are gated behind a follow-up provider-upgrade effort;
89+
# they remain on the default `azure` tag only.
90+
go test -v -p 1 -tags azureoidc -count=1 -timeout 45m \
91+
./test/azure/... 2>&1 | tee /tmp/logs/azure-integration-tests.log
92+
93+
- name: Upload test logs
94+
if: always()
95+
uses: actions/upload-artifact@v4
96+
with:
97+
name: azure-integration-test-logs
98+
path: /tmp/logs/
99+
retention-days: 14

test/azure/terraform_azure_container_apps_example_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
//go:build azure
2-
// +build azure
1+
//go:build azure || azureoidc
2+
// +build azure azureoidc
33

44
package test_test
55

test/azure/terraform_azure_keyvault_example_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
//go:build azure
2-
// +build azure
1+
//go:build azure || azureoidc
2+
// +build azure azureoidc
33

44
package test_test
55

0 commit comments

Comments
 (0)