Repository navigation
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·55 lines (53 loc) · 2.41 KB
/
Copy pathtest.sh
File metadata and controls
executable file
·55 lines (53 loc) · 2.41 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
#!/usr/bin/env bash
# Formats the generated sources, then runs every check without changing them: the Java 8 compile,
# tests, packaging, the formatting check and Checkstyle. CI runs this for the Java target.
#
# FILES_SDK_SET_RELEASE_VERSION=1: after formatting, also give the project the release line in
# _VERSION, as build.sh does, so that the checks package it under that version. CI's build-java
# runs this in place of test.sh followed by build.sh, which would format and package it again.
set -euo pipefail
cd "$(dirname "$0")"
# OpenRewrite formats and checks only the sources that the nearest Git repository at or above the
# build does not both ignore and leave untracked. Generated in the generator's checkout, whose
# .gitignore ignores generated/, the SDK would be skipped, so it gets a repository of its own when the
# enclosing repository ignores it. An SDK with its own .git (a clone, worktree or submodule) and a copy
# outside any repository are left as they are, without needing Git.
if [ ! -e .git ]; then
enclosing=$(pwd -P)
until [ -e "$enclosing/.git" ] || [ "$enclosing" = / ]; do
enclosing=$(dirname "$enclosing")
done
if [ -e "$enclosing/.git" ]; then
if ! command -v git > /dev/null; then
echo "$0: Git is needed to keep $enclosing/.git from hiding the sources from formatting" >&2
exit 1
fi
ignored=0
(unset GIT_DIR GIT_WORK_TREE; git check-ignore -- pom.xml src > /dev/null) || ignored=$?
if [ "$ignored" -eq 0 ]; then
(unset GIT_DIR GIT_WORK_TREE; git init -q)
elif [ "$ignored" -ne 1 ]; then
echo "$0: Git could not tell whether $enclosing/.git ignores the sources" >&2
exit 1
fi
fi
fi
. ./build-jdk.sh
./mvnw -B -ntp -V rewrite:run
if [ "${FILES_SDK_SET_RELEASE_VERSION:-}" = 1 ]; then
./mvnw -B -ntp -DnewVersion="$(cat _VERSION)" -DgenerateBackupPoms=false versions:set
fi
# FilesApiTest runs against WireMock servers on JDK 17 (see test-server/servers.sh) unless the
# caller already runs them and set their URLs. Servers this script started are stopped when it
# exits; failing to stop them fails the run without replacing an earlier failure's status.
stop_test_servers() {
local status=$?
./test-server/servers.sh stop || [ "$status" -ne 0 ] || status=1
exit "$status"
}
if [ -z "${FILES_TEST_SERVER_URL:-}" ]; then
./test-server/servers.sh start || exit 1
trap stop_test_servers EXIT
. ./test-server/target/servers.env
fi
./mvnw -B -ntp verify