From 17eb342fa007c98f63785a270549eb42ad9239ec Mon Sep 17 00:00:00 2001 From: gmega Date: Wed, 10 Jun 2026 21:14:47 -0300 Subject: [PATCH] add test setup scripts --- README.md | 3 +++ run-tests.sh | 23 ++++++++++++++++++ scripts/common.sh | 3 +++ scripts/github.sh | 45 ++++++++++++++++++++++++++++++++++ scripts/logos.sh | 62 +++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 136 insertions(+) create mode 100644 README.md create mode 100644 run-tests.sh create mode 100644 scripts/common.sh create mode 100644 scripts/github.sh create mode 100644 scripts/logos.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..22f9462 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Logos Storage Modules E2E Tests + +End-to-end testing harness for running UI tests on the Logos Storage module stack. \ No newline at end of file diff --git a/run-tests.sh b/run-tests.sh new file mode 100644 index 0000000..4c4774b --- /dev/null +++ b/run-tests.sh @@ -0,0 +1,23 @@ +#!/usr/bin/bash + +source "./scripts/logos.sh" +source "./scripts/github.sh" + +LOGOS_QT_MCP_REPO="${LOGOS_QT_MCP_REPO:-logos-co/logos-qt-mcp}" + +gh_clone "logos-co/logos-basecamp" "${BASECAMP_RELEASE_OR_BRANCH:-latest}" +gh_clone "logos-co/logos-storage-module" "${CORE_RELEASE_OR_BRANCH:-latest}" +gh_clone "logos-co/logos-storage-ui" "${UI_RELEASE_OR_BRANCH:-latest}" + +# Allows overriding LOGOS_QT_MCP with a custom repo/tag/branch. +LOGOS_QT_MCP=$(gh_clone "${LOGOS_QT_MCP_REPO}" "${LOGOS_QT_MCP_RELEASE_OR_BRANCH:-latest}") + +BASECAMP_BINARY=$(lg_build_local_basecamp) +STORAGE_CORE_LGX=$(lg_build_local_lgx "logos-storage-module") +STORAGE_UI_LGX=$(lg_build_storage_ui_lgx "logos-storage-ui") + +export LOGOS_QT_MCP +export STORAGE_CORE_LGX +export STORAGE_UI_LGX + +node tests/logos-ui-module-tests.mjs --ci "${BASECAMP_BINARY}" --xvfb \ No newline at end of file diff --git a/scripts/common.sh b/scripts/common.sh new file mode 100644 index 0000000..176eb14 --- /dev/null +++ b/scripts/common.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +echoerr() { echo "$@" >&2; } diff --git a/scripts/github.sh b/scripts/github.sh new file mode 100644 index 0000000..94c9640 --- /dev/null +++ b/scripts/github.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +set -euo pipefail + +SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +source "${SOURCE_DIR}/common.sh" + +gh_latest_release() { + local repo_slug="$1" + local api_url="https://api.github.com/repos/${repo_slug}" + local latest_release + latest_release=$(curl -fsSL "${api_url}/releases/latest" | jq -r '.tag_name') + + if [[ -z "${latest_release}" || "${latest_release}" == "null" ]]; then + echoerr "Error: could not determine latest release for ${repo_slug}" >&2 + return 1 + fi + echoerr "Latest release of ${repo_slug}: ${latest_release}" + echo "${latest_release}" +} + +gh_clone() { + local repo_slug="$1" + local branch_or_tag="$2" + local repo_name="${repo_slug##*/}" + local api_url="https://api.github.com/repos/${repo_slug}" + local dest="${LOGOS_BASE}/${repo_name}" + + if [[ -z "${branch_or_tag}" || "${branch_or_tag}" == "latest" ]]; then + branch_or_tag=$(gh_latest_release "${repo_slug}") || return 1 + fi + + echoerr "Cloning ${repo_slug}: ${branch_or_tag}" + + if [[ -d "${dest}" ]]; then + echoerr "Removing existing ${dest}" + rm -rf "${dest}" + fi + + mkdir -p "$(dirname "${dest}")" + git clone --depth 1 --branch "${branch_or_tag}" \ + "https://github.com/${repo_slug}.git" "${dest}" + + echoerr "Cloned ${repo_slug}@${branch_or_tag} into ${dest}" + echo "${dest}" +} diff --git a/scripts/logos.sh b/scripts/logos.sh new file mode 100644 index 0000000..f380ebf --- /dev/null +++ b/scripts/logos.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash +set -euo pipefail + +SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +source "${SOURCE_DIR}/common.sh" + +LOGOS_BASE="$(cd "${SOURCE_DIR}/.." && pwd)/logos" +export LOGOS_BASE + +mkdir -p "${LOGOS_BASE}" + +_find_lgx() { + local matches + mapfile -t matches < <(find -L ./ -type f -name "*.lgx") + if (( ${#matches[@]} != 1 )); then + echoerr "Expected exactly 1 LGX file, found ${#matches[@]}" + return 1 + fi + realpath "${matches[0]}" +} + +lg_build_local_basecamp() { + if [[ -z "${LOGOS_QT_MCP:-}" ]]; then + echoerr "LOGOS_QT_MCP is not set" + return 1 + fi + cd "${LOGOS_BASE}/logos-basecamp" || return 1 + nix build --override-input logos-qt-mcp "path:${LOGOS_QT_MCP}" '.#app' || return 1 + if [ -e ./result/bin/LogosBasecamp ]; then + echo "${PWD}/result/bin/LogosBasecamp" + else + echoerr "No output found" + return 1 + fi +} + +lg_build_local_lgx() { + local lgx module + + module="$1" + cd "${LOGOS_BASE}/${module}" || return 1 + nix bundle --bundler github:logos-co/nix-bundle-lgx ".#lib" || return 1 + lgx=$(_find_lgx) + echoerr "LGX generated at ${lgx}" + echo "${lgx}" +} + +lg_build_storage_ui_lgx() { + local lgx + + cd "${LOGOS_BASE}/logos-storage-ui" || return 1 + nix build '.#lgx' || return 1 + lgx=$(_find_lgx) + echoerr "LGX generated at ${lgx}" + echo "${lgx}" +} + +lg_start_basecamp() { + local basecamp + basecamp=$(lg_build_local_basecamp) || return 1 + "${basecamp}" & +}