Skip to content

Commit 62304ec

Browse files
committed
Assemble command in .ci/make.sh
1 parent 3481969 commit 62304ec

File tree

2 files changed

+183
-1
lines changed

2 files changed

+183
-1
lines changed

.ci/make.sh

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
#!/usr/bin/env bash
2+
3+
# ------------------------------------------------------- #
4+
#
5+
# Skeleton for common build entry script for all elastic
6+
# clients. Needs to be adapted to individual client usage.
7+
#
8+
# Must be called: ./.ci/make.sh <target> <params>
9+
#
10+
# Version: 1.1.0
11+
#
12+
# Targets:
13+
# ---------------------------
14+
# assemble <VERSION> : build client artefacts with version
15+
# bump <VERSION> : bump client internals to version
16+
# codegen <VERSION> : generate endpoints
17+
# docsgen <VERSION> : generate documentation
18+
# examplegen : generate the doc examples
19+
# clean : clean workspace
20+
#
21+
# ------------------------------------------------------- #
22+
23+
# ------------------------------------------------------- #
24+
# Bootstrap
25+
# ------------------------------------------------------- #
26+
27+
script_path=$(dirname "$(realpath -s "$0")")
28+
repo=$(realpath "$script_path/../")
29+
30+
# shellcheck disable=SC1090
31+
CMD=$1
32+
TASK=$1
33+
TASK_ARGS=()
34+
VERSION=$2
35+
STACK_VERSION=$VERSION
36+
set -euo pipefail
37+
38+
product="elastic/elasticsearch-php"
39+
output_folder=".ci/output"
40+
codegen_folder=".ci/output"
41+
OUTPUT_DIR="$repo/${output_folder}"
42+
REPO_BINDING="${OUTPUT_DIR}:/sln/${output_folder}"
43+
mkdir -p "$OUTPUT_DIR"
44+
45+
echo -e "\033[34;1mINFO:\033[0m PRODUCT ${product}\033[0m"
46+
echo -e "\033[34;1mINFO:\033[0m VERSION ${STACK_VERSION}\033[0m"
47+
echo -e "\033[34;1mINFO:\033[0m OUTPUT_DIR ${OUTPUT_DIR}\033[0m"
48+
49+
# ------------------------------------------------------- #
50+
# Parse Command
51+
# ------------------------------------------------------- #
52+
53+
case $CMD in
54+
clean)
55+
echo -e "\033[36;1mTARGET: clean workspace $output_folder\033[0m"
56+
rm -rfv "$output_folder"
57+
echo -e "\033[32;1mTARGET: clean - done.\033[0m"
58+
exit 0
59+
;;
60+
assemble)
61+
if [ -v $VERSION ]; then
62+
echo -e "\033[31;1mTARGET: assemble -> missing version parameter\033[0m"
63+
exit 1
64+
fi
65+
echo -e "\033[36;1mTARGET: assemble artefact $VERSION\033[0m"
66+
TASK=release
67+
TASK_ARGS=("$VERSION" "$output_folder")
68+
;;
69+
codegen)
70+
if [ -v $VERSION ]; then
71+
echo -e "\033[31;1mTARGET: codegen -> missing version parameter\033[0m"
72+
exit 1
73+
fi
74+
echo -e "\033[36;1mTARGET: codegen API v$VERSION\033[0m"
75+
TASK=codegen
76+
# VERSION is BRANCH here for now
77+
TASK_ARGS=("$VERSION" "$codegen_folder")
78+
;;
79+
docsgen)
80+
if [ -v $VERSION ]; then
81+
echo -e "\033[31;1mTARGET: docsgen -> missing version parameter\033[0m"
82+
exit 1
83+
fi
84+
echo -e "\033[36;1mTARGET: generate docs for $VERSION\033[0m"
85+
TASK=codegen
86+
# VERSION is BRANCH here for now
87+
TASK_ARGS=("$VERSION" "$codegen_folder")
88+
;;
89+
examplesgen)
90+
echo -e "\033[36;1mTARGET: generate examples\033[0m"
91+
TASK=codegen
92+
# VERSION is BRANCH here for now
93+
TASK_ARGS=("$VERSION" "$codegen_folder")
94+
;;
95+
bump)
96+
if [ -v $VERSION ]; then
97+
echo -e "\033[31;1mTARGET: bump -> missing version parameter\033[0m"
98+
exit 1
99+
fi
100+
echo -e "\033[36;1mTARGET: bump to version $VERSION\033[0m"
101+
TASK=bump
102+
# VERSION is BRANCH here for now
103+
TASK_ARGS=("$VERSION")
104+
;;
105+
*)
106+
echo -e "\nUsage:\n\t $CMD is not supported right now\n"
107+
exit 1
108+
esac
109+
110+
111+
# ------------------------------------------------------- #
112+
# Build Container
113+
# ------------------------------------------------------- #
114+
115+
#echo -e "\033[34;1mINFO: building $product container\033[0m"
116+
117+
#docker build --file .ci/Dockerfile --tag ${product} \
118+
# --build-arg USER_ID="$(id -u)" \
119+
# --build-arg GROUP_ID="$(id -g)" .
120+
121+
122+
# ------------------------------------------------------- #
123+
# Run the Container
124+
# ------------------------------------------------------- #
125+
126+
#echo -e "\033[34;1mINFO: running $product container\033[0m"
127+
128+
#docker run \
129+
# --env "DOTNET_VERSION" \
130+
# --name test-runner \
131+
# --volume $REPO_BINDING \
132+
# --rm \
133+
# $product \
134+
# /bin/bash -c "./build.sh $TASK ${TASK_ARGS[*]} && chown -R $(id -u):$(id -g) ."
135+
136+
# ------------------------------------------------------- #
137+
# Post Command tasks & checks
138+
# ------------------------------------------------------- #
139+
140+
if [[ "$CMD" == "assemble" ]]; then
141+
artefact_name="elasticsearch-php-${VERSION}"
142+
echo -e "\033[34;1mINFO: copy artefacts\033[0m"
143+
rsync -arv --exclude=.ci --exclude=.git --filter=':- .gitignore' "$PWD" "${output_folder}/."
144+
145+
echo -e "\033[34;1mINFO: rename artefacts\033[0m"
146+
mv -v "${output_folder}/elasticsearch-php" "${output_folder}/${artefact_name}"
147+
148+
echo -e "\033[34;1mINFO: build artefacts\033[0m"
149+
cd ./.ci/output && tar -czvf ${artefact_name}.tar.gz "${artefact_name}/." && cd -
150+
151+
echo -e "\033[34;1mINFO: cleanup\033[0m"
152+
rm -Rf "${output_folder}/${artefact_name}"
153+
154+
echo -e "\033[34;1mINFO: validate artefact\033[0m"
155+
proof=`ls ${output_folder}`
156+
157+
if [ $proof == "${artefact_name}.tar.gz" ]; then
158+
echo -e "\033[32;1mTARGET: assemble - success: $artefact_name.tar.gz\033[0m"
159+
else
160+
echo -e "\033[31;1mTARGET: assemble failed, empty workspace!\033[0m"
161+
exit 1
162+
fi
163+
fi
164+
165+
if [[ "$CMD" == "bump" ]]; then
166+
echo "TODO"
167+
fi
168+
169+
if [[ "$CMD" == "codegen" ]]; then
170+
echo "TODO"
171+
fi
172+
173+
if [[ "$CMD" == "docsgen" ]]; then
174+
echo "TODO"
175+
fi
176+
177+
if [[ "$CMD" == "examplesgen" ]]; then
178+
echo "TODO"
179+
fi

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,7 @@ build
4545
tests/*-junit.xml
4646

4747
# YAML tests
48-
tests/Elasticsearch/Tests/Yaml
48+
tests/Elasticsearch/Tests/Yaml
49+
50+
# Exclude .ci/make.sh artifcats
51+
.ci/output

0 commit comments

Comments
 (0)