Skip to content

Commit 0c93aaf

Browse files
[7.12] Build dists in Docker during make.sh assemble
Co-authored-by: Seth Michael Larson <seth.larson@elastic.co>
1 parent 38ffd7c commit 0c93aaf

File tree

3 files changed

+189
-32
lines changed

3 files changed

+189
-32
lines changed

.ci/make.sh

Lines changed: 160 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,166 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

3-
set -eo pipefail
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+
# ------------------------------------------------------- #
422

5-
BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
6-
BASE_DIR="$( dirname "$BASE_DIR" )"
23+
# ------------------------------------------------------- #
24+
# Bootstrap
25+
# ------------------------------------------------------- #
726

8-
if [[ "$1" == "assemble" ]]; then
9-
mkdir -p $BASE_DIR/.ci/output
10-
docker build . --tag elastic/elasticsearch-py -f .ci/Dockerfile
11-
docker run --rm -v $BASE_DIR/.ci/output:/code/elasticsearch-py/dist \
12-
elastic/elasticsearch-py \
13-
python /code/elasticsearch-py/utils/build-dists.py $2
14-
cd ./.ci/output && tar -czvf elasticsearch-py-$2.tar.gz * && cd -
15-
exit 0
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-py"
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 -rf "$output_folder"
57+
echo -e "\033[32;1mdone.\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 \
118+
--file $repo/.ci/Dockerfile \
119+
--tag ${product} \
120+
.
121+
122+
# ------------------------------------------------------- #
123+
# Run the Container
124+
# ------------------------------------------------------- #
125+
126+
echo -e "\033[34;1mINFO: running $product container\033[0m"
127+
128+
if [[ "$CMD" == "assemble" ]]; then
129+
130+
# Build dists into .ci/output
131+
docker run \
132+
--rm -v $repo/.ci/output:/code/elasticsearch-py/dist \
133+
$product \
134+
/bin/bash -c "python /code/elasticsearch-py/utils/build-dists.py $VERSION"
135+
136+
# Verify that there are dists in .ci/output
137+
if compgen -G ".ci/output/*" > /dev/null; then
138+
139+
# Tarball everything up in .ci/output
140+
cd $repo/.ci/output && tar -czvf elasticsearch-py-$VERSION.tar.gz * && cd -
141+
142+
echo -e "\033[32;1mTARGET: successfully assembled client v$VERSION\033[0m"
143+
exit 0
144+
else
145+
echo -e "\033[31;1mTARGET: assemble failed, empty workspace!\033[0m"
146+
exit 1
147+
fi
148+
fi
149+
150+
if [[ "$CMD" == "bump" ]]; then
151+
echo "TODO"
152+
fi
153+
154+
if [[ "$CMD" == "codegen" ]]; then
155+
echo "TODO"
156+
fi
157+
158+
if [[ "$CMD" == "docsgen" ]]; then
159+
echo "TODO"
160+
fi
161+
162+
if [[ "$CMD" == "examplesgen" ]]; then
163+
echo "TODO"
16164
fi
17165

18166
echo "Must be called with '.ci/make.sh [command]"

.github/workflows/ci.yml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,6 @@ name: CI
44
on: [push, pull_request]
55

66
jobs:
7-
package:
8-
runs-on: ubuntu-latest
9-
steps:
10-
- name: Checkout Repository
11-
uses: actions/checkout@v1
12-
- name: Set up Python 3.7
13-
uses: actions/setup-python@v1
14-
with:
15-
python-version: 3.7
16-
- name: Install dependencies
17-
run: |
18-
python3.7 -m pip install setuptools wheel twine
19-
- name: Build packages
20-
run: |
21-
python3.7 utils/build-dists.py
22-
- name: Check packages
23-
run: |
24-
set -exo pipefail;
25-
if [ $(python3.7 -m twine check dist/* | grep -c 'warning') != 0 ]; then exit 1; fi
26-
277
lint:
288
runs-on: ubuntu-latest
299
steps:

.github/workflows/unified-release.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Unified Release
2+
3+
on:
4+
pull_request:
5+
paths-ignore:
6+
- 'README.md'
7+
push:
8+
paths-ignore:
9+
- 'README.md'
10+
branches:
11+
- main
12+
- master
13+
- '[0-9]+.[0-9]+'
14+
- '[0-9]+.x'
15+
16+
jobs:
17+
assemble:
18+
name: Assemble
19+
runs-on: ubuntu-latest
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
stack_version: ['7.12-SNAPSHOT']
24+
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v2
28+
- run: "./.ci/make.sh assemble ${{ matrix.stack_version }}"
29+
name: Assemble ${{ matrix.stack_version }}

0 commit comments

Comments
 (0)