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

[2.0.x] CI platform directories #8149

Merged
merged 7 commits into from
Oct 30, 2019
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
13 changes: 6 additions & 7 deletions .cicd/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ if [[ "$(uname)" == 'Darwin' ]]; then
export PINNED=false
ccache -s
CMAKE_EXTRAS="$CMAKE_EXTRAS -DCMAKE_CXX_COMPILER_LAUNCHER=ccache"
./$CICD_DIR/platforms/macos-10.14.sh
else
CMAKE_EXTRAS="$CMAKE_EXTRAS -DBUILD_MONGO_DB_PLUGIN=true"
fi
Expand All @@ -22,18 +21,17 @@ if [[ "$(uname)" == 'Darwin' ]]; then
else # Linux
CMAKE_EXTRAS="$CMAKE_EXTRAS -DBUILD_MONGO_DB_PLUGIN=true"
ARGS=${ARGS:-"--rm --init -v $(pwd):$MOUNTED_DIR"}
. $HELPERS_DIR/file-hash.sh $CICD_DIR/platforms/$IMAGE_TAG.dockerfile
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 -DCMAKE_CXX_COMPILER_LAUNCHER=ccache"
if [[ "$IMAGE_TAG" == 'amazon_linux-2' ]]; then
if [[ "$IMAGE_TAG" == 'amazon_linux-2-pinned' ]]; then
PRE_COMMANDS="$PRE_COMMANDS && export PATH=/usr/lib64/ccache:\\\$PATH"
elif [[ "$IMAGE_TAG" == 'centos-7.6' ]]; then
elif [[ "$IMAGE_TAG" == 'centos-7.6-pinned' ]]; then
PRE_COMMANDS="$PRE_COMMANDS && export PATH=/usr/lib64/ccache:\\\$PATH"
elif [[ "$IMAGE_TAG" == 'ubuntu-16.04' ]]; then
elif [[ "$IMAGE_TAG" == 'ubuntu-16.04-pinned' ]]; then
PRE_COMMANDS="$PRE_COMMANDS && export PATH=/usr/lib/ccache:\\\$PATH"
elif [[ "$IMAGE_TAG" == 'ubuntu-18.04' ]]; then
elif [[ "$IMAGE_TAG" == 'ubuntu-18.04-pinned' ]]; then
PRE_COMMANDS="$PRE_COMMANDS && export PATH=/usr/lib/ccache:\\\$PATH"
elif [[ "$IMAGE_TAG" == 'amazon_linux-2-unpinned' ]]; then
PRE_COMMANDS="$PRE_COMMANDS && export PATH=/usr/lib64/ccache:\\\$PATH"
Expand All @@ -43,7 +41,7 @@ else # Linux
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
PRE_COMMANDS="$PRE_COMMANDS && export PATH=/usr/lib/ccache:\\\$PATH"
CMAKE_EXTRAS="$CMAKE_EXTRAS -DCMAKE_CXX_COMPILER='clang++' -DCMAKE_C_COMPILER='clang' -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"
# Docker Commands
Expand All @@ -57,6 +55,7 @@ else # Linux
ARGS="$ARGS -v /usr/lib/ccache -v $HOME/.ccache:/opt/.ccache -e JOBS -e TRAVIS -e CCACHE_DIR=/opt/.ccache"
COMMANDS="ccache -s && $BUILD_COMMANDS"
fi
. $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\"
Expand Down
8 changes: 4 additions & 4 deletions .cicd/generate-base-images.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#!/bin/bash
set -eo pipefail
. ./.cicd/helpers/general.sh
. $HELPERS_DIR/file-hash.sh $CICD_DIR/platforms/${IMAGE_TAG}.dockerfile
. $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")
# build, if neccessary
if [[ $EXISTS =~ '404 page not found' || $EXISTS =~ 'manifest unknown' ]]; then # if we cannot pull the image, we build and push it first
docker build -t $FULL_TAG -f $CICD_DIR/platforms/${IMAGE_TAG}.dockerfile .
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 -t $FULL_TAG -f $CICD_DIR/platforms/$PLATFORM_TYPE/$IMAGE_TAG.dockerfile .
docker push $FULL_TAG
else
echo "$FULL_TAG already exists."
fi
fi
46 changes: 24 additions & 22 deletions .cicd/generate-pipeline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,20 @@ if [[ $BUILDKITE_BRANCH =~ ^pull/[0-9]+/head: ]]; then
PR_ID=$(echo $BUILDKITE_BRANCH | cut -d/ -f2)
export GIT_FETCH="git fetch -v --prune origin refs/pull/$PR_ID/head &&"
fi

