Repository: bacalhau-project/bacalhau (language: python)

Issue:
Handle testsuite integration



Discussion / hints:

Fix patch:
diff --git a/Makefile b/Makefile
index bcc4eac1e1..4e9e935bd9 100644
--- a/Makefile
+++ b/Makefile
@@ -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
 
@@ -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 \
 		-- \


Test patch:
diff --git a/buildkite/scripts/test.sh b/buildkite/scripts/test.sh
index ad1f04bbc7..75b159a8f6 100755
--- a/buildkite/scripts/test.sh
+++ b/buildkite/scripts/test.sh
@@ -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 "data=@unittests.xml" \
+      -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"