Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Merge pull request #9748 from EOSIO/release/2.0.x
Browse files Browse the repository at this point in the history
Merge release/2.0.x into master
  • Loading branch information
heifner authored Dec 7, 2020
2 parents 0d87dff + c5a0f8e commit 617cea2
Show file tree
Hide file tree
Showing 76 changed files with 1,790 additions and 365 deletions.
67 changes: 43 additions & 24 deletions .cicd/build.sh
Original file line number Diff line number Diff line change
@@ -1,39 +1,48 @@
#!/bin/bash
set -eo pipefail
[[ "$ENABLE_INSTALL" == 'true' ]] || echo '--- :evergreen_tree: Configuring Environment'
. ./.cicd/helpers/general.sh
mkdir -p $BUILD_DIR
CMAKE_EXTRAS="-DCMAKE_BUILD_TYPE='Release' -DENABLE_MULTIVERSION_PROTOCOL_TEST=true -DBUILD_MONGO_DB_PLUGIN=true"
if [[ "$(uname)" == 'Darwin' && $FORCE_LINUX != true ]]; then
mkdir -p "$BUILD_DIR"
CMAKE_EXTRAS="-DCMAKE_BUILD_TYPE=\"Release\" -DENABLE_MULTIVERSION_PROTOCOL_TEST=\"true\" -DBUILD_MONGO_DB_PLUGIN=\"true\""
if [[ "$(uname)" == 'Darwin' && "$FORCE_LINUX" != 'true' ]]; then
# You can't use chained commands in execute
if [[ "$GITHUB_ACTIONS" == 'true' ]]; then
export PINNED=false
export PINNED='false'
fi
[[ ! "$PINNED" == 'false' ]] && CMAKE_EXTRAS="$CMAKE_EXTRAS -DCMAKE_TOOLCHAIN_FILE=$HELPERS_DIR/clang.make"
cd $BUILD_DIR
echo "cmake $CMAKE_EXTRAS .."
cmake $CMAKE_EXTRAS ..
echo "make -j$JOBS"
make -j$JOBS
[[ ! "$PINNED" == 'false' ]] && CMAKE_EXTRAS="$CMAKE_EXTRAS -DCMAKE_TOOLCHAIN_FILE=\"$HELPERS_DIR/clang.make\""
cd "$BUILD_DIR"
echo '+++ :hammer_and_wrench: Building EOSIO'
CMAKE_COMMAND="cmake $CMAKE_EXTRAS .."
echo "$ $CMAKE_COMMAND"
eval $CMAKE_COMMAND
MAKE_COMMAND="make -j '$JOBS'"
echo "$ $MAKE_COMMAND"
eval $MAKE_COMMAND
cd ..
else # Linux
ARGS=${ARGS:-"--rm --init -v $(pwd):$MOUNTED_DIR"}
PRE_COMMANDS="cd $MOUNTED_DIR/build"
ARGS=${ARGS:-"--rm --init -v \"\$(pwd):$MOUNTED_DIR\""}
PRE_COMMANDS="cd \"$MOUNTED_DIR/build\""
# PRE_COMMANDS: Executed pre-cmake
# CMAKE_EXTRAS: Executed within and right before the cmake path (cmake CMAKE_EXTRAS ..)
[[ ! "$IMAGE_TAG" =~ 'unpinned' ]] && CMAKE_EXTRAS="$CMAKE_EXTRAS -DCMAKE_TOOLCHAIN_FILE=$MOUNTED_DIR/.cicd/helpers/clang.make"
[[ ! "$IMAGE_TAG" =~ 'unpinned' ]] && CMAKE_EXTRAS="$CMAKE_EXTRAS -DCMAKE_TOOLCHAIN_FILE=\"$MOUNTED_DIR/.cicd/helpers/clang.make\""
if [[ "$IMAGE_TAG" == 'amazon_linux-2-unpinned' ]]; then
CMAKE_EXTRAS="$CMAKE_EXTRAS -DCMAKE_CXX_COMPILER='clang++' -DCMAKE_C_COMPILER='clang'"
CMAKE_EXTRAS="$CMAKE_EXTRAS -DCMAKE_CXX_COMPILER=\"clang++\" -DCMAKE_C_COMPILER=\"clang\""
elif [[ "$IMAGE_TAG" == 'centos-7.7-unpinned' ]]; then
PRE_COMMANDS="$PRE_COMMANDS && source /opt/rh/devtoolset-8/enable && source /opt/rh/rh-python36/enable"
CMAKE_EXTRAS="$CMAKE_EXTRAS -DLLVM_DIR='/opt/rh/llvm-toolset-7.0/root/usr/lib64/cmake/llvm'"
PRE_COMMANDS="$PRE_COMMANDS && source \"/opt/rh/devtoolset-8/enable\" && source \"/opt/rh/rh-python36/enable\""
CMAKE_EXTRAS="$CMAKE_EXTRAS -DLLVM_DIR=\"/opt/rh/llvm-toolset-7.0/root/usr/lib64/cmake/llvm\""
elif [[ "$IMAGE_TAG" == 'ubuntu-18.04-unpinned' ]]; then
CMAKE_EXTRAS="$CMAKE_EXTRAS -DCMAKE_CXX_COMPILER='clang++-7' -DCMAKE_C_COMPILER='clang-7' -DLLVM_DIR='/usr/lib/llvm-7/lib/cmake/llvm'"
CMAKE_EXTRAS="$CMAKE_EXTRAS -DCMAKE_CXX_COMPILER=\"clang++-7\" -DCMAKE_C_COMPILER=\"clang-7\" -DLLVM_DIR=\"/usr/lib/llvm-7/lib/cmake/llvm\""
fi
BUILD_COMMANDS="cmake $CMAKE_EXTRAS .. && make -j$JOBS"
CMAKE_COMMAND="cmake \$CMAKE_EXTRAS .."
MAKE_COMMAND="make -j $JOBS"
BUILD_COMMANDS="echo \"+++ :hammer_and_wrench: Building EOSIO\" && echo \"$ $CMAKE_COMMAND\" && eval $CMAKE_COMMAND && echo \"$ $MAKE_COMMAND\" && eval $MAKE_COMMAND"
# Docker Commands
if [[ "$BUILDKITE" == 'true' ]]; then
# Generate Base Images
$CICD_DIR/generate-base-images.sh
[[ "$ENABLE_INSTALL" == 'true' ]] && COMMANDS="cp -r $MOUNTED_DIR /root/eosio && cd /root/eosio/build &&"
BASE_IMAGE_COMMAND="\"$CICD_DIR/generate-base-images.sh\""
echo "$ $BASE_IMAGE_COMMAND"
eval $BASE_IMAGE_COMMAND
[[ "$ENABLE_INSTALL" == 'true' ]] && COMMANDS="cp -r \"$MOUNTED_DIR\" \"/root/eosio\" && cd \"/root/eosio/build\" &&"
COMMANDS="$COMMANDS $BUILD_COMMANDS"
[[ "$ENABLE_INSTALL" == 'true' ]] && COMMANDS="$COMMANDS && make install"
elif [[ "$GITHUB_ACTIONS" == 'true' ]]; then
Expand All @@ -42,8 +51,18 @@ else # Linux
else
COMMANDS="$BUILD_COMMANDS"
fi
. $HELPERS_DIR/file-hash.sh $CICD_DIR/platforms/$PLATFORM_TYPE/$IMAGE_TAG.dockerfile
. "$HELPERS_DIR/file-hash.sh" "$CICD_DIR/platforms/$PLATFORM_TYPE/$IMAGE_TAG.dockerfile"
COMMANDS="$PRE_COMMANDS && $COMMANDS"
echo "$ docker run $ARGS $(buildkite-intrinsics) $FULL_TAG bash -c \"$COMMANDS\""
eval docker run $ARGS $(buildkite-intrinsics) $FULL_TAG bash -c \"$COMMANDS\"
fi
DOCKER_RUN="docker run $ARGS $(buildkite-intrinsics) --env CMAKE_EXTRAS='$CMAKE_EXTRAS' '$FULL_TAG' bash -c '$COMMANDS'"
echo "$ $DOCKER_RUN"
eval $DOCKER_RUN
fi
if [[ "$BUILDKITE" == 'true' && "$ENABLE_INSTALL" != 'true' ]]; then
echo '--- :arrow_up: Uploading Artifacts'
echo 'Compressing build directory.'
tar -pczf 'build.tar.gz' build
echo 'Uploading build directory.'
buildkite-agent artifact upload 'build.tar.gz'
echo 'Done uploading artifacts.'
fi
[[ "$ENABLE_INSTALL" == 'true' ]] || echo '--- :white_check_mark: Done!'
85 changes: 67 additions & 18 deletions .cicd/docker-tag.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,71 @@
#!/bin/bash
set -eo pipefail
echo '+++ :evergreen_tree: Configuring Environment'
REPO='eosio/ci-contracts-builder'
echo '--- :evergreen_tree: Configuring Environment'
. ./.cicd/helpers/general.sh
PREFIX='base-ubuntu-18.04'
IMAGE="$REPO:$PREFIX-$BUILDKITE_COMMIT-$PLATFORM_TYPE"
SANITIZED_BRANCH=$(echo "$BUILDKITE_BRANCH" | sed 's.^/..' | tr '/' '_')
SANITIZED_BRANCH=$(echo "$BUILDKITE_BRANCH" | sed 's.^/..' | sed 's/[:/]/_/g')
SANITIZED_TAG=$(echo "$BUILDKITE_TAG" | sed 's.^/..' | tr '/' '_')
echo '+++ :arrow_down: Pulling Container'
echo "Pulling \"$IMAGE\""
docker pull "$IMAGE"
echo '+++ :label: Tagging Container'
docker tag "$IMAGE" "$REPO:$PREFIX-$SANITIZED_BRANCH"
echo "Tagged \"$REPO:$PREFIX-$SANITIZED_BRANCH\"."
[[ -z "$BUILDKITE_TAG" ]] || docker tag "$IMAGE" "$REPO:$PREFIX-$SANITIZED_TAG" && echo "Tagged \"$REPO:$PREFIX-$SANITIZED_TAG\"."
echo '+++ :arrow_up: Pushing Container'
docker push "$REPO:$PREFIX-$SANITIZED_BRANCH"
[[ -z "$BUILDKITE_TAG" ]] || docker push "$REPO:$PREFIX-$SANITIZED_TAG"
echo '+++ :put_litter_in_its_place: Cleaning Up'
docker rmi "$REPO:$PREFIX-$SANITIZED_BRANCH"
[[ -z "$BUILDKITE_TAG" || "$SANITIZED_BRANCH" == "$SANITIZED_TAG" ]] || docker rmi "$REPO:$PREFIX-$SANITIZED_TAG"
docker rmi "$IMAGE"
echo '$ echo ${#CONTRACT_REGISTRIES[*]} # array length'
echo ${#CONTRACT_REGISTRIES[*]}
echo '$ echo ${CONTRACT_REGISTRIES[*]} # array'
echo ${CONTRACT_REGISTRIES[*]}
# pull
echo '+++ :arrow_down: Pulling Container(s)'
for REGISTRY in ${CONTRACT_REGISTRIES[*]}; do
if [[ ! -z "$REGISTRY" ]]; then
echo "Pulling from '$REGISTRY'."
IMAGE="$REGISTRY:$PREFIX-$BUILDKITE_COMMIT-$PLATFORM_TYPE"
DOCKER_PULL_COMMAND="docker pull '$IMAGE'"
echo "$ $DOCKER_PULL_COMMAND"
eval $DOCKER_PULL_COMMAND
fi
done
# tag
echo '+++ :label: Tagging Container(s)'
for REGISTRY in ${CONTRACT_REGISTRIES[*]}; do
if [[ ! -z "$REGISTRY" ]]; then
echo "Tagging for registry $REGISTRY."
IMAGE="$REGISTRY:$PREFIX-$BUILDKITE_COMMIT-$PLATFORM_TYPE"
DOCKER_TAG_COMMAND="docker tag '$IMAGE' '$REGISTRY:$PREFIX-$SANITIZED_BRANCH'"
echo "$ $DOCKER_TAG_COMMAND"
eval $DOCKER_TAG_COMMAND
if [[ ! -z "$BUILDKITE_TAG" && "$SANITIZED_BRANCH" != "$SANITIZED_TAG" ]]; then
DOCKER_TAG_COMMAND="docker tag '$IMAGE' '$REGISTRY:$PREFIX-$SANITIZED_TAG'"
echo "$ $DOCKER_TAG_COMMAND"
eval $DOCKER_TAG_COMMAND
fi
fi
done
# push
echo '+++ :arrow_up: Pushing Container(s)'
for REGISTRY in ${CONTRACT_REGISTRIES[*]}; do
if [[ ! -z "$REGISTRY" ]]; then
echo "Pushing to '$REGISTRY'."
DOCKER_PUSH_COMMAND="docker push '$REGISTRY:$PREFIX-$SANITIZED_BRANCH'"
echo "$ $DOCKER_PUSH_COMMAND"
eval $DOCKER_PUSH_COMMAND
if [[ ! -z "$BUILDKITE_TAG" && "$SANITIZED_BRANCH" != "$SANITIZED_TAG" ]]; then
DOCKER_PUSH_COMMAND="docker push '$REGISTRY:$PREFIX-$SANITIZED_TAG'"
echo "$ $DOCKER_PUSH_COMMAND"
eval $DOCKER_PUSH_COMMAND
fi
fi
done
# cleanup
echo '--- :put_litter_in_its_place: Cleaning Up'
for REGISTRY in ${CONTRACT_REGISTRIES[*]}; do
if [[ ! -z "$REGISTRY" ]]; then
echo "Cleaning up from $REGISTRY."
DOCKER_RMI_COMMAND="docker rmi '$REGISTRY:$PREFIX-$SANITIZED_BRANCH'"
echo "$ $DOCKER_RMI_COMMAND"
eval $DOCKER_RMI_COMMAND
if [[ ! -z "$BUILDKITE_TAG" && "$SANITIZED_BRANCH" != "$SANITIZED_TAG" ]]; then
DOCKER_RMI_COMMAND="docker rmi '$REGISTRY:$PREFIX-$SANITIZED_TAG'"
echo "$ $DOCKER_RMI_COMMAND"
eval $DOCKER_RMI_COMMAND
fi
DOCKER_RMI_COMMAND="docker rmi '$REGISTRY:$PREFIX-$BUILDKITE_COMMIT-$PLATFORM_TYPE'"
echo "$ $DOCKER_RMI_COMMAND"
eval $DOCKER_RMI_COMMAND
fi
done
97 changes: 86 additions & 11 deletions .cicd/generate-base-images.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,96 @@
#!/bin/bash
set -eo pipefail
. ./.cicd/helpers/general.sh
. $HELPERS_DIR/file-hash.sh $CICD_DIR/platforms/$PLATFORM_TYPE/$IMAGE_TAG.dockerfile
# look for Docker image
echo "+++ :mag_right: Looking for $FULL_TAG"
ORG_REPO=$(echo $FULL_TAG | cut -d: -f1)
TAG=$(echo $FULL_TAG | cut -d: -f2)
EXISTS=$(curl -s -H "Authorization: Bearer $(curl -sSL "https://auth.docker.io/token?service=registry.docker.io&scope=repository:${ORG_REPO}:pull" | jq --raw-output .token)" "https://registry.hub.docker.com/v2/${ORG_REPO}/manifests/$TAG")
. "$HELPERS_DIR/file-hash.sh" "$CICD_DIR/platforms/$PLATFORM_TYPE/$IMAGE_TAG.dockerfile"
# search for base image in docker registries
echo '--- :docker: Build or Pull Base Image :minidisc:'
echo "Looking for '$HASHED_IMAGE_TAG' container in our registries."
EXISTS_ALL='true'
EXISTS_DOCKER_HUB='false'
EXISTS_ECR='false'
for REGISTRY in ${CI_REGISTRIES[*]}; do
if [[ ! -z "$REGISTRY" ]]; then
MANIFEST_COMMAND="docker manifest inspect '$REGISTRY:$HASHED_IMAGE_TAG'"
echo "$ $MANIFEST_COMMAND"
set +e
eval $MANIFEST_COMMAND
MANIFEST_INSPECT_EXIT_STATUS="$?"
set -eo pipefail
if [[ "$MANIFEST_INSPECT_EXIT_STATUS" == '0' ]]; then
if [[ "$(echo "$REGISTRY" | grep -icP '[.]amazonaws[.]com/')" != '0' ]]; then
EXISTS_ECR='true'
elif [[ "$(echo "$REGISTRY" | grep -icP 'docker[.]io/')" != '0' ]]; then
EXISTS_DOCKER_HUB='true'
fi
else
EXISTS_ALL='false'
fi
fi
done
# copy, if possible, since it is so much faster
if [[ "$EXISTS_ECR" == 'false' && "$EXISTS_DOCKER_HUB" == 'true' && "$OVERWRITE_BASE_IMAGE" != 'true' && ! -z "$MIRROR_REGISTRY" ]]; then
echo 'Attempting copy from Docker Hub to the mirror instead of a new base image build.'
DOCKER_PULL_COMMAND="docker pull '$DOCKERHUB_CI_REGISTRY:$HASHED_IMAGE_TAG'"
echo "$ $DOCKER_PULL_COMMAND"
set +e
eval $DOCKER_PULL_COMMAND
DOCKER_PULL_EXIT_STATUS="$?"
set -eo pipefail
if [[ "$DOCKER_PULL_EXIT_STATUS" == '0' ]]; then
echo 'Pull from Docker Hub worked! Pushing to mirror.'
# tag
DOCKER_TAG_COMMAND="docker tag '$DOCKERHUB_CI_REGISTRY:$HASHED_IMAGE_TAG' '$MIRROR_REGISTRY:$HASHED_IMAGE_TAG'"
echo "$ $DOCKER_TAG_COMMAND"
eval $DOCKER_TAG_COMMAND
# push
DOCKER_PUSH_COMMAND="docker push '$MIRROR_REGISTRY:$HASHED_IMAGE_TAG'"
echo "$ $DOCKER_PUSH_COMMAND"
eval $DOCKER_PUSH_COMMAND
EXISTS_ALL='true'
EXISTS_ECR='true'
else
echo 'Pull from Docker Hub failed, rebuilding base image from scratch.'
fi
fi
# esplain yerself
if [[ "$EXISTS_ALL" == 'false' ]]; then
echo 'Building base image from scratch.'
elif [[ "$OVERWRITE_BASE_IMAGE" == 'true' ]]; then
echo "OVERWRITE_BASE_IMAGE is set to 'true', building from scratch and pushing to docker registries."
elif [[ "$FORCE_BASE_IMAGE" == 'true' ]]; then
echo "FORCE_BASE_IMAGE is set to 'true', building from scratch and NOT pushing to docker registries."
fi
# build, if neccessary
if [[ $EXISTS =~ '404 page not found' || $EXISTS =~ 'manifest unknown' || $FORCE_BASE_IMAGE == true ]]; then # if we cannot pull the image, we build and push it first
docker build --no-cache -t $FULL_TAG -f $CICD_DIR/platforms/$PLATFORM_TYPE/$IMAGE_TAG.dockerfile .
if [[ $FORCE_BASE_IMAGE != true ]]; then
docker push $FULL_TAG
if [[ "$EXISTS_ALL" == 'false' || "$FORCE_BASE_IMAGE" == 'true' || "$OVERWRITE_BASE_IMAGE" == 'true' ]]; then # if we cannot pull the image, we build and push it first
export DOCKER_BUILD_COMMAND="docker build --no-cache -t 'ci:$HASHED_IMAGE_TAG' -f '$CICD_DIR/platforms/$PLATFORM_TYPE/$IMAGE_TAG.dockerfile' ."
echo "$ $DOCKER_BUILD_COMMAND"
eval $DOCKER_BUILD_COMMAND
if [[ "$FORCE_BASE_IMAGE" != 'true' || "$OVERWRITE_BASE_IMAGE" == 'true' ]]; then
for REGISTRY in ${CI_REGISTRIES[*]}; do
if [[ ! -z "$REGISTRY" ]]; then
# tag
DOCKER_TAG_COMMAND="docker tag 'ci:$HASHED_IMAGE_TAG' '$REGISTRY:$HASHED_IMAGE_TAG'"
echo "$ $DOCKER_TAG_COMMAND"
eval $DOCKER_TAG_COMMAND
# push
DOCKER_PUSH_COMMAND="docker push '$REGISTRY:$HASHED_IMAGE_TAG'"
echo "$ $DOCKER_PUSH_COMMAND"
eval $DOCKER_PUSH_COMMAND
# clean up
if [[ "$FULL_TAG" != "$REGISTRY:$HASHED_IMAGE_TAG" ]]; then
DOCKER_RMI_COMMAND="docker rmi '$REGISTRY:$HASHED_IMAGE_TAG'"
echo "$ $DOCKER_RMI_COMMAND"
eval $DOCKER_RMI_COMMAND
fi
fi
done
DOCKER_RMI_COMMAND="docker rmi 'ci:$HASHED_IMAGE_TAG'"
echo "$ $DOCKER_RMI_COMMAND"
eval $DOCKER_RMI_COMMAND
else
echo "Base image creation successful. Not pushing...".
exit 0
fi
else
echo "$FULL_TAG already exists."
fi
fi
11 changes: 4 additions & 7 deletions .cicd/generate-pipeline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if [[ $PINNED == false ]]; then
else
export PLATFORM_TYPE="pinned"
fi
for FILE in $(ls $CICD_DIR/platforms/$PLATFORM_TYPE); do
for FILE in $(ls "$CICD_DIR/platforms/$PLATFORM_TYPE"); do
# skip mac or linux by not even creating the json block
( [[ $SKIP_MAC == true ]] && [[ $FILE =~ 'macos' ]] ) && continue
( [[ $SKIP_LINUX == true ]] && [[ ! $FILE =~ 'macos' ]] ) && continue
Expand All @@ -28,7 +28,7 @@ for FILE in $(ls $CICD_DIR/platforms/$PLATFORM_TYPE); do
export SKIP_CONTRACT_BUILDER=${SKIP_CONTRACT_BUILDER:-true}
export SKIP_PACKAGE_BUILDER=${SKIP_PACKAGE_BUILDER:-true}
fi
export FILE_NAME="$(echo $FILE | awk '{split($0,a,/\.(d|s)/); print a[1] }')"
export FILE_NAME="$(echo "$FILE" | awk '{split($0,a,/\.(d|s)/); print a[1] }')"
# macos-10.14
# ubuntu-16.04
export PLATFORM_NAME="$(echo $FILE_NAME | cut -d- -f1 | sed 's/os/OS/g')"
Expand All @@ -55,7 +55,7 @@ for FILE in $(ls $CICD_DIR/platforms/$PLATFORM_TYPE); do
[[ $FILE_NAME =~ 'ubuntu' ]] && export ICON=':ubuntu:'
[[ $FILE_NAME =~ 'centos' ]] && export ICON=':centos:'
[[ $FILE_NAME =~ 'macos' ]] && export ICON=':darwin:'
. $HELPERS_DIR/file-hash.sh $CICD_DIR/platforms/$PLATFORM_TYPE/$FILE # returns HASHED_IMAGE_TAG, etc
. "$HELPERS_DIR/file-hash.sh" "$CICD_DIR/platforms/$PLATFORM_TYPE/$FILE" # returns HASHED_IMAGE_TAG, etc
export PLATFORMS_JSON_ARRAY=$(echo $PLATFORMS_JSON_ARRAY | jq -c '. += [{
"FILE_NAME": env.FILE_NAME,
"PLATFORM_NAME": env.PLATFORM_NAME,
Expand Down Expand Up @@ -96,9 +96,7 @@ echo $PLATFORMS_JSON_ARRAY | jq -cr '.[]' | while read -r PLATFORM_JSON; do
if [[ ! "$(echo "$PLATFORM_JSON" | jq -r .FILE_NAME)" =~ 'macos' ]]; then
cat <<EOF
- label: "$(echo "$PLATFORM_JSON" | jq -r .ICON) $(echo "$PLATFORM_JSON" | jq -r .PLATFORM_NAME_FULL) - Build"
command:
- "./.cicd/build.sh"
- "tar -pczf build.tar.gz build && buildkite-agent artifact upload build.tar.gz"
command: "./.cicd/build.sh"
env:
IMAGE_TAG: $(echo "$PLATFORM_JSON" | jq -r .FILE_NAME)
PLATFORM_TYPE: $PLATFORM_TYPE
Expand All @@ -114,7 +112,6 @@ EOF
command:
- "git clone \$BUILDKITE_REPO eos && cd eos && $GIT_FETCH git checkout -f \$BUILDKITE_COMMIT && git submodule update --init --recursive"
- "cd eos && ./.cicd/build.sh"
- "cd eos && tar -pczf build.tar.gz build && buildkite-agent artifact upload build.tar.gz"
plugins:
- EOSIO/anka#v0.6.1:
no-volume: true
Expand Down
8 changes: 4 additions & 4 deletions .cicd/helpers/file-hash.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -eo pipefail
[[ -z $1 ]] && echo "Please provide the file to be hashed" && exit 1
FILE_NAME=$(basename $1 | awk '{split($0,a,/\.(d|s)/); print a[1] }')
export DETERMINED_HASH=$(sha1sum $1 | awk '{ print $1 }')
[[ -z "$1" ]] && echo 'Please provide the file to be hashed as first argument.' && exit 1
FILE_NAME="$(basename "$1" | awk '{split($0,a,/\.(d|s)/); print a[1] }')"
export DETERMINED_HASH=$(sha1sum "$1" | awk '{ print $1 }')
export HASHED_IMAGE_TAG="eos-${FILE_NAME}-${DETERMINED_HASH}"
export FULL_TAG="${IMAGE_NAME:-"eosio/ci"}:$HASHED_IMAGE_TAG"
export FULL_TAG="${MIRROR_REGISTRY:-$DOCKERHUB_CI_REGISTRY}:$HASHED_IMAGE_TAG"
23 changes: 14 additions & 9 deletions .cicd/helpers/general.sh
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
export ROOT_DIR=$( dirname "${BASH_SOURCE[0]}" )/../..
export BUILD_DIR=$ROOT_DIR/build
export CICD_DIR=$ROOT_DIR/.cicd
export HELPERS_DIR=$CICD_DIR/helpers
export BUILD_DIR="$ROOT_DIR/build"
export CICD_DIR="$ROOT_DIR/.cicd"
export HELPERS_DIR="$CICD_DIR/helpers"
export JOBS=${JOBS:-"$(getconf _NPROCESSORS_ONLN)"}
export MOUNTED_DIR='/workdir'
export MOUNTED_DIR='/eos'
export DOCKER_CLI_EXPERIMENTAL='enabled'
export DOCKERHUB_CI_REGISTRY="docker.io/eosio/ci"
export DOCKERHUB_CONTRACTS_REGISTRY="docker.io/eosio/ci-contracts-builder"
export CI_REGISTRIES=("$DOCKERHUB_CI_REGISTRY" "$MIRROR_REGISTRY")
export CONTRACT_REGISTRIES=("$DOCKERHUB_CONTRACTS_REGISTRY" "$MIRROR_REGISTRY")

# capitalize each word in a string
function capitalize()
{
if [[ ! $1 =~ 'mac' ]]; then # Don't capitalize mac
echo $1 | awk '{$1=toupper(substr($1,1,1))substr($1,2)}1'
if [[ ! "$1" =~ 'mac' ]]; then # Don't capitalize mac
echo "$1" | awk '{$1=toupper(substr($1,1,1))substr($1,2)}1'
else
echo $1
echo "$1"
fi
}

# load buildkite intrinsic environment variables for use in docker run
function buildkite-intrinsics()
{
BK_ENV=''
if [[ -f $BUILDKITE_ENV_FILE ]]; then
if [[ -f "$BUILDKITE_ENV_FILE" ]]; then
while read -r var; do
BK_ENV="$BK_ENV --env ${var%%=*}"
done < "$BUILDKITE_ENV_FILE"
fi
echo "$BK_ENV"
}
}
Loading

0 comments on commit 617cea2

Please sign in to comment.