Skip to content

Commit

Permalink
Testsuite Integration for Buildkite (#4309)
Browse files Browse the repository at this point in the history
This PR aims at the following

- Send testsuite executions to Buildkite Portal for better insights

closes #4300
  • Loading branch information
udsamani authored Aug 8, 2024
1 parent a3dcc8f commit f4bef24
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 18 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ integration-test:
go test ./... -v --tags=integration -p 1

.PHONY: bash-test
bash-test:
bash-test:
${BINARY_PATH}
cd test && bin/bashtub *.sh

Expand Down Expand Up @@ -439,7 +439,6 @@ test-and-report: unittests.xml ${COVER_FILE}

${COVER_FILE} unittests.xml ${TEST_OUTPUT_FILE_PREFIX}_unit.json &: ${CMD_FILES} ${PKG_FILES} $(dir ${COVER_FILE})
gotestsum \
--jsonfile ${TEST_OUTPUT_FILE_PREFIX}_unit.json \
--junitfile unittests.xml \
--format testname \
-- \
Expand Down
81 changes: 65 additions & 16 deletions buildkite/scripts/test.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,67 @@
#!/bin/bash

export LOG_LEVEL=DEBUG
export TEST_BUILD_TAGS=$1
export TEST_PARALLEL_PACKAGES=8
export BACALHAU_ENVIRONMENT=test
export AWS_ACCESS_KEY_ID=$(buildkite-agent secret get AWS_ACCESS_KEY_ID)
export AWS_SECRET_ACCESS_KEY=$(buildkite-agent secret get AWS_SECRET_ACCESS_KEY)
export AWS_REGION=eu-west-1

ipfs init
ipfs config Addresses.API /ip4/127.0.0.1/tcp/5001
ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080
ipfs daemon --offline &
export BACALHAU_NODE_IPFS_CONNECT=/ip4/127.0.0.1/tcp/5001

make build-webui
make test-and-report
# Exit immediately if a command exits with a non-zero status
set -e

# Function to set environment variables
set_environment_variables() {
export LOG_LEVEL=DEBUG
export TEST_BUILD_TAGS=$1
export TEST_PARALLEL_PACKAGES=8
export BACALHAU_ENVIRONMENT=test
export AWS_ACCESS_KEY_ID=$(buildkite-agent secret get AWS_ACCESS_KEY_ID)
export AWS_SECRET_ACCESS_KEY=$(buildkite-agent secret get AWS_SECRET_ACCESS_KEY)
export BUILDKITE_ANALYTICS_TOKEN=$(buildkite-agent secret get TESTSUITE_TOKEN)
export AWS_REGION=eu-west-1
}

# Function to initialize IPFS
initialize_ipfs() {
ipfs init
ipfs config Addresses.API /ip4/127.0.0.1/tcp/5001
ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080
ipfs daemon --offline &
export BACALHAU_NODE_IPFS_CONNECT=/ip4/127.0.0.1/tcp/5001
}

# Function to build web UI
build_web_ui() {
make build-webui
}

# Function to run tests and report
run_tests_and_report() {
make test-and-report
}

# Function to upload test results
upload_test_results() {
curl \
-X POST \
--fail-with-body \
--verbose \
-H "Authorization: Token token=\"$BUILDKITE_ANALYTICS_TOKEN\"" \
-F "[email protected]" \
-F "format=junit" \
-F "run_env[CI]=buildkite" \
-F "run_env[key]=$BUILDKITE_BUILD_ID" \
-F "run_env[number]=$BUILDKITE_BUILD_NUMBER" \
-F "run_env[job_id]=$BUILDKITE_JOB_ID" \
-F "run_env[branch]=$BUILDKITE_BRANCH" \
-F "run_env[commit_sha]=$BUILDKITE_COMMIT" \
-F "run_env[message]=$BUILDKITE_MESSAGE" \
-F "run_env[url]=$BUILDKITE_BUILD_URL" \
https://analytics-api.buildkite.com/v1/uploads
}

# Main function to execute the script
test() {
set_environment_variables $1
initialize_ipfs
build_web_ui
run_tests_and_report
upload_test_results
}

# Call the main function with the provided test tag
test "$1"

0 comments on commit f4bef24

Please sign in to comment.