Skip to content

Commit fe6f9ac

Browse files
Adds make.sh, Dockerfile, bump task (#1772)
* [Automation] Adds make.sh, Dockerfile, bump task This commit adds a `bump` task to the Makefile, as well as the make.sh script and Dockerfile to automate the bump task. * [Automation] Updates stack version as a variable in validate-pr.yml * [Automation] Updates bump.sh regexp for validate-pr
1 parent 367f257 commit fe6f9ac

File tree

5 files changed

+86
-2
lines changed

5 files changed

+86
-2
lines changed

.ci/Dockerfile

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM node:16
2+
3+
WORKDIR /usr/src/app
4+
5+
RUN pwd
6+
RUN npm install \
7+
make setup

.ci/bump.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
if [[ -z $VERSION ]]; then
4+
echo "Required environment variable VERSION not set"
5+
exit 1;
6+
fi
7+
8+
# If VERSION is x.y.z, set it to x.y
9+
if [[ ${VERSION} =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then
10+
VERSION=${VERSION%.*}
11+
fi
12+
13+
sed -i "s/\(STACK_VERSION:\s\)\([0-9.]\+\)\(-SNAPSHOT\)/\1$VERSION\3/" .github/workflows/validate-pr.yml

.ci/make.sh

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env bash
2+
# ------------------------------------------------------- #
3+
#
4+
# Build entry script for elasticsearch-specification
5+
#
6+
# Must be called: ./.ci/make.sh <target> <params>
7+
#
8+
# Version: 1.1.0
9+
#
10+
# Targets:
11+
# ---------------------------
12+
# bump <VERSION> : bump client internals to version
13+
# ------------------------------------------------------- #
14+
15+
# ------------------------------------------------------- #
16+
# Bootstrap
17+
# ------------------------------------------------------- #
18+
script_path=$(dirname "$(realpath -s "$0")")
19+
repo=$(realpath "$script_path/../")
20+
21+
# shellcheck disable=SC1090
22+
CMD=$1
23+
VERSION=$2
24+
set -euo pipefail
25+
26+
product="elastic/elasticsearch-specification"
27+
case $CMD in
28+
bump)
29+
if [ -v $VERSION ]; then
30+
echo -e "\033[31;1mTARGET: bump -> missing version parameter\033[0m"
31+
exit 1
32+
fi
33+
echo -e "\033[36;1mTARGET: bump to version $VERSION\033[0m"
34+
TASK=bump
35+
# VERSION is BRANCH here for now
36+
TASK_ARGS=("$VERSION")
37+
;;
38+
esac
39+
40+
# ------------------------------------------------------- #
41+
# Build Container
42+
# ------------------------------------------------------- #
43+
44+
echo -e "\033[34;1mINFO: building $product container\033[0m"
45+
docker build -t ${product} ./.ci
46+
47+
# ------------------------------------------------------- #
48+
# Run the Container
49+
# ------------------------------------------------------- #
50+
51+
echo -e "\033[34;1mINFO: running $product container\033[0m"
52+
53+
docker run \
54+
--env "VERSION=${VERSION}" \
55+
--volume "${repo}:/usr/src/app" \
56+
--rm \
57+
"${product}" \
58+
make $TASK

.github/workflows/validate-pr.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ jobs:
1717
name: build
1818
if: github.repository_owner == 'elastic' # this action will fail if executed from a fork
1919
runs-on: ubuntu-latest
20+
env:
21+
STACK_VERSION: 8.4-SNAPSHOT
2022

2123
steps:
2224
- uses: actions/checkout@v2
@@ -52,7 +54,7 @@ jobs:
5254
working-directory: ./clients-flight-recorder
5355
run: |
5456
node scripts/upload-recording/download.js --branch latest
55-
node scripts/clone-elasticsearch/index.js --version 8.4-SNAPSHOT
57+
node scripts/clone-elasticsearch/index.js --version ${{ env.STACK_VERSION }}
5658
env:
5759
GCS_CREDENTIALS: ${{ secrets.GCS_CREDENTIALS }}
5860

@@ -67,4 +69,4 @@ jobs:
6769

6870
- name: Run validation
6971
working-directory: ./elasticsearch-specification
70-
run: node .github/validate-pr --token ${{ secrets.GITHUB_TOKEN }} --version 8.4-SNAPSHOT
72+
run: node .github/validate-pr --token ${{ secrets.GITHUB_TOKEN }} --version ${{ env.STACK_VERSION }}

Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ transform-expand-generics: ## Create a new schema with all generics expanded
4949

5050
contrib: | generate license-check spec-format-fix ## Pre contribution target
5151

52+
bump:
53+
@echo ">> bumping..."
54+
.ci/bump.sh
55+
5256
help: ## Display help
5357
@awk 'BEGIN {FS = ":.*##"; printf "Usage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
5458
#------------- <https://suva.sh/posts/well-documented-makefiles> --------------

0 commit comments

Comments
 (0)