-
Notifications
You must be signed in to change notification settings - Fork 0
292 lines (273 loc) · 10.1 KB
/
push-actions.yml
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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
name: Tracer Testing
on:
push:
branches: [ main ]
paths-ignore:
- '.github/**'
- '**.md'
pull_request:
types: [ opened, synchronize ]
paths-ignore:
- '.github/**'
- '**.md'
jobs:
pr-labeling:
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
pull-requests: write
steps:
- uses: amannn/action-semantic-pull-request@v5
if: github.event_name == 'pull_request'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
disallowScopes: |
release
- uses: codelytv/pr-size-labeler@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
xs_label: 'size/xs'
xs_max_size: '15'
s_label: 'size/s'
s_max_size: '100'
m_label: 'size/m'
m_max_size: '500'
l_label: 'size/l'
l_max_size: '1000'
xl_label: 'size/xl'
fail_if_xl: 'false'
message_if_xl: >
This PR exceeds the recommended size of 1000 lines.
Please make sure you are NOT addressing multiple issues with one PR.
Note this PR might be rejected due to its size.
files_to_ignore: ''
spotless:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up JDK for running Gradle
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
- name: Spotless
uses: gradle/actions/setup-gradle@v3
with:
# this is a common failure point, so we run it first
arguments: spotlessCheck
cache-read-only: true
smoke-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
- name: Configure aws credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: 'us-west-2'
- name: Tests
uses: gradle/actions/setup-gradle@v3
with:
# exclude spotlessCheck to avoid running it twice
arguments: check -x spotlessCheck
cache-read-only: true
- name: Upload test reports
uses: actions/upload-artifact@v4
if: always()
with:
name: 'Smoke test reports'
path: |
**/build/reports/
**/build/test-results/
if-no-files-found: error
k8s-e2e:
runs-on: ubuntu-latest
steps:
- name: Clone the code
uses: actions/checkout@v4
- name: Cache go dependencies
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install KiND
uses: helm/[email protected]
with:
install_only: true
- name: Set up JDK for running Gradle
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
- name: Build the injector container
run: make -C integration-tests/k8s build-injector
shell: bash
- name: Set up gotestfmt
uses: GoTestTools/gotestfmt-action@v2
with:
# Optional: pass GITHUB_TOKEN to avoid rate limiting.
token: ${{ secrets.GITHUB_TOKEN }}
- name: Run Integration tests
shell: bash
working-directory: integration-tests/k8s
run: |
set -euo pipefail
go test -v -timeout 1h -json ./... --args -v 5 -build-tag=$(git rev-parse --short HEAD) 2>&1 | tee /tmp/gotest.log | gotestfmt
- name: Upload test log
uses: actions/upload-artifact@v4
if: always()
with:
name: k8s-e2e-test-log
path: /tmp/gotest.log
if-no-files-found: error
ecs-e2e:
# Needed by aws-actions/configure-aws-credentials
permissions:
id-token: write
contents: read
runs-on: ubuntu-latest
steps:
- name: Clone the code
uses: actions/checkout@v4
- name: Set up JDK for running Gradle
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
- name: Assemble the agent
uses: gradle/actions/setup-gradle@v3
with:
# Skip tests and spotless to get more specific K8s info in case
# of PRs with issues
arguments: |
clean assemble
-x test
-x spotlessCheck
cache-read-only: true
- uses: actions/setup-node@v3
- name: Configure aws credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: 'us-west-2'
- name: Create a random deployment suffix
id: deployment-suffix
shell: bash
run: |
suffix=$(dd bs=512 if=/dev/urandom count=1 2>/dev/null | LC_ALL=C tr -dc "a-zA-Z0-9" | head -c 10)
echo "DEPLOYMENT_SUFFIX=${suffix}" >> $GITHUB_OUTPUT
- name: Install dependencies
run: yarn
working-directory: integration-tests/ecs
- name: CDK Bootstrap
run: yarn cdk bootstrap
working-directory: integration-tests/ecs
env:
DEPLOYMENT_SUFFIX: ${{ steps.deployment-suffix.outputs.DEPLOYMENT_SUFFIX }}
- name: Synth stack
run: yarn cdk synth
working-directory: integration-tests/ecs
env:
DEPLOYMENT_SUFFIX: ${{ steps.deployment-suffix.outputs.DEPLOYMENT_SUFFIX }}
- name: Deploy stack
run: yarn cdk deploy --all --require-approval never
working-directory: integration-tests/ecs
env:
DEPLOYMENT_SUFFIX: ${{ steps.deployment-suffix.outputs.DEPLOYMENT_SUFFIX }}
- name: Test the agent
env:
DEPLOYMENT_SUFFIX: ${{ steps.deployment-suffix.outputs.DEPLOYMENT_SUFFIX }}
shell: bash
run: |
suffix=${DEPLOYMENT_SUFFIX}
if [ -z "$suffix" ]; then
suffix="dev"
fi
suffix="-${suffix}"
start_time=$(($(date +%s000) - 100000))
log_count=$(aws logs filter-log-events --log-stream-name-prefix springboot --log-group-name JavaagentFargateTestLogGroup${suffix} --output text --start-time $start_time --end-time $(date +%s000) | grep -o "aws.ecs.task.arn" | wc -l | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
log_count=$(($log_count + 0))
if [ $log_count -lt 1 ]; then
echo -e "\033[0;31mNo evidence for the aws.ecs.task.arn resource attribute in the logs. Expected at least 1 occurrence.\033[0m"
exit 1
fi
echo -e "\033[0;32mFound $log_count occurrences of the aws.ecs.task.arn resource attribute in the logs.\033[0m"
echo -e "\033[0;32mTest passes.\033[0m"
- name: remove stack
if: always()
run: yarn cdk destroy --all --force --require-approval never
working-directory: integration-tests/ecs
env:
DEPLOYMENT_SUFFIX: ${{ steps.deployment-suffix.outputs.DEPLOYMENT_SUFFIX }}
instrumentations-to-test:
name: List instrumentations to test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: list_instrumentations
run: |
instrumentationFolders=$(find instrumentation -type d -name "tested_versions" -not -path "*/build/*" | sed 's/instrumentation\///g' | sed 's/\/src\/main\/resources\/tested_versions//' | sort)
instrumentations_as_json_list=$(echo "$instrumentationFolders" | jq --raw-input --slurp 'split("\n") | map(select(. != ""))' | jq -r tostring)
echo "instrumentations=${instrumentations_as_json_list}" >> "${GITHUB_OUTPUT}"
echo "instrumentations=${instrumentations_as_json_list}"
outputs:
instrumentations: ${{ steps.list_instrumentations.outputs.instrumentations }}
supported-java-versions-testing:
name: 'JDK ${{ matrix.jdk_version }} ${{ matrix.instrumentation_to_test }} tests'
runs-on: ubuntu-latest
needs: [instrumentations-to-test]
strategy:
fail-fast: false # We want to see all tests being tried, rather than stop when the first fails
matrix:
jdk_version: [ 11, 17, 21]
instrumentation_to_test: ${{ fromJson(needs.instrumentations-to-test.outputs.instrumentations) }}
steps:
- uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.jdk_version }}
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ matrix.jdk_version }}
- name: Configure aws credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: 'us-west-2'
- run: ./gradlew clean
- run: ./gradlew build -x test
- run: .github/testComponentVersions.sh ${{ matrix.instrumentation_to_test }}
checks:
permissions:
contents: write
issues: write
runs-on: ubuntu-latest
needs: [ pr-labeling, spotless, smoke-tests, k8s-e2e, ecs-e2e, instrumentations-to-test, supported-java-versions-testing ]
# Force this job to run even if the previous jobs failed
if: ${{ always() }}
steps:
- name: Report failure
# Only create an issue if a previous job failed and this is a push to main
if: ${{contains(needs.*.result, 'failure') && github.event_name == 'push' && github.ref == 'refs/heads/main'}}
uses: actions-cool/issues-helper@v3
with:
actions: 'create-issue'
token: ${{ secrets.GITHUB_TOKEN }}
title: 🐛 Checks failed for ${{ github.sha }}
body: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
labels: bug