Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

[CI] [Buildkite] Migrate Primary Pipeline #570

Closed
wants to merge 25 commits into from
Closed
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
25 changes: 22 additions & 3 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
steps:
- label: "Placeholder Pipeline"
command: echo "Hello!"
agents:
provider: "gcp"
machineType: "n1-standard-8"
useVault: true

defaultTimeoutInMinutes: 45
steps:
- label: ":safety_vest: Connectors Tests"
commands:
- "./.buildkite/scripts/run_command.sh tests"
artifact_paths:
- "coverage/index.html"
- label: ":wrench: Linter"
commands:
- "./.buildkite/scripts/run_command.sh linter"
- label: ":package: Docker"
commands:
- "./.buildkite/scripts/run_command.sh docker"
- label: ":package: Packaging"
commands:
- "./.buildkite/scripts/run_command.sh packaging"
artifact_paths:
- ".gems/*.gem"
36 changes: 36 additions & 0 deletions .buildkite/scripts/run_ci_step.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

set -euxo pipefail

export PATH="$PATH:/root/.rbenv/bin:/root/.rbenv/plugins/ruby-build/bin:/ci/.rbenv/shims"

RUBY_VERSION=$(cat .ruby-version)
echo "---- installing Ruby version $RUBY_VERSION"
rbenv install $RUBY_VERSION
rbenv global $RUBY_VERSION

case $1 in

tests)
echo "---- running unit tests"
make install test
;;

linter)
echo "---- running linter"
make install lint
;;

packaging)
echo "---- running packaging"
curl -L -o yq https://github.com/mikefarah/yq/releases/download/v4.21.1/yq_linux_amd64
chmod +x yq
YQ=`realpath yq` make install build_service build_service_gem
gem install .gems/connectors_service-8.*
;;

*)
echo "Usage: run_command {tests|linter|packaging}"
exit 2
;;
esac
39 changes: 39 additions & 0 deletions .buildkite/scripts/run_command.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

set -euxo pipefail

COMMAND_TO_RUN=${1:-}

if [[ "${COMMAND_TO_RUN:-}" == "" ]]; then
echo "Usage: run_command.sh {tests|linter|docker|packaging}"
exit 2
fi

function realpath {
echo "$(cd "$(dirname "$1")"; pwd)"/"$(basename "$1")";
}

SCRIPT_WORKING_DIR=$(realpath "$(dirname "$0")")
BUILDKITE_DIR=$(realpath "$(dirname "$SCRIPT_WORKING_DIR")")
PROJECT_ROOT=$(realpath "$(dirname "$BUILDKITE_DIR")")

if [[ "${COMMAND_TO_RUN:-}" == "docker" ]]; then
echo "running docker build"
make build-docker
else
DOCKER_IMAGE="docker.elastic.co/ci-agent-images/enterprise-search/rbenv-buildkite-agent:latest"
SCRIPT_CMD="/ci/.buildkite/scripts/run_ci_step.sh"

docker run --interactive --rm \
--sig-proxy=true --init \
--user "root" \
--volume "$PROJECT_ROOT:/ci" \
--workdir /ci \
--env HOME=/ci \
--env CI \
--env GIT_REVISION=${BUILDKITE_COMMIT-} \
--env BUILD_ID=${BUILDKITE_BUILD_NUMBER-} \
--entrypoint "${SCRIPT_CMD}" \
$DOCKER_IMAGE \
$COMMAND_TO_RUN
fi