2024-04-21 22:28:35 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
# Path to Complement's source code
|
|
|
|
#
|
|
|
|
# The `COMPLEMENT_SRC` environment variable is set in the Nix dev shell, which
|
|
|
|
# points to a store path containing the Complement source code. It's likely you
|
|
|
|
# want to just pass that as the first argument to use it here.
|
2024-07-07 01:15:44 +00:00
|
|
|
COMPLEMENT_SRC="${COMPLEMENT_SRC:-$1}"
|
2024-04-21 22:28:35 +00:00
|
|
|
|
|
|
|
# A `.jsonl` file to write test logs to
|
|
|
|
LOG_FILE="$2"
|
|
|
|
|
|
|
|
# A `.jsonl` file to write test results to
|
|
|
|
RESULTS_FILE="$3"
|
|
|
|
|
2024-10-25 01:29:17 +00:00
|
|
|
OCI_IMAGE="complement-conduwuit:main"
|
2024-04-21 22:28:35 +00:00
|
|
|
|
2024-07-07 01:15:44 +00:00
|
|
|
# Complement tests that are skipped due to flakiness/reliability issues
|
2024-10-31 18:41:35 +00:00
|
|
|
SKIPPED_COMPLEMENT_TESTS='-skip=TestClientSpacesSummary.*|TestJoinFederatedRoomFromApplicationServiceBridgeUser.*|TestJumpToDateEndpoint.*|TestUnbanViaInvite.*'
|
2024-05-22 00:59:45 +00:00
|
|
|
|
2024-07-07 01:15:44 +00:00
|
|
|
# $COMPLEMENT_SRC needs to be a directory to Complement source code
|
|
|
|
if [ -f "$COMPLEMENT_SRC" ]; then
|
|
|
|
echo "\$COMPLEMENT_SRC must be a directory/path to Complement source code"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# quick test to make sure we can actually write to $LOG_FILE and $RESULTS_FILE
|
|
|
|
touch $LOG_FILE && rm -v $LOG_FILE
|
|
|
|
touch $RESULTS_FILE && rm -v $RESULTS_FILE
|
|
|
|
|
2024-05-02 03:30:49 +00:00
|
|
|
toplevel="$(git rev-parse --show-toplevel)"
|
|
|
|
|
|
|
|
pushd "$toplevel" > /dev/null
|
2024-05-06 05:09:51 +00:00
|
|
|
|
2024-10-25 03:03:36 +00:00
|
|
|
bin/nix-build-and-cache just .#linux-complement
|
2024-05-06 05:09:51 +00:00
|
|
|
|
2024-04-21 22:28:35 +00:00
|
|
|
docker load < result
|
|
|
|
popd > /dev/null
|
|
|
|
|
|
|
|
# It's okay (likely, even) that `go test` exits nonzero
|
|
|
|
set +o pipefail
|
|
|
|
env \
|
|
|
|
-C "$COMPLEMENT_SRC" \
|
|
|
|
COMPLEMENT_BASE_IMAGE="$OCI_IMAGE" \
|
2024-07-04 05:51:32 +00:00
|
|
|
go test -tags="conduwuit_blacklist" "$SKIPPED_COMPLEMENT_TESTS" -v -timeout 1h -json ./tests | tee "$LOG_FILE"
|
2024-04-21 22:28:35 +00:00
|
|
|
set -o pipefail
|
|
|
|
|
2024-05-02 14:32:30 +00:00
|
|
|
# Post-process the results into an easy-to-compare format, sorted by Test name for reproducible results
|
|
|
|
cat "$LOG_FILE" | jq -s -c 'sort_by(.Test)[]' | jq -c '
|
2024-04-21 22:28:35 +00:00
|
|
|
select(
|
|
|
|
(.Action == "pass" or .Action == "fail" or .Action == "skip")
|
|
|
|
and .Test != null
|
|
|
|
) | {Action: .Action, Test: .Test}
|
2024-05-02 14:32:30 +00:00
|
|
|
' > "$RESULTS_FILE"
|