Skip to content

Commit

Permalink
action: support for benchmark using GitHub actions in conjunction wit…
Browse files Browse the repository at this point in the history
…h Buildkite (#3374)

* ci: remove Jenkins

* support for benchmark using GitHub actions in conjunction with Buildkite

* chore: for testing purposes

* remove any Jenkins references

* add buildkite log echo for helping with collapsing the output in the UI

 this will not show make the UI better in GitHub actions though

* action: group logs

* Revert "action: group logs"

This reverts commit 92bcd6c.

* move the traces earlier

* debug what's going on

* use the installation steps explained in https://github.com/nvm-sh/nvm

* use install manually as explained in https://github.com/nvm-sh/nvm\#manual-install

* Revert "use install manually as explained in https://github.com/nvm-sh/nvm\#manual-install"

This reverts commit 0af0553.

* install only if it is not installed

* debug whether shell login

* avoid errors when calling the nvm for the first time

* support buildkite missbehaviour

* remove debug

* revert changes to be similar to the previous configuration

* debug

* reduce log traces

* Update .ci/scripts/bench.sh

* Apply suggestions from code review

* Apply suggestions from code review

* Apply suggestions from code review

Co-authored-by: Trent Mick <[email protected]>

* ci: small format cleanup

Signed-off-by: Adrien Mannocci <[email protected]>

* ci: let's debug nvm install

Signed-off-by: Adrien Mannocci <[email protected]>

* ci: correct benchmark prepare step

Signed-off-by: Adrien Mannocci <[email protected]>

* ci: flush positional arguments and use major version

Signed-off-by: Adrien Mannocci <[email protected]>

* ci: properly set NODE_VERSION env var

Signed-off-by: Adrien Mannocci <[email protected]>

* ci: use nvmrc instead of explicit value

Signed-off-by: Adrien Mannocci <[email protected]>

* ci: small cleanup

Signed-off-by: Adrien Mannocci <[email protected]>

* ci: last cleanup before merge

Signed-off-by: Adrien Mannocci <[email protected]>

* ci: remove leftover jenkins job scheduling

Signed-off-by: Adrien Mannocci <[email protected]>

---------

Signed-off-by: Adrien Mannocci <[email protected]>
Co-authored-by: Trent Mick <[email protected]>
Co-authored-by: Adrien Mannocci <[email protected]>
  • Loading branch information
3 people authored Jul 6, 2023
1 parent c98f14a commit 230740e
Show file tree
Hide file tree
Showing 13 changed files with 126 additions and 278 deletions.
97 changes: 0 additions & 97 deletions .ci/Jenkinsfile

This file was deleted.

44 changes: 0 additions & 44 deletions .ci/jobs/apm-agent-nodejs-mbp.yml

This file was deleted.

27 changes: 0 additions & 27 deletions .ci/jobs/apm-agent-nodejs-schedule-daily.yml

This file was deleted.

4 changes: 0 additions & 4 deletions .ci/jobs/apm-agent-nodejs.yml

This file was deleted.

22 changes: 0 additions & 22 deletions .ci/jobs/defaults.yml

This file was deleted.

64 changes: 0 additions & 64 deletions .ci/schedule-daily.groovy

This file was deleted.

32 changes: 32 additions & 0 deletions .ci/scripts/bench.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash

# Bash strict mode
set -eo pipefail

# Found current script directory
RELATIVE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

# Found project directory
BASE_PROJECT="$(dirname "$(dirname "${RELATIVE_DIR}")")"

# Run the microbenchmark in Buildkite and for such
# it configures the required settings in the Buildkite runners
# to execute the benchmarks afterwards

## Buildkite specific configuration
if [ "${CI}" == "true" ] ; then
# If HOME is not set then use the Buildkite workspace
# that's normally happening when running in the CI
# owned by Elastic.
if [ -z "${HOME}" ] ; then
HOME="${BUILDKITE_BUILD_CHECKOUT_PATH}"
export HOME
fi
fi

# Run benchmark
echo "--- Execute benchmarks"
"${BASE_PROJECT}/.ci/scripts/run-benchmarks.sh" "apm-agent-benchmark-results.json" "$(cat "${BASE_PROJECT}/.nvmrc")"

echo "--- Send benchmark results"
sendBenchmark "${ES_USER_SECRET}" "${ES_PASS_SECRET}" "${ES_URL_SECRET}" "apm-agent-benchmark-results.json"
29 changes: 22 additions & 7 deletions .ci/scripts/prepare-benchmarks-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,42 @@
# Usage:
# NODE_VERSION=...
# source .../prepare-benchmarks-env.sh
#
# Note: echo "--- ..." helps with presenting the output in Buildkite.
#

set -xeo pipefail

if [[ -z "$NODE_VERSION" ]]; then
if [[ -z "${NODE_VERSION}" ]]; then
echo "prepare-benchmarks-env.sh: error: NODE_VERSION envvar is not set" >&2
exit 1
fi

echo "--- Download nvm"
# This particular configuration is required to be installed in the baremetal
curl -sS -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
export NVM_DIR="$HOME/.nvm"
export NVM_DIR="${HOME}/.nvm"

echo "--- Install nvm"
set +x # Disable xtrace because output using nvm.sh is huge.
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
# Flush positional arguments
shift $#
if [ -s "${NVM_DIR}/nvm.sh" ] ; then
\. "${NVM_DIR}/nvm.sh"
fi

# Check nvm command is available
command -v nvm
nvm --version

echo "--- Run nvm install ${NODE_VERSION}"
nvm install "${NODE_VERSION}"
set -x

npm config list
npm install

# Check node command is available
node --version
npm --version

echo "--- Install dependencies"
set -x
npm config list
npm install
17 changes: 14 additions & 3 deletions .ci/scripts/run-benchmarks.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
#!/usr/bin/env bash
set -xueo pipefail

# Bash strict mode
set -eo pipefail

# Found current script directory
RELATIVE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

# Found project directory
BASE_PROJECT="$(dirname "$(dirname "${RELATIVE_DIR}")")"

# Arguments
RESULT_FILE=$1
NODE_VERSION=$2
if [[ -z "$RESULT_FILE" || -z "$NODE_VERSION" ]]; then
echo "usage: run-benchmarks.sh RESULT_FILE NODE_VERSION"
exit 1
fi

SCRIPTPATH=$(dirname "$0")
source ./${SCRIPTPATH}/prepare-benchmarks-env.sh
# Prepare benchmark environment
export NODE_VERSION="${NODE_VERSION}"
source "${RELATIVE_DIR}/prepare-benchmarks-env.sh"

# Run benchmark
npm run bench:ci "${RESULT_FILE}" "${NODE_VERSION}"
Loading

0 comments on commit 230740e

Please sign in to comment.