From 3d05f4cbb62948175df3b3db123fa12c998d8fa6 Mon Sep 17 00:00:00 2001 From: Bas Steins <592313+sebst@users.noreply.github.com> Date: Sat, 12 Oct 2024 22:31:16 +0200 Subject: [PATCH] feat(`webinstall.dev`): Add feature. (#15) * feat(`webinstall.dev`): Add feature. * feat(`webinstall.dev`): Fix `devcontainer-feature.json`. --- .github/workflows/test.yaml | 2 ++ src/webinstall.dev/devcontainer-feature.json | 17 +++++++++ src/webinstall.dev/install.sh | 36 ++++++++++++++++++++ test/webinstall.dev/test.sh | 19 +++++++++++ 4 files changed, 74 insertions(+) create mode 100644 src/webinstall.dev/devcontainer-feature.json create mode 100755 src/webinstall.dev/install.sh create mode 100755 test/webinstall.dev/test.sh diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 9beaa49..860d312 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -20,6 +20,7 @@ jobs: - pkgx.sh - smallstep.com - starship.rs + - webinstall.dev - zellij.dev baseImage: - debian:latest @@ -47,6 +48,7 @@ jobs: - pkgx.sh - smallstep.com - starship.rs + - webinstall.dev - zellij.dev steps: - uses: actions/checkout@v4 diff --git a/src/webinstall.dev/devcontainer-feature.json b/src/webinstall.dev/devcontainer-feature.json new file mode 100644 index 0000000..dca0323 --- /dev/null +++ b/src/webinstall.dev/devcontainer-feature.json @@ -0,0 +1,17 @@ +{ + "name": "webinstall.dev", + "id": "webinstall.dev", + "version": "1.0.0", + "description": "Install \"webi\" binary", + "documentationURL": "https://github.com/devcontainer-community/devcontainer-features/tree/main/src/webinstall.dev", + "options": { + "version": { + "type": "string", + "default": "latest", + "proposals": [ + "latest" + ], + "description": "Version of \"webi\" to install." + } + } +} \ No newline at end of file diff --git a/src/webinstall.dev/install.sh b/src/webinstall.dev/install.sh new file mode 100755 index 0000000..a1e388f --- /dev/null +++ b/src/webinstall.dev/install.sh @@ -0,0 +1,36 @@ +#!/bin/bash +set -o errexit +set -o pipefail +set -o noclobber +set -o nounset +set -o allexport +readonly name="asdf" +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 + su $_REMOTE_USER -c "curl -sS https://webi.sh/webi | sh" + apt_get_cleanup +} +echo_banner "devcontainer.community" +echo "Installing $name..." +install "$@" +echo "(*) Done!" diff --git a/test/webinstall.dev/test.sh b/test/webinstall.dev/test.sh new file mode 100755 index 0000000..d0c92a8 --- /dev/null +++ b/test/webinstall.dev/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