Skip to content

Commit 230740e

Browse files
v1vtrentmamannocci
authored
action: support for benchmark using GitHub actions in conjunction with 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 <trent.mick@elastic.co> * ci: small format cleanup Signed-off-by: Adrien Mannocci <adrien.mannocci@elastic.co> * ci: let's debug nvm install Signed-off-by: Adrien Mannocci <adrien.mannocci@elastic.co> * ci: correct benchmark prepare step Signed-off-by: Adrien Mannocci <adrien.mannocci@elastic.co> * ci: flush positional arguments and use major version Signed-off-by: Adrien Mannocci <adrien.mannocci@elastic.co> * ci: properly set NODE_VERSION env var Signed-off-by: Adrien Mannocci <adrien.mannocci@elastic.co> * ci: use nvmrc instead of explicit value Signed-off-by: Adrien Mannocci <adrien.mannocci@elastic.co> * ci: small cleanup Signed-off-by: Adrien Mannocci <adrien.mannocci@elastic.co> * ci: last cleanup before merge Signed-off-by: Adrien Mannocci <adrien.mannocci@elastic.co> * ci: remove leftover jenkins job scheduling Signed-off-by: Adrien Mannocci <adrien.mannocci@elastic.co> --------- Signed-off-by: Adrien Mannocci <adrien.mannocci@elastic.co> Co-authored-by: Trent Mick <trent.mick@elastic.co> Co-authored-by: Adrien Mannocci <adrien.mannocci@elastic.co>
1 parent c98f14a commit 230740e

13 files changed

+126
-278
lines changed

.ci/Jenkinsfile

-97
This file was deleted.

.ci/jobs/apm-agent-nodejs-mbp.yml

-44
This file was deleted.

.ci/jobs/apm-agent-nodejs-schedule-daily.yml

-27
This file was deleted.

.ci/jobs/apm-agent-nodejs.yml

-4
This file was deleted.

.ci/jobs/defaults.yml

-22
This file was deleted.

.ci/schedule-daily.groovy

-64
This file was deleted.

.ci/scripts/bench.sh

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
3+
# Bash strict mode
4+
set -eo pipefail
5+
6+
# Found current script directory
7+
RELATIVE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
8+
9+
# Found project directory
10+
BASE_PROJECT="$(dirname "$(dirname "${RELATIVE_DIR}")")"
11+
12+
# Run the microbenchmark in Buildkite and for such
13+
# it configures the required settings in the Buildkite runners
14+
# to execute the benchmarks afterwards
15+
16+
## Buildkite specific configuration
17+
if [ "${CI}" == "true" ] ; then
18+
# If HOME is not set then use the Buildkite workspace
19+
# that's normally happening when running in the CI
20+
# owned by Elastic.
21+
if [ -z "${HOME}" ] ; then
22+
HOME="${BUILDKITE_BUILD_CHECKOUT_PATH}"
23+
export HOME
24+
fi
25+
fi
26+
27+
# Run benchmark
28+
echo "--- Execute benchmarks"
29+
"${BASE_PROJECT}/.ci/scripts/run-benchmarks.sh" "apm-agent-benchmark-results.json" "$(cat "${BASE_PROJECT}/.nvmrc")"
30+
31+
echo "--- Send benchmark results"
32+
sendBenchmark "${ES_USER_SECRET}" "${ES_PASS_SECRET}" "${ES_URL_SECRET}" "apm-agent-benchmark-results.json"

.ci/scripts/prepare-benchmarks-env.sh

+22-7
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,42 @@
66
# Usage:
77
# NODE_VERSION=...
88
# source .../prepare-benchmarks-env.sh
9+
#
10+
# Note: echo "--- ..." helps with presenting the output in Buildkite.
11+
#
912

1013
set -xeo pipefail
1114

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

20+
echo "--- Download nvm"
1721
# This particular configuration is required to be installed in the baremetal
1822
curl -sS -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
19-
export NVM_DIR="$HOME/.nvm"
23+
export NVM_DIR="${HOME}/.nvm"
24+
25+
echo "--- Install nvm"
2026
set +x # Disable xtrace because output using nvm.sh is huge.
21-
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
27+
# Flush positional arguments
28+
shift $#
29+
if [ -s "${NVM_DIR}/nvm.sh" ] ; then
30+
\. "${NVM_DIR}/nvm.sh"
31+
fi
32+
33+
# Check nvm command is available
2234
command -v nvm
2335
nvm --version
2436

37+
echo "--- Run nvm install ${NODE_VERSION}"
2538
nvm install "${NODE_VERSION}"
26-
set -x
27-
28-
npm config list
29-
npm install
3039

40+
# Check node command is available
3141
node --version
3242
npm --version
43+
44+
echo "--- Install dependencies"
45+
set -x
46+
npm config list
47+
npm install

.ci/scripts/run-benchmarks.sh

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
11
#!/usr/bin/env bash
2-
set -xueo pipefail
32

3+
# Bash strict mode
4+
set -eo pipefail
5+
6+
# Found current script directory
7+
RELATIVE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
8+
9+
# Found project directory
10+
BASE_PROJECT="$(dirname "$(dirname "${RELATIVE_DIR}")")"
11+
12+
# Arguments
413
RESULT_FILE=$1
514
NODE_VERSION=$2
615
if [[ -z "$RESULT_FILE" || -z "$NODE_VERSION" ]]; then
716
echo "usage: run-benchmarks.sh RESULT_FILE NODE_VERSION"
817
exit 1
918
fi
1019

11-
SCRIPTPATH=$(dirname "$0")
12-
source ./${SCRIPTPATH}/prepare-benchmarks-env.sh
20+
# Prepare benchmark environment
21+
export NODE_VERSION="${NODE_VERSION}"
22+
source "${RELATIVE_DIR}/prepare-benchmarks-env.sh"
1323

24+
# Run benchmark
1425
npm run bench:ci "${RESULT_FILE}" "${NODE_VERSION}"

0 commit comments

Comments
 (0)