forked from aws/serverless-java-container
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gha_build.sh
executable file
·94 lines (86 loc) · 2.72 KB
/
gha_build.sh
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
#!/usr/bin/env bash
WORKING_DIR=$(pwd)
FRAMEWORK=$1
RUN_ARCHETYPE=$2
RUN_SAMPLES=$3
EXTRA_PARAMS=${*:4}
echo "Starting build script for ${FRAMEWORK} with params ${EXTRA_PARAMS}"
if [[ -z ${FRAMEWORK} ]] ; then
echo "Missing framework parameter"
exit 1
fi
function install {
# we skip tests for core because we assume they will be run in a separate branch of the workflow
cd ${WORKING_DIR}/aws-serverless-java-container-core && mvn -q clean install -DskipTests
if [[ "$?" -ne 0 ]]; then
exit 1
fi
cd ${WORKING_DIR}/aws-serverless-java-container-$1 && mvn -q clean install ${@:2}
if [[ "$?" -ne 0 ]]; then
exit 1
fi
}
function archetype {
ARCHETYPE_NAME=aws-serverless-$1-archetype
PROJ_NAME=$1-archetype-test
cd ${WORKING_DIR}/${ARCHETYPE_NAME} && mvn -q clean install
ARCHETYPE_TEST_DIR=${WORKING_DIR}/$1_archetype_test
mkdir -p ${ARCHETYPE_TEST_DIR}
cd ${ARCHETYPE_TEST_DIR} && mvn archetype:generate -DgroupId=my.service -DartifactId=${PROJ_NAME} -Dversion=1.0-SNAPSHOT \
-DarchetypeGroupId=com.amazonaws.serverless.archetypes \
-DarchetypeArtifactId=${ARCHETYPE_NAME} \
-DarchetypeCatalog=local \
-DinteractiveMode=false
if [[ "$?" -ne 0 ]]; then
exit 1
fi
cd ${ARCHETYPE_TEST_DIR}/${PROJ_NAME} && mvn -q clean package -Pshaded-jar
if [[ "$?" -ne 0 ]]; then
exit 1
fi
cd ${ARCHETYPE_TEST_DIR}/${PROJ_NAME} && mvn -q clean package
if [[ "$?" -ne 0 ]]; then
exit 1
fi
cd ${ARCHETYPE_TEST_DIR}/${PROJ_NAME} && gradle -q wrapper
if [[ "$?" -ne 0 ]]; then
exit 1
fi
cd ${ARCHETYPE_TEST_DIR}/${PROJ_NAME} && ./gradlew wrapper --gradle-version 5.0
if [[ "$?" -ne 0 ]]; then
exit 1
fi
cd ${ARCHETYPE_TEST_DIR}/${PROJ_NAME} && ./gradlew -q clean build
if [[ "$?" -ne 0 ]]; then
exit 1
fi
}
function sample {
# force to pet store for now. In the future we may loop over all samples
SAMPLE_FOLDER=${WORKING_DIR}/samples/$1/pet-store
cd ${SAMPLE_FOLDER} && mvn -q clean package
if [[ "$?" -ne 0 ]]; then
exit 1
fi
cd ${SAMPLE_FOLDER} && gradle -q wrapper
if [[ "$?" -ne 0 ]]; then
exit 1
fi
cd ${SAMPLE_FOLDER} && ./gradlew wrapper --gradle-version 5.0
if [[ "$?" -ne 0 ]]; then
exit 1
fi
cd ${SAMPLE_FOLDER} && ./gradlew -q clean build
if [[ "$?" -ne 0 ]]; then
exit 1
fi
}
# set up the master pom otherwise we won't be able to find new dependencies
cd ${WORKING_DIR}/ && mvn -q --non-recursive clean install
install ${FRAMEWORK} ${EXTRA_PARAMS}
if [[ "$RUN_ARCHETYPE" = true ]] ; then
archetype ${FRAMEWORK}
fi
if [[ "$RUN_SAMPLES" = true ]] ; then
sample ${FRAMEWORK}
fi