-
Notifications
You must be signed in to change notification settings - Fork 56
151 lines (128 loc) · 4.94 KB
/
pr-build.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
name: PR Build
on:
pull_request:
branches:
- main
- "release/v*"
env:
TEST_TAG: public.ecr.aws/aws-observability/adot-autoinstrumentation-java:test
jobs:
testpatch:
name: Test patches applied to dependencies
runs-on: aws-otel-java-instrumentation_ubuntu-latest_32-core
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
# vaadin 14 tests fail with node 18
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 16
# vaadin tests use pnpm
- name: Cache pnpm modules
uses: actions/cache@v3
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-test-cache-pnpm-modules
- uses: gradle/wrapper-validation-action@v1
- uses: ./.github/actions/patch-dependencies
with:
run_tests: "true"
build:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-latest
exclude:
# Skip windows on patch workflow because it is not possible to build opentelemetry-java on windows
# when the cache is in a different drive than the source code
# Windows is not working for patch workflows, therefore we disable it here
# https://github.com/square/wire/issues/2188
# https://github.com/open-telemetry/opentelemetry-java/issues/4560
- os: ${{ startsWith(github.event.pull_request.base.ref, 'release/v') && 'windows-latest' || '' }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
- uses: gradle/wrapper-validation-action@v1
# cache local patch outputs
- name: Cache local Maven repository
uses: actions/cache@v3
with:
path: |
~/.m2/repository/io/opentelemetry/
key: ${{ runner.os }}-maven-local-${{ hashFiles('.github/patches/opentelemetry-java*.patch') }}
- name: Publish patched dependencies to maven local
uses: ./.github/actions/patch-dependencies
if: ${{ matrix.os != 'windows-latest' }} # Skip patch on windows as it is not possible to build opentelemetry-java on windows
- name: Build with Gradle with Integration tests
uses: gradle/gradle-build-action@v3
if: ${{ matrix.os == 'ubuntu-latest' }}
with:
arguments: build integrationTests --stacktrace -PenableCoverage=true -PlocalDocker=true
- name: Set up Java version for tests
uses: actions/setup-java@v4
with:
java-version: 21
distribution: temurin
- name: Pull base image of Contract Tests Sample Apps
if: ${{ matrix.os == 'ubuntu-latest' }}
run: docker pull public.ecr.aws/docker/library/amazoncorretto:21-alpine
- name: Run contract tests
uses: gradle/gradle-build-action@v3
if: ${{ matrix.os == 'ubuntu-latest' }}
with:
arguments: contractTests -PlocalDocker=true -i
- name: Set up Java version for image build
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
- name: Get current version
if: ${{ matrix.os == 'ubuntu-latest' }}
shell: bash
run: |
echo "ADOT_JAVA_VERSION=$(./gradlew printVersion -q )" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
if: ${{ matrix.os == 'ubuntu-latest' }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: image=moby/buildkit:v0.15.1
if: ${{ matrix.os == 'ubuntu-latest' }}
- name: Build image for testing
uses: docker/build-push-action@v5
if: ${{ matrix.os == 'ubuntu-latest' }}
with:
push: false
build-args: "ADOT_JAVA_VERSION=${{ env.ADOT_JAVA_VERSION }}"
context: .
platforms: linux/amd64
tags: ${{ env.TEST_TAG }}
load: true
- name: Perform image scan
uses: ./.github/actions/image_scan
if: ${{ matrix.os == 'ubuntu-latest' }}
with:
image-ref: ${{ env.TEST_TAG }}
severity: 'CRITICAL,HIGH,MEDIUM,LOW,UNKNOWN'
- name: Test docker image
if: ${{ matrix.os == 'ubuntu-latest' }}
shell: bash
run: .github/scripts/test-adot-javaagent-image.sh "${{ env.TEST_TAG }}" "${{ env.ADOT_JAVA_VERSION }}"
- name: Build with Gradle
uses: gradle/gradle-build-action@v3
if: ${{ matrix.os != 'ubuntu-latest' && (hashFiles('.github/patches/opentelemetry-java*.patch') == '' || matrix.os != 'windows-latest' ) }} # build on windows as well unless a patch exists
with:
arguments: build --stacktrace -PenableCoverage=true
- uses: codecov/codecov-action@v3