Skip to content

Commit

Permalink
CI: added e2e test for install.sh
Browse files Browse the repository at this point in the history
Fixes #1132
  • Loading branch information
jdx committed Dec 14, 2023
1 parent cf92bb3 commit c7f0f1a
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 9 deletions.
1 change: 1 addition & 0 deletions .github/workflows/rtx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions packaging/standalone/install.envsubst
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
4 changes: 3 additions & 1 deletion scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ set -euxo pipefail
git config --global user.name rtx-vm
git config --global user.email [email protected]

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"

Expand Down Expand Up @@ -54,6 +55,7 @@ gpg --clearsign -u 408B88DB29DDE9E0 <SHASUMS512.txt >SHASUMS512.asc
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
Expand Down
2 changes: 1 addition & 1 deletion scripts/render-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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' \
<rtx/packaging/standalone/install.envsubst
<"$BASE_DIR/packaging/standalone/install.envsubst"
19 changes: 19 additions & 0 deletions scripts/test-standalone.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -euxo pipefail

BASE_DIR="$(pwd)"
RELEASE_DIR="$(pwd)/tmp"
RTX_VERSION="v$(curl -fsSL https://rtx.jdx.dev/VERSION)"
export BASE_DIR RELEASE_DIR RTX_VERSION

mkdir -p "$RELEASE_DIR/$RTX_VERSION"
curl -fsSL "https://rtx.jdx.dev/$RTX_VERSION/SHASUMS256.txt" >"$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

0 comments on commit c7f0f1a

Please sign in to comment.