From cdfb0d3011168cd4f6b15d2e356cc6110dcc8354 Mon Sep 17 00:00:00 2001 From: Fazle Adyuta Utomo Date: Sat, 23 Aug 2025 22:31:42 +0000 Subject: [PATCH 1/6] refactor(go-air): move all pre-installation checks into check_packages --- src/go-air/devcontainer-feature.json | 2 +- src/go-air/install.sh | 9 ++------- src/go-air/utils.sh | 21 +++++++++++++++++---- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/go-air/devcontainer-feature.json b/src/go-air/devcontainer-feature.json index 8844202..10e8e1d 100644 --- a/src/go-air/devcontainer-feature.json +++ b/src/go-air/devcontainer-feature.json @@ -1,7 +1,7 @@ { "name": "Air", "id": "go-air", - "version": "1.1.0", + "version": "1.1.1", "documentationURL": "http://github.com/omoxyz/devcontainer-features/tree/main/src/go-air", "description": "Install Air live reloader for Go apps.", "options": { diff --git a/src/go-air/install.sh b/src/go-air/install.sh index 869b7b8..1fb3a51 100644 --- a/src/go-air/install.sh +++ b/src/go-air/install.sh @@ -76,13 +76,8 @@ install_from_github() { rm -rf /tmp/air } -# Install curl if missing -check_packages curl ca-certificates - -# Install git if missing -if ! type git > /dev/null 2>&1; then - check_packages git -fi +# Install curl, git if missing +check_packages curl ca-certificates git version_list=$(git ls-remote --tags ${GITHUB_REPO}) diff --git a/src/go-air/utils.sh b/src/go-air/utils.sh index cb8c907..2d001db 100644 --- a/src/go-air/utils.sh +++ b/src/go-air/utils.sh @@ -10,11 +10,24 @@ apt_get_update() { # Checks if packages are installed and installs them if not check_packages() { - if ! dpkg -s "$@" > /dev/null 2>&1; then + for pkg in "$@"; do + # Check if it's a command in PATH + if command -v "$pkg" &> /dev/null; then + echo "[OK] $pkg found in PATH" + continue + fi + + # Check if it's a Debian/Ubuntu package installed + if dpkg -s "$pkg" &> /dev/null; then + echo "[OK] $pkg package installed" + continue + fi + + # If not found, install package + echo "$pkg not found. Installing..." apt_get_update - echo "Installing $@..." - apt-get install -y --no-install-recommends $@ - fi + apt-get install -y --no-install-recommends $pkg + done } # Find 2 latest versions that appropriate to requested version From b7eff5a90e8bf0c42805dc0f90f3612880c25326 Mon Sep 17 00:00:00 2001 From: Fazle Adyuta Utomo Date: Sat, 23 Aug 2025 22:40:31 +0000 Subject: [PATCH 2/6] refactor(lefthook): consolidate pre-install checks into check_packages - Move all pre-installation checks into `check_packages` - Add fallback to latest version when previous version is not found --- src/lefthook/devcontainer-feature.json | 2 +- src/lefthook/install.sh | 6 ++---- src/lefthook/utils.sh | 22 ++++++++++++++++++---- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/lefthook/devcontainer-feature.json b/src/lefthook/devcontainer-feature.json index 5c6fed7..82ac89a 100644 --- a/src/lefthook/devcontainer-feature.json +++ b/src/lefthook/devcontainer-feature.json @@ -1,7 +1,7 @@ { "name": "Lefthook", "id": "lefthook", - "version": "1.0.2", + "version": "1.0.3", "documentationURL": "http://github.com/omoxyz/devcontainer-features/tree/main/src/lefthook", "description": "Install Lefthook fast polyglot Git hooks manager.", "options": { diff --git a/src/lefthook/install.sh b/src/lefthook/install.sh index 811f603..828d71c 100644 --- a/src/lefthook/install.sh +++ b/src/lefthook/install.sh @@ -37,7 +37,7 @@ install_from_github() { fi latest_version=${versions[0]} - prev_version=${versions[1]} + prev_version=${versions[1]:-$latest_version} echo "Downloading lefthook v${latest_version}...." @@ -90,9 +90,7 @@ check_packages curl ca-certificates # Install Lefthook if [ "${INSTALL_DIRECTLY_FROM_GITHUB_RELEASE}" = "true" ]; then # Install git if missing - if ! type git > /dev/null 2>&1; then - check_packages git - fi + check_packages git install_from_github else diff --git a/src/lefthook/utils.sh b/src/lefthook/utils.sh index fcafce2..053090a 100644 --- a/src/lefthook/utils.sh +++ b/src/lefthook/utils.sh @@ -10,11 +10,25 @@ apt_get_update() { # Checks if packages are installed and installs them if not check_packages() { - if ! dpkg -s "$@" > /dev/null 2>&1; then + for pkg in "$@"; do + # Check if it's a command in PATH + if command -v "$pkg" &> /dev/null; then + echo "[OK] $pkg found in PATH" + continue + fi + + # Check if it's a Debian/Ubuntu package installed + if dpkg -s "$pkg" &> /dev/null; then + echo "[OK] $pkg package installed" + continue + fi + + # If not found, install package + echo "$pkg not found. Installing..." apt_get_update - echo "Installing $@..." - apt-get install -y --no-install-recommends $@ - fi + apt-get install -y --no-install-recommends $pkg + + done } # Find 2 latest versions that appropriate to requested version From 35230940f30b7c0ca6d97a01837722c0baf56ff7 Mon Sep 17 00:00:00 2001 From: Fazle Adyuta Utomo Date: Sat, 23 Aug 2025 22:49:40 +0000 Subject: [PATCH 3/6] refactor(protolint): add fallback to latest version when previous version is not found --- src/protolint/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/protolint/install.sh b/src/protolint/install.sh index ea4ad29..38ecf5e 100644 --- a/src/protolint/install.sh +++ b/src/protolint/install.sh @@ -37,7 +37,7 @@ install_from_github() { fi latest_version=${versions[0]} - prev_version=${versions[1]} + prev_version=${versions[1]:-$latest_version} echo "Downloading protolint v${latest_version}...." From 7c5c20695df3109aa4480ec8ac9860cef358706e Mon Sep 17 00:00:00 2001 From: Fazle Adyuta Utomo Date: Sat, 23 Aug 2025 22:50:31 +0000 Subject: [PATCH 4/6] test(protolint): fix test scenario --- test/protolint/scenarios.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/protolint/scenarios.json b/test/protolint/scenarios.json index eb2c92f..c0d8a49 100644 --- a/test/protolint/scenarios.json +++ b/test/protolint/scenarios.json @@ -2,7 +2,7 @@ "test": { "image": "mcr.microsoft.com/devcontainers/base:debian", "features": { - "protoc": {} + "protolint": {} } } } \ No newline at end of file From 7931b4a5b25411275573a3247c330c2fb1c368b4 Mon Sep 17 00:00:00 2001 From: Fazle Adyuta Utomo Date: Sat, 23 Aug 2025 22:56:30 +0000 Subject: [PATCH 5/6] chore(vscode): change launch test configurations - Remove --skip-scenarios argument - Set ubuntu as default base image --- .vscode/launch.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 9ceca1b..857f686 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -21,7 +21,6 @@ "args": [ "features", "test", - "--skip-scenarios", "-f", "${input:selectedFeatures}", "-i", @@ -59,7 +58,7 @@ "id": "selectedBaseImage", "type": "promptString", "description": "Base Image", - "default": "mcr.microsoft.com/vscode/devcontainers/base:ubuntu" + "default": "mcr.microsoft.com/vscode/devcontainers/base:debian" } ] } \ No newline at end of file From 87f76957cda0a00b33e35c1d00403369b7f01da6 Mon Sep 17 00:00:00 2001 From: Fazle Adyuta Utomo Date: Sat, 23 Aug 2025 22:56:48 +0000 Subject: [PATCH 6/6] ci: simplify test workflow Remove test-autogenerated and change test-scenarios to avoid outdated test configuration --- .github/workflows/test.yaml | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index ef104ed..0964d75 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -7,42 +7,22 @@ on: workflow_dispatch: jobs: - test-autogenerated: - runs-on: ubuntu-latest - continue-on-error: true - strategy: - matrix: - features: - - lefthook - baseImage: - - debian:latest - - ubuntu:latest - - mcr.microsoft.com/devcontainers/base:ubuntu - steps: - - uses: actions/checkout@v4 - - - name: "Install latest devcontainer CLI" - run: npm install -g @devcontainers/cli - - - name: "Generating tests for '${{ matrix.features }}' against '${{ matrix.baseImage }}'" - run: devcontainer features test --skip-scenarios -f ${{ matrix.features }} -i ${{ matrix.baseImage }} . - test-scenarios: runs-on: ubuntu-latest continue-on-error: true strategy: matrix: - features: - - lefthook - - go-air + images: + - mcr.microsoft.com/devcontainers/base:debian + - mcr.microsoft.com/devcontainers/base:ubuntu steps: - uses: actions/checkout@v4 - name: "Install latest devcontainer CLI" run: npm install -g @devcontainers/cli - - name: "Generating tests for '${{ matrix.features }}' scenarios" - run: devcontainer features test -f ${{ matrix.features }} --skip-autogenerated --skip-duplicated . + - name: "Generating tests for all scenarios against ${{ matrix.images }}" + run: devcontainer features test -i ${{ matrix.images }} . test-global: runs-on: ubuntu-latest