From 5dd20e4522b73699a7778a039f875855fe384a25 Mon Sep 17 00:00:00 2001 From: jdx <216188+jdx@users.noreply.github.com> Date: Thu, 14 Dec 2023 01:59:27 -0600 Subject: [PATCH] CI: added e2e test for install.sh (#1176) Fixes #1132 --- .github/workflows/rtx.yml | 1 + packaging/standalone/install.envsubst | 14 +++++++------- scripts/release.sh | 6 ++---- scripts/render-install.sh | 2 +- scripts/test-standalone.sh | 20 ++++++++++++++++++++ 5 files changed, 31 insertions(+), 12 deletions(-) create mode 100755 scripts/test-standalone.sh diff --git a/.github/workflows/rtx.yml b/.github/workflows/rtx.yml index 0a215acda0..ad0858f944 100644 --- a/.github/workflows/rtx.yml +++ b/.github/workflows/rtx.yml @@ -43,6 +43,7 @@ jobs: - run: cargo deny check - run: cargo msrv verify - run: cargo machete --with-metadata + - run: ./scripts/test-standalone.sh - run: just render-all lint-fix - if: github.event_name == 'pull_request' uses: EndBug/add-and-commit@v9 diff --git a/packaging/standalone/install.envsubst b/packaging/standalone/install.envsubst index 637319ec84..46d5d9dc52 100644 --- a/packaging/standalone/install.envsubst +++ b/packaging/standalone/install.envsubst @@ -52,13 +52,13 @@ get_arch() { } shasum_bin() { - if command -v shasum >/dev/null 2>&1; then - echo "shasum" - elif command -v sha256sum >/dev/null 2>&1; then - echo "sha256sum" - else - error "rtx install requires shasum or sha256sum but neither is installed. Aborting." - fi + if command -v shasum >/dev/null 2>&1; then + echo "shasum" + elif command -v sha256sum >/dev/null 2>&1; then + echo "sha256sum" + else + error "rtx install requires shasum or sha256sum but neither is installed. Aborting." + fi } get_checksum() { diff --git a/scripts/release.sh b/scripts/release.sh index eb99227eed..2c9cda0b33 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -4,9 +4,10 @@ set -euxo pipefail git config --global user.name rtx-vm git config --global user.email 123107610+rtx-vm@users.noreply.github.com +BASE_DIR="$(cd rtx && pwd)" RTX_VERSION=$(cd rtx && ./scripts/get-version.sh) RELEASE_DIR=releases -export RTX_VERSION RELEASE_DIR +export BASE_DIR RTX_VERSION RELEASE_DIR rm -rf "${RELEASE_DIR:?}/$RTX_VERSION" mkdir -p "$RELEASE_DIR/$RTX_VERSION" @@ -56,9 +57,6 @@ popd ./rtx/scripts/render-install.sh >"$RELEASE_DIR"/install.sh chmod +x "$RELEASE_DIR"/install.sh shellcheck "$RELEASE_DIR"/install.sh -# TODO: figure out how to test this -# "$RELEASE_DIR"/install.sh -#~/.local/share/rtx/bin/rtx -v gpg -u 408B88DB29DDE9E0 --output "$RELEASE_DIR"/install.sh.sig --sign "$RELEASE_DIR"/install.sh if [[ "$DRY_RUN" != 1 ]]; then diff --git a/scripts/render-install.sh b/scripts/render-install.sh index 1f66c73570..7b2b4c7861 100755 --- a/scripts/render-install.sh +++ b/scripts/render-install.sh @@ -14,4 +14,4 @@ RTX_VERSION=$RTX_VERSION \ RTX_CHECKSUM_MACOS_X86_64=$(grep "rtx-v.*macos-x64.tar.gz" "$RELEASE_DIR/$RTX_VERSION/SHASUMS256.txt") \ RTX_CHECKSUM_MACOS_ARM64=$(grep "rtx-v.*macos-arm64.tar.gz" "$RELEASE_DIR/$RTX_VERSION/SHASUMS256.txt") \ envsubst '$RTX_VERSION,$RTX_CHECKSUM_LINUX_X86_64,$RTX_CHECKSUM_LINUX_ARM64,$RTX_CHECKSUM_MACOS_X86_64,$RTX_CHECKSUM_MACOS_ARM64' \ - "$RELEASE_DIR/$RTX_VERSION/SHASUMS256.txt" +./scripts/render-install.sh >tmp/install.sh +chmod +x tmp/install.sh +shellcheck tmp/install.sh + +RTX_DATA_DIR="$RELEASE_DIR" ./tmp/install.sh +if [[ ! "$("$RELEASE_DIR/bin/rtx" -v)" =~ ^${RTX_VERSION//v/} ]]; then + echo "rtx version mismatch" + exit 1 +fi +rm -rf "$RELEASE_DIR"