-
Notifications
You must be signed in to change notification settings - Fork 246
318 lines (298 loc) · 13.7 KB
/
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
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
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
name: Tests
on:
push:
paths-ignore: ['*.md', 'CODEOWNERS', 'LICENSE']
branches:
- 'integration'
- 'release/version*'
pull_request:
paths-ignore: ['*.md', 'CODEOWNERS', 'LICENSE', '.github/workflows/microservice*.yaml']
workflow_dispatch:
env:
JAVA_VERSION: '11'
JAVA_DISTRIBUTION: 'zulu' #This is the default on v1 of the action for 1.8
MAVEN_OPTS: "-Djansi.force=true -Dhttps.protocols=TLSv1.2 -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Djava.awt.headless=true -XX:ThreadStackSize=1m"
jobs:
# Runs the pom sorter and code formatter to ensure that the code
# is formatted and poms are sorted according to project rules. If changes are found,
# they are committed back to the branch
check-code-formatting:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up JDK ${{env.JAVA_VERSION}}
uses: actions/setup-java@v4
with:
distribution: ${{env.JAVA_DISTRIBUTION}}
java-version: ${{env.JAVA_VERSION}}
maven-version: 3.9.5
cache: 'maven'
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Format code
env:
USER_NAME: ${{ secrets.USER_NAME }}
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
run: |
mvn -s $GITHUB_WORKSPACE/.github/workflows/settings.xml -V -B -e -ntp "-Dstyle.color=always" clean formatter:format sortpom:sort impsort:sort -Dmaven.build.cache.enabled=false -Pautoformat
git status
git diff-index --quiet HEAD || (echo "Modified files found. Creating new commit with formatting fixes" && echo "diffs_found=true" >> "$GITHUB_ENV")
- name: Commit Changes
run: |
if [ "$diffs_found" = true ]; then
git checkout -b ${{ steps.extract_branch.outputs.branch }}
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
git commit -am "Formatting job fix"
git push
else
echo "Nothing to do"
fi
# Build the code and run the unit/integration tests.
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up JDK ${{env.JAVA_VERSION}}
uses: actions/setup-java@v4
with:
distribution: ${{env.JAVA_DISTRIBUTION}}
java-version: ${{env.JAVA_VERSION}}
maven-version: 3.9.5
cache: 'maven'
- name: Build and Run Unit Tests
env:
USER_NAME: ${{ secrets.USER_NAME }}
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
run: |
RUN_TESTS="mvn -s $GITHUB_WORKSPACE/.github/workflows/settings.xml -V -B -e -ntp "-Dstyle.color=always" -Pdev,examples,assemble,spotbugs -Dmaven.build.cache.enabled=false -Ddeploy -Ddist -T1C clean verify"
$RUN_TESTS \
|| { echo "***** TESTS FAILED. Attempting retry."; $RUN_TESTS; } \
|| { echo "***** TESTS FAILED. Attempting final retry."; $RUN_TESTS; }
# This step can be uncommented to support feature development. When developing a
# feature which spans multiple repos, you can update the poms to use the latest
# SNAPSHOT across the board, and run this action as a sanity check to ensure
# everything is working in unison.
# # Build the code and run the microservice unit/integration tests.
# build-and-test-microservices:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout Code
# uses: actions/checkout@v4
# with:
# submodules: 'recursive'
# - name: Set up JDK ${{env.JAVA_VERSION}}
# uses: actions/setup-java@v4
# with:
# distribution: ${{env.JAVA_DISTRIBUTION}}
# java-version: ${{env.JAVA_VERSION}}
# - uses: actions/cache@v4
# with:
# path: ~/.m2/repository
# key: ${{ runner.os }}-maven-build-${{ hashFiles('**/pom.xml') }}
# restore-keys: |
# ${{ runner.os }}-maven-build-
# ${{ runner.os }}-maven-format-
# ${{ runner.os }}-maven-
# - name: Build Project
# env:
# USER_NAME: ${{ secrets.USER_NAME }}
# ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
# run: |
# BUILD="mvn -s $GITHUB_WORKSPACE/.github/workflows/settings.xml -V -B -e -Pdev,examples,assemble,spotbugs -Dmaven.build.cache.enabled=false -DskipServices -Ddeploy -Ddist -T1C -pl "-:config-service" clean install -DskipTests"
# $BUILD
# - name: Run Microservice Unit Tests
# env:
# USER_NAME: ${{ secrets.USER_NAME }}
# ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
# run: |
# RUN_TESTS="mvn -s $GITHUB_WORKSPACE/.github/workflows/settings.xml -V -B -e -Dmaven.build.cache.enabled=false verify"
# cd microservices
# $RUN_TESTS \
# || { echo "***** TESTS FAILED. Attempting retry."; $RUN_TESTS; } \
# || { echo "***** TESTS FAILED. Attempting final retry."; $RUN_TESTS; }
quickstart-build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up JDK ${{env.JAVA_VERSION}}
uses: actions/setup-java@v4
with:
distribution: ${{env.JAVA_DISTRIBUTION}}
java-version: ${{env.JAVA_VERSION}}
maven-version: 3.9.5
cache: 'maven'
# Allow us to use the "--squash" option below
- name: Turn on Docker experimental features and move Docker data root
run: |
if [[ -f /etc/docker/daemon.json ]]; then
sudo sed -ri 's|\s*}\s*$|, "experimental": true, "data-root": "/mnt/docker" }|' /etc/docker/daemon.json
else
echo $'{\n "experimental": true, "data-root": "/mnt/docker"\n}' | sudo tee /etc/docker/daemon.json
fi
sudo systemctl restart docker
echo Docker Experimental Features: $(docker version -f '{{.Server.Experimental}}')
# Builds the quickstart docker image and run the query tests
- name: Quickstart Query Tests
env:
DW_DATAWAVE_BUILD_COMMAND: "mvn -s $GITHUB_WORKSPACE/.github/workflows/settings.xml -B -V -e -ntp -Dstyle.color=always -Dmaven.build.cache.enabled=false -Pdev -Ddeploy -Dtar -DskipTests clean package"
DOCKER_BUILD_OPTS: "--squash --force-rm"
USER_NAME: ${{ secrets.USER_NAME }}
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
run: |
TAG=$(mvn -s $GITHUB_WORKSPACE/.github/workflows/settings.xml -q -N -Dmaven.build.cache.enabled=false -Dexec.executable='echo' -Dexec.args='${project.version}' exec:exec)
contrib/datawave-quickstart/docker/docker-build.sh ${TAG} --docker-opts "${DOCKER_BUILD_OPTS}"
compose-build-and-test-latest-snapshots:
runs-on: ubuntu-latest
steps:
- name: Free up some space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/share/boost
sudo rm -rf $AGENT_TOOLSDIRECTORY
- name: Checkout Code
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Set up JDK ${{env.JAVA_VERSION}}
uses: actions/setup-java@v4
with:
distribution: ${{env.JAVA_DISTRIBUTION}}
java-version: ${{env.JAVA_VERSION}}
maven-version: 3.9.5
cache: 'maven'
# Builds the quickstart and microservice docker images and runs a query test
- name: Docker Compose Query Tests
env:
USER_NAME: ${{ secrets.USER_NAME }}
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
run: |
# update datawave dependencies to use the latest snapshots
mvn -s $GITHUB_WORKSPACE/.github/workflows/settings.xml -B -V -e versions:update-properties versions:update-parent -DallowSnapshots=true -Dincludes=gov.nsa.*
mvn -s $GITHUB_WORKSPACE/.github/workflows/settings.xml -B -V -e -Pcompose -Dmicroservice-docker -Dquickstart-docker -Ddeploy -Dtar -DskipTests clean install
# free up some space so that we don't run out
docker system prune -f
mvn -s $GITHUB_WORKSPACE/.github/workflows/settings.xml -B -V -e -Pcompose -Dmicroservice-docker -Dquickstart-docker -Ddeploy -Dtar -DskipTests clean
cd docker
./bootstrap.sh
attempt=0
max_attempts=20
while [ $attempt -lt $max_attempts ]; do
attempt=$((attempt+1))
echo "Starting docker compose (Attempt ${attempt}/${max_attempts})"
nohup docker compose up -d --no-recreate < /dev/null > compose.out 2>&1 &
sleep 60s
cat compose.out
# check to see if the query service is running
QUERY="$(docker compose ps --status running --services | grep query || true)"
if [ "$QUERY" == "query" ] ; then
echo "Docker compose started successfully"
break
elif [ $attempt -eq $max_attempts ] ; then
echo "Failed to start docker compose"
exit 1
fi
done
cd scripts
./testAll.sh
- name: Dump Logs
if: failure()
run: |
cd docker
docker compose logs
compose-build-and-test:
runs-on: ubuntu-latest
steps:
- name: Free up some space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/share/boost
sudo rm -rf $AGENT_TOOLSDIRECTORY
- name: Checkout Code
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Set up JDK ${{env.JAVA_VERSION}}
uses: actions/setup-java@v4
with:
distribution: ${{env.JAVA_DISTRIBUTION}}
java-version: ${{env.JAVA_VERSION}}
- uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-build-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-build-
${{ runner.os }}-maven-format-
${{ runner.os }}-maven-
# Builds the quickstart and microservice docker images and runs a query test
- name: Docker Compose Query Tests
env:
USER_NAME: ${{ secrets.USER_NAME }}
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
run: |
# set some bogus URLs to trigger dependency download via maven
DIST_URLS="-Durl.zookeeper=https://bogus.apache.org/zookeeper/zookeeper-3.7.2/apache-zookeeper-3.7.2-bin.tar.gz.tar.gz \
-Durl.accumulo=https://bogus.apache.org/accumulo/2.1.3/accumulo-2.1.3-bin.tar.gz \
-Durl.wildfly=https://bogus.jboss.org/wildfly/17.0.1.Final/wildfly-17.0.1.Final.tar.gz \
-Durl.hadoop=https://bogus.apache.org/hadoop/common/hadoop-3.3.6/hadoop-3.3.6.tar.gz \
-Durl.maven=https://bogus.apache.org/maven/maven-3/3.8.8/binaries/apache-maven-3.8.8-bin.tar.gz"
mvn -s $GITHUB_WORKSPACE/.github/workflows/settings.xml -B -V -e -Pcompose -Dmicroservice-docker -Dquickstart-docker -Dquickstart-maven ${DIST_URLS} -Ddeploy -Dtar -DskipTests -Dmaven.build.cache.enabled=false clean install
# free up some space so that we don't run out
docker system prune -f
mvn -s $GITHUB_WORKSPACE/.github/workflows/settings.xml -B -V -e -Pcompose -Dmicroservice-docker -Dquickstart-docker -Dquickstart-maven ${DIST_URLS} -Ddeploy -Dtar -DskipTests -Dmaven.build.cache.enabled=false clean
cd docker
./bootstrap.sh
attempt=0
max_attempts=20
while [ $attempt -lt $max_attempts ]; do
attempt=$((attempt+1))
echo "Starting docker compose (Attempt ${attempt}/${max_attempts})"
nohup docker compose up -d --no-recreate < /dev/null > compose.out 2>&1 &
sleep 60s
cat compose.out
# check to see if the query service is running
QUERY="$(docker compose ps --status running --services | grep query || true)"
if [ "$QUERY" == "query" ] ; then
echo "Docker compose started successfully"
break
elif [ $attempt -eq $max_attempts ] ; then
echo "Failed to start docker compose"
exit 1
fi
done
cd scripts
./testAll.sh
- name: Dump Logs
if: failure()
run: |
cd docker
docker compose logs
# Here's an example of how you'd deploy the image to the github package registry.
# We don't want to do this by default since packages on github cannot be deleted
# or overwritten. So this could only be done for tags, however it seems the quickstart
# image may also exceed the maximum size allowed by github.
# - name: Deploy Quickstart Image
# env:
# IMAGE_REGISTRY: "docker.pkg.github.com"
# IMAGE_USERNAME: "brianloss"
# IMAGE_NAME: "datawave/quickstart"
# USER_NAME: ${{ secrets.USER_NAME }}
# ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
# run: |
# # Set up env vars
# TAG=$(mvn -s $GITHUB_WORKSPACE/.github/workflows/settings.xml -q -N -Dmaven.build.cache.enabled=false -Dexec.executable='echo' -Dexec.args='${project.version}' exec:exec)
# REMOTE_IMAGE_NAME="${IMAGE_REGISTRY}/${IMAGE_USERNAME}/${IMAGE_NAME}"
# # Log in to the package registry
# echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com --username ${GITHUB_ACTOR} --password-stdin
# # Tag and push the image
# docker tag ${IMAGE_NAME}:${TAG} ${REMOTE_IMAGE_NAME}:${TAG}
# docker images
# docker push ${REMOTE_IMAGE_NAME}:${TAG}