for FILE in $(ls $CICD_DIR/platforms); do
# Determine which dockerfiles/scripts to use for the pipeline.
if [[ $PINNED == false || $UNPINNED == true ]]; then
export PLATFORM_TYPE="unpinned"
else
export PLATFORM_TYPE="pinned"
fi
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
# use pinned or unpinned, not both sets of platform files
if [[ $PINNED == false || $UNPINNED == true ]] && [[ ! $FILE =~ 'macos' ]]; then
if [[ $PINNED == false || $UNPINNED == true ]]; then
export SKIP_CONTRACT_BUILDER=${SKIP_CONTRACT_BUILDER:-true}
export SKIP_PACKAGE_BUILDER=${SKIP_PACKAGE_BUILDER:-true}
[[ ! $FILE =~ 'unpinned' ]] && continue
else
[[ $FILE =~ 'unpinned' ]] && continue
fi
export FILE_NAME="$(echo $FILE | awk '{split($0,a,/\.(d|s)/); print a[1] }')"
# macos-10.14
Expand Down Expand Up @@ -58,7 +60,7 @@ for FILE in $(ls $CICD_DIR/platforms); 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/$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 @@ -100,7 +102,7 @@ echo $PLATFORMS_JSON_ARRAY | jq -cr '.[]' | while read -r PLATFORM_JSON; do
- "tar -pczf build.tar.gz build && buildkite-agent artifact upload build.tar.gz"
env:
IMAGE_TAG: $(echo "$PLATFORM_JSON" | jq -r .FILE_NAME)
BUILDKITE_AGENT_ACCESS_TOKEN:
PLATFORM_TYPE: $PLATFORM_TYPE
agents:
queue: "$BUILDKITE_BUILD_AGENT_QUEUE"
timeout: ${TIMEOUT:-180}
Expand Down Expand Up @@ -138,9 +140,9 @@ EOF
REPO_COMMIT: $BUILDKITE_COMMIT
TEMPLATE: $MOJAVE_ANKA_TEMPLATE_NAME
TEMPLATE_TAG: $MOJAVE_ANKA_TAG_BASE
PINNED: $PINNED
UNPINNED: $UNPINNED
TAG_COMMANDS: "git clone ${BUILDKITE_PULL_REQUEST_REPO:-$BUILDKITE_REPO} eos && cd eos && $GIT_FETCH git checkout -f $BUILDKITE_COMMIT && git submodule update --init --recursive && export PINNED=$PINNED && export UNPINNED=$UNPINNED && . ./.cicd/platforms/$(echo "$PLATFORM_JSON" | jq -r .FILE_NAME).sh && cd ~/eos && cd .. && rm -rf eos"
IMAGE_TAG: $(echo "$PLATFORM_JSON" | jq -r .FILE_NAME)
PLATFORM_TYPE: $PLATFORM_TYPE
TAG_COMMANDS: "git clone ${BUILDKITE_PULL_REQUEST_REPO:-$BUILDKITE_REPO} eos && cd eos && $GIT_FETCH git checkout -f $BUILDKITE_COMMIT && git submodule update --init --recursive && export IMAGE_TAG=$(echo "$PLATFORM_JSON" | jq -r .FILE_NAME) && export PLATFORM_TYPE=$PLATFORM_TYPE && . ./.cicd/platforms/$PLATFORM_TYPE/$(echo "$PLATFORM_JSON" | jq -r .FILE_NAME).sh && cd ~/eos && cd .. && rm -rf eos"
PROJECT_TAG: $(echo "$PLATFORM_JSON" | jq -r .HASHED_IMAGE_TAG)
timeout: ${TIMEOUT:-180}
agents: "queue=mac-anka-large-node-fleet"
Expand Down Expand Up @@ -175,7 +177,7 @@ for ROUND in $(seq 1 $ROUNDS); do
- "./.cicd/test.sh scripts/parallel-test.sh"
env:
IMAGE_TAG: $(echo "$PLATFORM_JSON" | jq -r .FILE_NAME)
BUILDKITE_AGENT_ACCESS_TOKEN:
PLATFORM_TYPE: $PLATFORM_TYPE
agents:
queue: "$BUILDKITE_BUILD_AGENT_QUEUE"
timeout: ${TIMEOUT:-30}
Expand Down Expand Up @@ -231,7 +233,7 @@ EOF
- "./.cicd/test.sh scripts/wasm-spec-test.sh"
env:
IMAGE_TAG: $(echo "$PLATFORM_JSON" | jq -r .FILE_NAME)
BUILDKITE_AGENT_ACCESS_TOKEN:
PLATFORM_TYPE: $PLATFORM_TYPE
agents:
queue: "$BUILDKITE_BUILD_AGENT_QUEUE"
timeout: ${TIMEOUT:-30}
Expand Down Expand Up @@ -290,7 +292,7 @@ EOF
- "./.cicd/test.sh scripts/serial-test.sh $TEST_NAME"
env:
IMAGE_TAG: $(echo "$PLATFORM_JSON" | jq -r .FILE_NAME)
BUILDKITE_AGENT_ACCESS_TOKEN:
PLATFORM_TYPE: $PLATFORM_TYPE
agents:
queue: "$BUILDKITE_TEST_AGENT_QUEUE"
timeout: ${TIMEOUT:-20}
Expand Down Expand Up @@ -350,7 +352,7 @@ EOF
- "./.cicd/test.sh scripts/long-running-test.sh $TEST_NAME"
env:
IMAGE_TAG: $(echo "$PLATFORM_JSON" | jq -r .FILE_NAME)
BUILDKITE_AGENT_ACCESS_TOKEN:
PLATFORM_TYPE: $PLATFORM_TYPE
agents:
queue: "$BUILDKITE_TEST_AGENT_QUEUE"
timeout: ${TIMEOUT:-180}
Expand Down Expand Up @@ -465,8 +467,8 @@ cat <<EOF
- "buildkite-agent artifact download build.tar.gz . --step ':centos: CentOS 7.6 - Build' --agent-access-token \$\$BUILDKITE_AGENT_ACCESS_TOKEN && tar -xzf build.tar.gz"
- "./.cicd/package.sh"
env:
IMAGE_TAG: "centos-7.6"
BUILDKITE_AGENT_ACCESS_TOKEN:
IMAGE_TAG: "centos-7.6-$PLATFORM_TYPE"
PLATFORM_TYPE: $PLATFORM_TYPE
OS: "el7" # OS and PKGTYPE required for lambdas
PKGTYPE: "rpm"
agents:
Expand All @@ -479,8 +481,8 @@ cat <<EOF
- "buildkite-agent artifact download build.tar.gz . --step ':ubuntu: Ubuntu 16.04 - Build' --agent-access-token \$\$BUILDKITE_AGENT_ACCESS_TOKEN && tar -xzf build.tar.gz"
- "./.cicd/package.sh"
env:
IMAGE_TAG: "ubuntu-16.04"
BUILDKITE_AGENT_ACCESS_TOKEN:
IMAGE_TAG: "ubuntu-16.04-$PLATFORM_TYPE"
PLATFORM_TYPE: $PLATFORM_TYPE
OS: "ubuntu-16.04" # OS and PKGTYPE required for lambdas
PKGTYPE: "deb"
agents:
Expand All @@ -493,8 +495,8 @@ cat <<EOF
- "buildkite-agent artifact download build.tar.gz . --step ':ubuntu: Ubuntu 18.04 - Build' --agent-access-token \$\$BUILDKITE_AGENT_ACCESS_TOKEN && tar -xzf build.tar.gz"
- "./.cicd/package.sh"
env:
IMAGE_TAG: "ubuntu-18.04"
BUILDKITE_AGENT_ACCESS_TOKEN:
IMAGE_TAG: "ubuntu-18.04-$PLATFORM_TYPE"
PLATFORM_TYPE: $PLATFORM_TYPE
OS: "ubuntu-18.04" # OS and PKGTYPE required for lambdas
PKGTYPE: "deb"
agents:
Expand Down Expand Up @@ -529,7 +531,7 @@ cat <<EOF
command: "./.cicd/installation-build.sh"
env:
IMAGE_TAG: "ubuntu-18.04-unpinned"
BUILDKITE_AGENT_ACCESS_TOKEN:
PLATFORM_TYPE: "unpinned"
agents:
queue: "$BUILDKITE_BUILD_AGENT_QUEUE"
timeout: ${TIMEOUT:-30}
Expand Down
1 change: 0 additions & 1 deletion .cicd/helpers/file-hash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ 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 }')
( [[ $FILE_NAME =~ 'macos' ]] && [[ $PINNED == false || $UNPINNED == true ]] ) && FILE_NAME="${FILE_NAME}-unpinned"
export HASHED_IMAGE_TAG="eos-${FILE_NAME}-${DETERMINED_HASH}"
export FULL_TAG="eosio/ci:$HASHED_IMAGE_TAG"
2 changes: 0 additions & 2 deletions .cicd/installation-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ if [[ $BUILDKITE_BRANCH =~ ^release/[0-9].[0-9]+.x$ || $BUILDKITE_BRANCH =~ ^mas
export CONTRACTS_BUILDER_TAG="eosio/ci-contracts-builder:base-ubuntu-18.04"
export ARGS="--name ci-contracts-builder-$BUILDKITE_COMMIT --init -v $(pwd):$MOUNTED_DIR"
$CICD_DIR/build.sh
docker commit ci-contracts-builder-$BUILDKITE_COMMIT $CONTRACTS_BUILDER_TAG-latest
docker commit ci-contracts-builder-$BUILDKITE_COMMIT $CONTRACTS_BUILDER_TAG-$BUILDKITE_COMMIT
docker commit ci-contracts-builder-$BUILDKITE_COMMIT $CONTRACTS_BUILDER_TAG-$BRANCH
docker commit ci-contracts-builder-$BUILDKITE_COMMIT $CONTRACTS_BUILDER_TAG-$BRANCH-$BUILDKITE_COMMIT
docker push $CONTRACTS_BUILDER_TAG-latest
docker push $CONTRACTS_BUILDER_TAG-$BUILDKITE_COMMIT
docker push $CONTRACTS_BUILDER_TAG-$BRANCH
docker push $CONTRACTS_BUILDER_TAG-$BRANCH-$BUILDKITE_COMMIT
Expand Down
2 changes: 1 addition & 1 deletion .cicd/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if [[ $(uname) == 'Darwin' ]]; then
done
else # Linux
ARGS=${ARGS:-"--rm --init -v $(pwd):$MOUNTED_DIR"}
. $HELPERS_DIR/file-hash.sh $CICD_DIR/platforms/$IMAGE_TAG.dockerfile
. $HELPERS_DIR/file-hash.sh $CICD_DIR/platforms/$PLATFORM_TYPE/$IMAGE_TAG.dockerfile
PRE_COMMANDS="cd $MOUNTED_DIR/build/packages && chmod 755 ./*.sh"
if [[ "$IMAGE_TAG" =~ "ubuntu" ]]; then
ARTIFACT='*.deb'
Expand Down
91 changes: 0 additions & 91 deletions .cicd/platforms/macos-10.14.sh

This file was deleted.

Loading