-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[CI] Add pipeline task queue framework and merge workers into one #64011
Changes from 1 commit
146946b
2dda2db
d651e8e
7fa0b0b
09f17a8
6fb7275
e4f7b45
b71e339
b975fbf
09ca5bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
ARG NODE_VERSION=10.21.0 | ||
|
||
FROM node:${NODE_VERSION} AS base | ||
|
||
RUN apt-get update && \ | ||
apt-get -y install xvfb gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 \ | ||
libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 \ | ||
libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 \ | ||
libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 \ | ||
libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget openjdk-8-jre && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
RUN curl -sSL https://dl.google.com/linux/linux_signing_key.pub | apt-key add - \ | ||
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \ | ||
&& apt-get update \ | ||
&& apt-get install -y rsync jq bsdtar google-chrome-stable \ | ||
--no-install-recommends \ | ||
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
|
||
RUN LATEST_VAULT_RELEASE=$(curl -s https://api.github.com/repos/hashicorp/vault/tags | jq --raw-output .[0].name[1:]) \ | ||
&& curl -L https://releases.hashicorp.com/vault/${LATEST_VAULT_RELEASE}/vault_${LATEST_VAULT_RELEASE}_linux_amd64.zip -o vault.zip \ | ||
&& unzip vault.zip \ | ||
&& rm vault.zip \ | ||
&& chmod +x vault \ | ||
&& mv vault /usr/local/bin/vault | ||
|
||
RUN groupadd -r kibana && useradd -r -g kibana kibana && mkdir /home/kibana && chown kibana:kibana /home/kibana | ||
|
||
COPY ./bash_standard_lib.sh /usr/local/bin/bash_standard_lib.sh | ||
RUN chmod +x /usr/local/bin/bash_standard_lib.sh | ||
|
||
COPY ./runbld /usr/local/bin/runbld | ||
RUN chmod +x /usr/local/bin/runbld | ||
|
||
USER kibana |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
#! /usr/bin/env bash | ||
|
||
# Readonly vars | ||
readonly CACHE_DIR="${HOME}/.git-references" | ||
|
||
# Global vars | ||
declare -a cloned_git_repos | ||
|
||
#============================================================================== | ||
# | ||
# What: A library of standard Bash functions | ||
# Why: Simplify and improve the quality of bash scripts being produced. | ||
# | ||
#============================================================================== | ||
|
||
# cache_maven_deps function | ||
# ------------------------------------- | ||
# Run a `mvnw compile` in order to populate the local | ||
# m2 repository. | ||
# | ||
# Expects a single param which is a project directory to change into | ||
# ------------------------------------- | ||
cache_maven_deps() { | ||
local project=$1 | ||
|
||
# Check that 'project' dir exists | ||
if [[ ! -d $project ]]; then | ||
printf 'Project dir %s doesn''t exist. Exiting...\n' $project >&2 | ||
exit 1 | ||
fi | ||
|
||
# Switch directory, and run mvnw compile | ||
pushd $project | ||
./mvnw compile | ||
popd | ||
} | ||
|
||
# clean_git_repo_clones function | ||
# ------------------------------------- | ||
# Clean up any Git repo clones performed by the 'clone_git_repo' function. | ||
# Should be called by the 'EXIT' trap. | ||
# ------------------------------------- | ||
clean_git_repo_clones() { | ||
printf 'Cleaning cloned git repos...\n' | ||
|
||
# Loop over cloned repos and remove them... | ||
for cloned_repo in "${cloned_git_repos[@]}" | ||
do | ||
printf 'Removing repo %s\n' "$cloned_repo" | ||
rm -rf $cloned_repo | ||
done | ||
} | ||
|
||
# clone_git_repo function | ||
# ------------------------------------- | ||
# Clone a Git repo, using either a Git SSH source, or a repo short-name. | ||
# If a matching local reference repo is found, then that will be used as the `--reference` for the Git clone, | ||
# otherwise a full clone is undertaken. | ||
# | ||
# Expects a single param which is the repo name or repo SSH source | ||
# ------------------------------------- | ||
clone_git_repo() { | ||
local repo=$1 | ||
local repo_name | ||
local repo_url | ||
|
||
# Calculate the "humanish" part of the source repo | ||
repo_name=$(echo "$repo" | sed -e 's|/$||' -e 's|:*/*\.git$||' -e 's|.*[/:]||g') | ||
local mirror_dir="${CACHE_DIR}/${repo_name}.git" | ||
|
||
# If $repo is a SSH repo source, use it as the repo_url. | ||
# Otherwise, attempt to get the origin URL from the matching reference repo, failing if the reference repo is not present. | ||
if [[ $repo == git* ]]; then | ||
repo_url=$repo | ||
else | ||
if [[ -d $mirror_dir ]]; then | ||
repo_url=$(cd "$mirror_dir" && git remote get-url origin) | ||
else | ||
printf 'Attempting to clone %s using the short-name, however no matching reference repo found. Exiting...\n' "$repo" >&2 | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# Check if we have a reference repo clone for this repo, | ||
# and use it for the clone if we do. | ||
# Otherwise clone the repo directly. | ||
if [[ -d $mirror_dir ]]; then | ||
printf 'Cloning repo %s using reference repo...\n' "$repo" | ||
git clone -q --reference "$mirror_dir" "$repo_url" || exit 1 | ||
else | ||
printf 'Cloning repo %s directly...' "$repo" | ||
git clone -q "$repo_url" || exit 1 | ||
fi | ||
|
||
# Add repo to cloned repo array | ||
cloned_git_repos+=("$repo") | ||
|
||
# Clean up clone on exit | ||
trap clean_git_repo_clones EXIT | ||
} | ||
|
||
# retry function | ||
# ------------------------------------- | ||
# Retry a command for a specified number of times until the command exits successfully. | ||
# Retry wait period backs off exponentially after each retry. | ||
# | ||
# The first argument should be the number of retries. | ||
# Remainder is treated as the command to execute. | ||
# ------------------------------------- | ||
retry() { | ||
local retries=$1 | ||
shift | ||
|
||
local count=0 | ||
until "$@"; do | ||
exit=$? | ||
wait=$((2 ** $count)) | ||
count=$(($count + 1)) | ||
if [ $count -lt $retries ]; then | ||
printf "Retry %s/%s exited %s, retrying in %s seconds...\n" "$count" "$retries" "$exit" "$wait" >&2 | ||
sleep $wait | ||
else | ||
printf "Retry %s/%s exited %s, no more retries left.\n" "$count" "$retries" "$exit" >&2 | ||
return $exit | ||
fi | ||
done | ||
return 0 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,10 +7,14 @@ function checkout_sibling { | |
targetDir=$2 | ||
useExistingParamName=$3 | ||
useExisting="$(eval "echo "\$$useExistingParamName"")" | ||
repoAddress="git@github.com:" | ||
if [[ "$USE_HTTPS_CLONE" ]]; then | ||
repoAddress="https://github.com/" | ||
fi | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there something using this? Now that we are only referencing public repos we should be able to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we could switch them, yeah. Nothing is actually using the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it works then I'm game |
||
|
||
if [ -z ${useExisting:+x} ]; then | ||
if [ -d "$targetDir" ]; then | ||
echo "I expected a clean workspace but an '${project}' sibling directory already exists in [$PARENT_DIR]!" | ||
echo "I expected a clean workspace but an '${project}' sibling directory already exists in [$WORKSPACE]!" | ||
echo | ||
echo "Either define '${useExistingParamName}' or remove the existing '${project}' sibling." | ||
exit 1 | ||
|
@@ -21,8 +25,9 @@ function checkout_sibling { | |
cloneBranch="" | ||
|
||
function clone_target_is_valid { | ||
|
||
echo " -> checking for '${cloneBranch}' branch at ${cloneAuthor}/${project}" | ||
if [[ -n "$(git ls-remote --heads "git@github.com:${cloneAuthor}/${project}.git" ${cloneBranch} 2>/dev/null)" ]]; then | ||
if [[ -n "$(git ls-remote --heads "${repoAddress}${cloneAuthor}/${project}.git" ${cloneBranch} 2>/dev/null)" ]]; then | ||
return 0 | ||
else | ||
return 1 | ||
|
@@ -71,7 +76,7 @@ function checkout_sibling { | |
fi | ||
|
||
echo " -> checking out '${cloneBranch}' branch from ${cloneAuthor}/${project}..." | ||
git clone -b "$cloneBranch" "git@github.com:${cloneAuthor}/${project}.git" "$targetDir" --depth=1 | ||
git clone -b "$cloneBranch" "${repoAddress}${cloneAuthor}/${project}.git" "$targetDir" --depth=1 | ||
echo " -> checked out ${project} revision: $(git -C "${targetDir}" rev-parse HEAD)" | ||
echo | ||
} | ||
|
@@ -87,12 +92,12 @@ function checkout_sibling { | |
fi | ||
} | ||
|
||
checkout_sibling "elasticsearch" "${PARENT_DIR}/elasticsearch" "USE_EXISTING_ES" | ||
checkout_sibling "elasticsearch" "${WORKSPACE}/elasticsearch" "USE_EXISTING_ES" | ||
export TEST_ES_FROM=${TEST_ES_FROM:-snapshot} | ||
|
||
# Set the JAVA_HOME based on the Java property file in the ES repo | ||
# This assumes the naming convention used on CI (ex: ~/.java/java10) | ||
ES_DIR="$PARENT_DIR/elasticsearch" | ||
ES_DIR="$WORKSPACE/elasticsearch" | ||
ES_JAVA_PROP_PATH=$ES_DIR/.ci/java-versions.properties | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
source src/dev/ci_setup/setup_env.sh | ||
|
||
yarn run grunt run:checkDocApiChanges |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
source src/dev/ci_setup/setup_env.sh | ||
|
||
yarn run grunt run:checkFileCasing |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
source src/dev/ci_setup/setup_env.sh | ||
|
||
yarn run grunt run:i18nCheck |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
source src/dev/ci_setup/setup_env.sh | ||
|
||
yarn run grunt run:licenses |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
source src/dev/ci_setup/setup_env.sh | ||
|
||
yarn run grunt run:checkLockfileSymlinks |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
source src/dev/ci_setup/setup_env.sh | ||
|
||
yarn run grunt run:test_hardening |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
source src/dev/ci_setup/setup_env.sh | ||
|
||
yarn run grunt run:test_projects |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
source src/dev/ci_setup/setup_env.sh | ||
|
||
yarn run grunt run:checkTsProjects |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
source src/dev/ci_setup/setup_env.sh | ||
|
||
yarn run grunt run:typeCheck |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reason we're copying this script here? Feels like we could copy it into the .ci directory from wherever it is on the worker just like we do for runbld.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good idea.. I copied this in like a month ago, but just created the runbld pattern yesterday or today. I'll switch it.