Skip to content

Adds make.sh, Dockerfile, bump task #1772

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .ci/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM node:16

WORKDIR /usr/src/app

RUN pwd
RUN npm install \
make setup
13 changes: 13 additions & 0 deletions .ci/bump.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

if [[ -z $VERSION ]]; then
echo "Required environment variable VERSION not set"
exit 1;
fi

# If VERSION is x.y.z, set it to x.y
if [[ ${VERSION} =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then
VERSION=${VERSION%.*}
fi

sed -i "s/\(STACK_VERSION:\s\)\([0-9.]\+\)\(-SNAPSHOT\)/\1$VERSION\3/" .github/workflows/validate-pr.yml
58 changes: 58 additions & 0 deletions .ci/make.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env bash
# ------------------------------------------------------- #
#
# Build entry script for elasticsearch-specification
#
# Must be called: ./.ci/make.sh <target> <params>
#
# Version: 1.1.0
#
# Targets:
# ---------------------------
# bump <VERSION> : bump client internals to version
# ------------------------------------------------------- #

# ------------------------------------------------------- #
# Bootstrap
# ------------------------------------------------------- #
script_path=$(dirname "$(realpath -s "$0")")
repo=$(realpath "$script_path/../")

# shellcheck disable=SC1090
CMD=$1
VERSION=$2
set -euo pipefail

product="elastic/elasticsearch-specification"
case $CMD in
bump)
if [ -v $VERSION ]; then
echo -e "\033[31;1mTARGET: bump -> missing version parameter\033[0m"
exit 1
fi
echo -e "\033[36;1mTARGET: bump to version $VERSION\033[0m"
TASK=bump
# VERSION is BRANCH here for now
TASK_ARGS=("$VERSION")
;;
esac

# ------------------------------------------------------- #
# Build Container
# ------------------------------------------------------- #

echo -e "\033[34;1mINFO: building $product container\033[0m"
docker build -t ${product} ./.ci

# ------------------------------------------------------- #
# Run the Container
# ------------------------------------------------------- #

echo -e "\033[34;1mINFO: running $product container\033[0m"

docker run \
--env "VERSION=${VERSION}" \
--volume "${repo}:/usr/src/app" \
--rm \
"${product}" \
make $TASK
6 changes: 4 additions & 2 deletions .github/workflows/validate-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
name: build
if: github.repository_owner == 'elastic' # this action will fail if executed from a fork
runs-on: ubuntu-latest
env:
STACK_VERSION: 8.4-SNAPSHOT

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -52,7 +54,7 @@ jobs:
working-directory: ./clients-flight-recorder
run: |
node scripts/upload-recording/download.js --branch latest
node scripts/clone-elasticsearch/index.js --version 8.4-SNAPSHOT
node scripts/clone-elasticsearch/index.js --version ${{ env.STACK_VERSION }}
env:
GCS_CREDENTIALS: ${{ secrets.GCS_CREDENTIALS }}

Expand All @@ -67,4 +69,4 @@ jobs:

- name: Run validation
working-directory: ./elasticsearch-specification
run: node .github/validate-pr --token ${{ secrets.GITHUB_TOKEN }} --version 8.4-SNAPSHOT
run: node .github/validate-pr --token ${{ secrets.GITHUB_TOKEN }} --version ${{ env.STACK_VERSION }}
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ transform-expand-generics: ## Create a new schema with all generics expanded

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

bump:
@echo ">> bumping..."
.ci/bump.sh

help: ## Display help
@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)
#------------- <https://suva.sh/posts/well-documented-makefiles> --------------
Expand Down