-
Notifications
You must be signed in to change notification settings - Fork 210
272 lines (230 loc) · 9.42 KB
/
build-common.yml
File metadata and controls
272 lines (230 loc) · 9.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
name: Build (common)
on:
workflow_call:
inputs:
no-build-cache:
type: boolean
required: false
env:
# set this to <repo>:<branch/sha> to build and test with an unreleased
# version of the azure-monitor-opentelemetry-autoconfigure dependency
AZURE_MONITOR_OPENTELEMETRY_AUTOCONFIGURE_SNAPSHOT:
jobs:
spotless:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up JDK for running Gradle
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 21
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5
- name: Spotless
run: ./gradlew spotlessCheck ${{ inputs.no-build-cache && '--no-build-cache' || '' }}
gradle-wrapper-validation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: gradle/actions/wrapper-validation@v5
license-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up JDK for running Gradle
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 21
- name: Build and install local azure-monitor-opentelemetry-autoconfigure dependency
if: env.AZURE_MONITOR_OPENTELEMETRY_AUTOCONFIGURE_SNAPSHOT != ''
run: ./.github/scripts/build-azure-monitor-dependency.sh
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5
- name: Generate license report
run: |
# generateLicenseReport build caching appears to be broken so need to ignore build cache always
./gradlew generateLicenseReport --no-build-cache
- name: Check licenses
run: |
# add any untracked folders that may have been added by generateLicenseReport
git add licenses
# there's always going to one line difference due to the timestamp included in the report
if [[ $(git diff --cached --shortstat licenses) == " 1 file changed, 1 insertion(+), 1 deletion(-)" ]]
then
echo "Licenses are up-to-date."
else
echo "Licenses are not up-to-date, please run './gradlew generateLicenseReport' locally and commit."
echo
echo "$(git diff --cached --stat licenses)"
echo
echo "$(git diff --cached licenses)"
exit 1
fi
assemble:
# running (and uploading artifact) from windows since only that build includes etw
runs-on: windows-2022
steps:
- name: Support long paths
run: git config --system core.longpaths true
- uses: actions/checkout@v6
- name: Set up JDK for running Gradle
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 21
- name: Build and install local azure-monitor-opentelemetry-autoconfigure dependency
if: env.AZURE_MONITOR_OPENTELEMETRY_AUTOCONFIGURE_SNAPSHOT != ''
shell: bash
run: ./.github/scripts/build-azure-monitor-dependency.sh
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5
- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v2
- name: Setup Visual Studio and Windows SDK environment
shell: cmd
run: |
"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath > vs.txt
set /p VSPATH=<vs.txt
echo APPINSIGHTS_VS_PATH=%VSPATH%>>%GITHUB_ENV%
echo APPINSIGHTS_WIN10_SDK_PATH=C:\Program Files (x86)\Windows Kits\10>>%GITHUB_ENV%
- name: Assemble
# javadoc task fails sporadically fetching https://docs.oracle.com/javase/8/docs/api/
run: >
./gradlew assemble
"-Dai.etw.native.build=release"
-x javadoc
${{ inputs.no-build-cache && '--no-build-cache' || '' }}
- name: Upload snapshot
uses: actions/upload-artifact@v7
with:
path: agent/agent/build/libs/applicationinsights-agent-*-SNAPSHOT.jar
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
test-java-version:
- 8
- 11
- 17
- 21
- 25
vm:
- hotspot
# TODO (trask) enable once profiler supports OpenJ9
# - openj9
os:
- windows-2022
- ubuntu-latest
fail-fast: false
steps:
- name: Support long paths
run: git config --system core.longpaths true
if: matrix.os == 'windows-2022'
- uses: actions/checkout@v6
- id: setup-test-java
name: Set up JDK ${{ matrix.test-java-version }}-${{ matrix.vm }} for running tests
uses: actions/setup-java@v5
with:
distribution: ${{ matrix.vm == 'hotspot' && 'temurin' || 'adopt-openj9'}}
java-version: ${{ matrix.test-java-version }}
- name: Set up JDK for running Gradle
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 21
- name: Build and install local azure-monitor-opentelemetry-autoconfigure dependency
if: env.AZURE_MONITOR_OPENTELEMETRY_AUTOCONFIGURE_SNAPSHOT != ''
shell: bash
run: ./.github/scripts/build-azure-monitor-dependency.sh
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5
- name: Test
# spotless is checked separately since it's a common source of failure
run: >
./gradlew
check
-x spotlessCheck
-PtestJavaVersion=${{ matrix.test-java-version }}
-PtestJavaVM=${{ matrix.vm }}
"-Porg.gradle.java.installations.paths=${{ steps.setup-test-java.outputs.path }}"
"-Porg.gradle.java.installations.auto-download=false"
${{ inputs.no-build-cache && ' --no-build-cache' || '' }}
setup-smoke-test-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v6
- id: set-matrix
run: |
json_array=$(
for dir in smoke-tests/apps/*; do
# Convert directory path to module name (e.g., "smoke-tests/apps/MyApp" -> "smoke-tests:apps:MyApp")
module=$(echo "$dir" | sed 's|/|:|g')
# Extract just the app name from the module path (e.g., "smoke-tests:apps:MyApp" -> "MyApp")
module_short=$(echo "$module" | sed 's|.*:||')
find "${dir}/src/smokeTest/java" -name "*Test.java" | \
# Remove the base path to get relative path from smokeTest/java
sed "s|${dir}/src/smokeTest/java/||" | \
# Convert file name to class name (e.g., "com/example/MyTest.java" -> "com.example.MyTest")
sed 's|/|.|g' | sed 's|\.java$||' | \
# Process each fully qualified test class name
while read -r class_name; do
# Extract just the simple class name (e.g., "com.example.MyTest" -> "MyTest")
class_short=$(echo "$class_name" | sed 's/.*\.//')
echo "{\"display\":\"${module_short}:${class_short}\"," \
"\"module\":\"${module}\"," \
"\"test_class\":\"${class_name}\"}"
done
# Join all JSON objects with commas and remove trailing comma
done | tr '\n' ',' | sed 's/,$//'
)
# Output the matrix in GitHub Actions format
echo "matrix={\"include\":[$json_array]}" >> $GITHUB_OUTPUT
smoke-test:
name: ${{ matrix.display }}
needs: setup-smoke-test-matrix
runs-on: ubuntu-latest
strategy:
matrix: ${{fromJson(needs.setup-smoke-test-matrix.outputs.matrix)}}
fail-fast: false
steps:
- uses: actions/checkout@v6
- name: Set up Java 21
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 21
- name: Build and install local azure-monitor-opentelemetry-autoconfigure dependency
if: env.AZURE_MONITOR_OPENTELEMETRY_AUTOCONFIGURE_SNAPSHOT != ''
run: ./.github/scripts/build-azure-monitor-dependency.sh
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5
- name: Test
run: ./gradlew ${{ matrix.module }}:smokeTest --tests "${{ matrix.test_class }}*"
- name: Create unique artifact name
if: failure()
run: |
# Create a unique name based on module and test class
artifact_name="${{ matrix.module }}:${{ matrix.test_class }}"
# Replace colons and dots with hyphens for valid artifact names
artifact_name=$(echo "$artifact_name" | sed 's/[:.]/\-/g')
echo "UPLOAD_ARTIFACT_NAME=$artifact_name" >> $GITHUB_ENV
- name: Upload smoke test reports
uses: actions/upload-artifact@v7
if: failure()
with:
name: ${{ env.UPLOAD_ARTIFACT_NAME }}
path: '**/build/reports/tests/smokeTest/**/*'
check-snapshot-dependency:
runs-on: ubuntu-latest
steps:
- name: Check for snapshot dependency
run: |
if [[ -n "$AZURE_MONITOR_OPENTELEMETRY_AUTOCONFIGURE_SNAPSHOT" ]]; then
echo "AZURE_MONITOR_OPENTELEMETRY_AUTOCONFIGURE_SNAPSHOT is set to '$AZURE_MONITOR_OPENTELEMETRY_AUTOCONFIGURE_SNAPSHOT'"
echo "PRs testing against a snapshot cannot be merged."
exit 1
fi