Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
matrix:
features:
- chezmoi
- gum
- k3d
- k9s
- kustomize
Expand Down
13 changes: 13 additions & 0 deletions src/gum/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "gum",
"id": "gum",
"version": "1.0.0",
"description": "A tool for glamorous shell scripts.",
"options": {
"version": {
"type": "string",
"default": "latest",
"description": "Version of gum to install. Accepts versions with or without the 'v' prefix."
}
}
}
73 changes: 73 additions & 0 deletions src/gum/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/bin/sh
set -e

# grab the version
readonly GUM_VERSION="${VERSION:-latest}"

# apt-get configuration
export DEBIAN_FRONTEND=noninteractive


preflight () {
if command -v wget > /dev/null; then
return
fi

if [ -e /etc/os-release ]; then
. /etc/os-release
fi

case "${ID}" in
'debian' | 'ubuntu')
apt-get update
apt-get install -y --no-install-recommends \
wget \
ca-certificates
;;
'fedora')
dnf -y install wget
;;
*) echo "The ${ID} distribution is not supported."; exit 1 ;;
esac
}

main () {
preflight

local ARCH="$(uname -m)"
case "${ARCH}" in
"aarch64") ARCH="arm64" ;;
"x86_64") ARCH="x86_64" ;;
*) echo "The current architecture (${ARCH}) is not supported."; exit 1 ;;
esac

if [ "${GUM_VERSION}" != "latest" ] ; then
GUM_CHECKSUMS_URL="https://github.com/charmbracelet/gum/releases/download/v${GUM_VERSION#[vV]}/checksums.txt"
GUM_URL="https://github.com/charmbracelet/gum/releases/download/v${GUM_VERSION#[vV]}/gum_${GUM_VERSION#[vV]}_Linux_${ARCH}.tar.gz"
else
local RELEASES_RESPONSE="$(wget -qO- --tries=3 https://api.github.com/repos/charmbracelet/gum/releases)"
GUM_CHECKSUMS_URL="$(echo "${RELEASES_RESPONSE}" | grep "browser_download_url.*checksums.txt" | head -n 1 | cut -d '"' -f 4)"
GUM_URL="$(echo "${RELEASES_RESPONSE}" | grep "browser_download_url.*Linux_${ARCH}.tar.gz" | head -n 1 | cut -d '"' -f 4)"
fi

echo "Installing gum ${GUM_VERSION} for ${ARCH} ..."

echo "Downloading checksums ${GUM_CHECKSUMS_URL} ..."
wget --no-verbose -O /tmp/checksums.txt "${GUM_CHECKSUMS_URL}"
local GUM_SHA="$(grep Linux_${ARCH}.tar.gz$ /tmp/checksums.txt | cut -d ' ' -f 1)"

echo "Downloading ${GUM_URL} ..."
wget --no-verbose -O /tmp/gum.tar.gz "${GUM_URL}"

echo "Verifying checksum ${GUM_SHA} ..."
echo "${GUM_SHA} /tmp/gum.tar.gz" | sha256sum -c -

echo "Extracting..."
tar xf /tmp/gum.tar.gz --directory=/usr/local/bin --strip-components=1 --wildcards gum_*_Linux_${ARCH}/gum
chmod +x /usr/local/bin/gum
rm /tmp/gum.tar.gz

echo "gum ${GUM_VERSION} for ${ARCH} installed at $(command -v gum)."
}

main "$@"
1 change: 1 addition & 0 deletions test/_global/all-tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ source dev-container-features-test-lib
# The 'check' command comes from the dev-container-features-test-lib.
check "skaffold" skaffold version
check "chezmoi" chezmoi --version
check "gum" gum --version
check "kustomize" kustomize version
check "k9s" k9s version
check "k3d" k3d version
Expand Down
1 change: 1 addition & 0 deletions test/_global/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"features": {
"chezmoi": {},
"skaffold": {},
"gum": {},
"k9s": {},
"k3d": {},
"kustomize": {},
Expand Down
14 changes: 14 additions & 0 deletions test/gum/gum-specific-version-with-prefix.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

set -e

# Optional: Import test library bundled with the devcontainer CLI
source dev-container-features-test-lib

# Feature-specific tests
# The 'check' command comes from the dev-container-features-test-lib.
check "gum specific version v0.16.1" /bin/bash -c "gum --version | grep 'v0.16.1'"

# Report result
# If any of the checks above exited with a non-zero exit code, the test will fail.
reportResults
14 changes: 14 additions & 0 deletions test/gum/gum-specific-version-without-prefix.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

set -e

# Optional: Import test library bundled with the devcontainer CLI
source dev-container-features-test-lib

# Feature-specific tests
# The 'check' command comes from the dev-container-features-test-lib.
check "gum specific version .16.1" /bin/bash -c "gum --version | grep 'v0.16.1'"

# Report result
# If any of the checks above exited with a non-zero exit code, the test will fail.
reportResults
18 changes: 18 additions & 0 deletions test/gum/scenarios.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"gum-specific-version-without-prefix": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"gum": {
"version": "0.16.1"
}
}
},
"gum-specific-version-with-prefix": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"gum": {
"version": "v0.16.1"
}
}
}
}
14 changes: 14 additions & 0 deletions test/gum/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

set -e

# Optional: Import test library bundled with the devcontainer CLI
source dev-container-features-test-lib

# Feature-specific tests
# The 'check' command comes from the dev-container-features-test-lib.
check "gum" gum --version

# Report result
# If any of the checks above exited with a non-zero exit code, the test will fail.
reportResults