-
Notifications
You must be signed in to change notification settings - Fork 409
198 lines (195 loc) · 7.13 KB
/
integration-tests.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
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: Integration test suite
on:
push:
branches: [ "main" ]
paths-ignore:
- 'docs/**'
- 'ors-api/src/test/java/**'
- 'ors-api/src/test/resources/**'
- 'ors-engine/src/test/**'
- 'ors-report-aggregation/**'
- '.rpm-packaging/**'
pull_request:
branches: [ "main", "feat/graph-repo-client" ]
types:
- opened
- reopened
- synchronize
- ready_for_review
paths-ignore:
- 'docs/**'
- 'ors-api/src/test/java/**'
- 'ors-api/src/test/resources/**'
- 'ors-engine/src/test/**'
- 'ors-report-aggregation/**'
- '.rpm-packaging/**'
jobs:
build-default-builder:
name: Build default builder image
runs-on: ubuntu-latest
outputs:
builder_image_id: ${{ steps.docker_build.outputs.imageid }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 17
id: setup-java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Prepare the maven cache dependencies
run: |
echo "Sync the maven dependencies"
mvn package -Dmaven.test.skip=true -B dependency:go-offline dependency:resolve-plugins dependency:resolve -q
# Replace all RUN mvn with RUN --mount=type=cache,target=/root/.m2 mvn
sed -i 's/RUN mvn /RUN --mount=type=cache,target=\/root\/.m2 mvn /g' ors-test-scenarios/src/test/resources/Builder.Dockerfile
- name: inject maven-build-cache into docker
uses: reproducible-containers/[email protected]
with:
cache-map: |
{
"/home/runner/.m2": "/root/.m2"
}
- name: Build ors-test-scenarios-builder
id: docker_build
uses: docker/build-push-action@v6
with:
context: .
push: false
load: false
file: ./ors-test-scenarios/src/test/resources/Builder.Dockerfile
tags: ors-test-scenarios-builder:latest
target: ors-test-scenarios-builder
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Cache the graph
id: cache_graph
uses: actions/cache@v4
with:
path: |
ors-test-scenarios/graphs-integrationtests
key: ${{ runner.os }}-ors-test-scenarios-builder-images-${{ steps.docker_build.outputs.imageid }}
- name: Load the ors-test-scenarios-builder image
if: steps.cache_graph.outputs.cache-hit != 'true'
uses: docker/build-push-action@v6
with:
context: .
push: false
load: false
file: ./ors-test-scenarios/src/test/resources/Builder.Dockerfile
tags: ors-test-scenarios-builder:latest
target: ors-test-scenarios-builder
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Load ors-test-scenarios-jar-builder image
if: steps.cache_graph.outputs.cache-hit != 'true'
uses: docker/build-push-action@v6
with:
context: .
load: true
file: ./ors-test-scenarios/src/test/resources/Builder.Dockerfile
tags: ors-test-scenarios-jar-builder:latest
target: ors-test-scenarios-jar-builder
cache-from: type=gha
cache-to: type=gha,mode=min
- name: Build shared graph
if: steps.cache_graph.outputs.cache-hit != 'true'
run: |
# Build the shared graph
mvn -pl ors-test-scenarios -q -Dtest=integrationtests.OneShotGraphBuilderTest\#oneShotGraphBuilder test \
-Dcontainer.builder.use_prebuild=true \
-Dcontainer.run.scenario=jar
env:
ONE_SHOT_GRAPH_BUILDER: true
integration-tests:
name: Integration tests
runs-on: ubuntu-22.04
needs:
- build-default-builder
strategy:
matrix:
test-scenario: [ "maven", "jar", "war" ]
test-class:
- integrationtests.ConfigEnvironmentTest
- integrationtests.ConfigFileTest
- integrationtests.ConfigLookupTest
- integrationtests.GeoToolsTest
- integrationtests.GraphRepoTest
fail-fast: true
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Cache local Maven repository
uses: actions/cache/restore@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: inject maven-build-cache into docker
uses: reproducible-containers/[email protected]
with:
cache-map: |
{
"/home/runner/.m2": "/root/.m2"
}
- name: Prepare the maven cache dependencies
run: |
# Replace all RUN mvn with RUN --mount=type=cache,target=/root/.m2 mvn
sed -i 's/RUN mvn /RUN --mount=type=cache,target=\/root\/.m2 mvn /g' ors-test-scenarios/src/test/resources/Builder.Dockerfile
- name: Restore cached graph
id: restore-cached-image
uses: actions/cache/restore@v4
with:
path: |
ors-test-scenarios/graphs-integrationtests
key: ${{ runner.os }}-ors-test-scenarios-builder-images-${{ needs.build-default-builder.outputs.builder_image_id }}
- name: Load ors-test-scenarios-builder image
uses: docker/build-push-action@v6
with:
context: .
load: true
file: ./ors-test-scenarios/src/test/resources/Builder.Dockerfile
tags: ors-test-scenarios-builder:latest
target: ors-test-scenarios-builder
cache-from: type=gha
- name: Build the ${{ matrix.test-scenario }} builder image
id: docker_build
uses: docker/build-push-action@v6
with:
context: .
load: true
file: ./ors-test-scenarios/src/test/resources/Builder.Dockerfile
tags: ors-test-scenarios-${{ matrix.test-scenario }}-builder:latest
target: ors-test-scenarios-${{ matrix.test-scenario }}-builder
cache-from: type=gha
- name: Run integration tests
run: |
# List the cached images
docker image ls -a
# Run only a subset for now
mvn -pl ors-test-scenarios -Dtest=${{ matrix.test-class }} test \
-Dcontainer.run.scenario=${{ matrix.test-scenario }} \
-Dcontainer.builder.use_prebuild=true -q