diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 249a51d..c74f752 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -21,6 +21,7 @@ jobs: - bun.sh - charmbracelet-gum - chezmoi.io + - cloudflare.com-warp-cli - deno.com - devenv.sh - feature-installer @@ -68,6 +69,7 @@ jobs: - bun.sh - charmbracelet-gum - chezmoi.io + - cloudflare.com-warp-cli - deno.com - devenv.sh - feature-installer diff --git a/src/cloudflare.com-warp-cli/devcontainer-feature.json b/src/cloudflare.com-warp-cli/devcontainer-feature.json new file mode 100644 index 0000000..4e451e3 --- /dev/null +++ b/src/cloudflare.com-warp-cli/devcontainer-feature.json @@ -0,0 +1,17 @@ +{ + "name": "cloudflare.com-warp-cli", + "id": "cloudflare.com-warp-cli", + "version": "1.0.0", + "description": "Install \"warp-cli\" binary", + "documentationURL": "https://github.com/devcontainer-community/devcontainer-features/tree/main/src/cloudflare.com-warp-cli", + "options": { + "version": { + "type": "string", + "default": "latest", + "proposals": [ + "latest" + ], + "description": "Currently unused." + } + } +} diff --git a/src/cloudflare.com-warp-cli/install.sh b/src/cloudflare.com-warp-cli/install.sh new file mode 100755 index 0000000..ce0bdd8 --- /dev/null +++ b/src/cloudflare.com-warp-cli/install.sh @@ -0,0 +1,43 @@ +#!/bin/bash +set -o errexit +set -o pipefail +set -o noclobber +set -o nounset +set -o allexport +readonly name="warp-cli" +apt_get_update() { + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update -y + fi +} +apt_get_checkinstall() { + if ! dpkg -s "$@" >/dev/null 2>&1; then + apt_get_update + DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends --no-install-suggests --option 'Debug::pkgProblemResolver=true' --option 'Debug::pkgAcquire::Worker=1' "$@" + fi +} +apt_get_cleanup() { + apt-get clean + rm -rf /var/lib/apt/lists/* +} +echo_banner() { + local text="$1" + echo -e "\e[1m\e[97m\e[41m$text\e[0m" +} +install() { + apt_get_checkinstall curl ca-certificates gnupg lsb-release + curl -fsSL https://pkg.cloudflareclient.com/pubkey.gpg \ + | gpg --yes --dearmor --output /usr/share/keyrings/cloudflare-warp-archive-keyring.gpg + echo "deb [signed-by=/usr/share/keyrings/cloudflare-warp-archive-keyring.gpg] https://pkg.cloudflareclient.com/ $(lsb_release -cs) main" \ + | tee /etc/apt/sources.list.d/cloudflare-client.list + apt-get update -y + DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends --no-install-suggests \ + --option 'Debug::pkgProblemResolver=true' --option 'Debug::pkgAcquire::Worker=1' \ + cloudflare-warp + apt_get_cleanup +} +echo_banner "devcontainer.community" +echo "Installing $name..." +install "$@" +echo "(*) Done!" diff --git a/test/cloudflare.com-warp-cli/test.sh b/test/cloudflare.com-warp-cli/test.sh new file mode 100755 index 0000000..71f73d5 --- /dev/null +++ b/test/cloudflare.com-warp-cli/test.sh @@ -0,0 +1,19 @@ +#!/bin/bash + + +set -e + +# Optional: Import test library bundled with the devcontainer CLI +# See https://github.com/devcontainers/cli/blob/HEAD/docs/features/test.md#dev-container-features-test-lib +# Provides the 'check' and 'reportResults' commands. +source dev-container-features-test-lib + +# Feature-specific tests +# The 'check' command comes from the dev-container-features-test-lib. Syntax is... +# check