Skip to content

Commit 2e551fe

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 2e551fe

3 files changed

Lines changed: 98 additions & 4 deletions

File tree

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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+
cancel-in-progress: true
28+
29+
jobs:
30+
azure-integration-tests:
31+
name: Azure Integration Tests
32+
if: >-
33+
github.event_name != 'pull_request' ||
34+
github.event.pull_request.head.repo.full_name == github.repository
35+
runs-on: ubuntu-latest
36+
timeout-minutes: 60
37+
permissions:
38+
id-token: write
39+
contents: read
40+
41+
steps:
42+
- uses: actions/checkout@v4
43+
44+
- name: Install mise
45+
uses: jdx/mise-action@v3
46+
with:
47+
version: 2025.12.10
48+
experimental: true
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
52+
- name: Go module cache
53+
uses: actions/cache@v4
54+
with:
55+
path: |
56+
~/go/pkg/mod
57+
~/.cache/go-build
58+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
59+
restore-keys: |
60+
${{ runner.os }}-go-
61+
62+
- name: Download Go modules
63+
run: go mod download
64+
65+
- name: Azure login (OIDC)
66+
uses: azure/login@v2
67+
with:
68+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
69+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
70+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
71+
72+
- name: Run Azure integration tests
73+
env:
74+
ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
75+
ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
76+
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
77+
ARM_USE_OIDC: "true"
78+
run: |
79+
set -o pipefail
80+
mkdir -p /tmp/logs
81+
# Scope: tests that opt into OIDC via the `azureoidc` build tag.
82+
# AzureRM 2.x examples cannot authenticate via OIDC and are gated
83+
# behind a follow-up provider-upgrade effort; they remain on the
84+
# default `azure` tag.
85+
go test -v -p 1 -tags azureoidc -count=1 -timeout 45m \
86+
./test/azure/... 2>&1 | tee /tmp/logs/azure-integration-tests.log
87+
88+
- name: Upload test logs
89+
if: always()
90+
uses: actions/upload-artifact@v4
91+
with:
92+
name: azure-integration-test-logs
93+
path: /tmp/logs/
94+
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)