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 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 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 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 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}...." 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