diff --git a/.ci/Dockerfile b/.ci/Dockerfile new file mode 100644 index 0000000000..c114c1dded --- /dev/null +++ b/.ci/Dockerfile @@ -0,0 +1,7 @@ +FROM node:16 + +WORKDIR /usr/src/app + +RUN pwd +RUN npm install \ + make setup diff --git a/.ci/bump.sh b/.ci/bump.sh new file mode 100755 index 0000000000..6c434a1932 --- /dev/null +++ b/.ci/bump.sh @@ -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 diff --git a/.ci/make.sh b/.ci/make.sh new file mode 100755 index 0000000000..9818c454e2 --- /dev/null +++ b/.ci/make.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash +# ------------------------------------------------------- # +# +# Build entry script for elasticsearch-specification +# +# Must be called: ./.ci/make.sh +# +# Version: 1.1.0 +# +# Targets: +# --------------------------- +# bump : 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 diff --git a/.github/workflows/validate-pr.yml b/.github/workflows/validate-pr.yml index dc377def90..663303df60 100644 --- a/.github/workflows/validate-pr.yml +++ b/.github/workflows/validate-pr.yml @@ -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 @@ -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 }} @@ -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 }} diff --git a/Makefile b/Makefile index 727920e325..4b57b7f71a 100644 --- a/Makefile +++ b/Makefile @@ -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\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) #------------- --------------