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
2 changes: 1 addition & 1 deletion .github/workflows/publish-devcontainer-features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
uses: devcontainers/action@v1.4.0
with:
publish-features: "true"
base-path-to-features: "./devcontainer/features"
base-path-to-features: "./devcontainer/features/src"
generate-docs: "false"

env:
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/test-devcontainer-features.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: "Test devcontainer features"
on:
push:
branches:
- main
paths:
- .github/workflows/test-devcontainer-feature.yml
- devcontainer/features/**
- devcontainer/features-tests/**
pull_request:
branches:
- main
paths:
- .github/workflows/test-devcontainer-feature.yml
- devcontainer/features/**
- devcontainer/features-tests/**

jobs:
test-autogenerated:
runs-on: ubuntu-latest
continue-on-error: true
strategy:
matrix:
features:
- ansible
steps:
- uses: actions/checkout@v3

- name: "Install latest devcontainer CLI"
run: npm install -g @devcontainers/cli

- name: "Generating tests for '${{ matrix.features }}' scenarios"
run: devcontainer features test --project-folder ./devcontainer/features -f ${{ matrix.features }} --skip-autogenerated --skip-duplicated .
2 changes: 1 addition & 1 deletion .github/workflows/validate-devcontainer-features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ jobs:
uses: devcontainers/action@v1.4.0
with:
validate-only: "true"
base-path-to-features: "./devcontainer/features"
base-path-to-features: "./devcontainer/features/src"
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@ if [ -f requirements.txt ]; then
if ! command -v pip; then
sudo apt update
sudo apt install -y --no-install-recommends python3-pip
else
echo "Pip already installed"
fi
pip install -r requirements.txt
else
echo "No requirements.txt found"
fi

# Now that pip is setup, install Ansible Galaxy modules
if [ -f requirements.yml ]; then
ansible-galaxy install -r requirements.yml
else
echo "No requirements.yml found"
fi

# sshpass for initial node provisioning
Expand All @@ -21,5 +27,10 @@ if ! command -v sshpass; then
sudo apt install -y --no-install-recommends sshpass
fi

# Actually run the playbook
PLAYBOOK=${PLAYBOOK:-undefined}
ansible-playbook "$PLAYBOOK"
if [ -f "$PLAYBOOK" ]; then
ansible-playbook "$PLAYBOOK"
else
echo "Could not find playbook - cowardly doing nothing"
fi
3 changes: 3 additions & 0 deletions devcontainer/features/src/ansible/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# pip requirements
ansible==8.5.0
kubernetes==28.1.0
18 changes: 18 additions & 0 deletions devcontainer/features/test/ansible/basic.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/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.
# shellcheck disable=SC1091
source dev-container-features-test-lib

# Feature-specific tests
# The 'check' command comes from the dev-container-features-test-lib. Syntax is...
# check <LABEL> <cmd> [args...]
check "installed pip" bash -c "command -v pip"
check "installed ansible-playbook" bash -c "command -v ansible-playbook"

# Report results
# If any of the checks above exited with a non-zero exit code, the test will fail.
reportResults
9 changes: 9 additions & 0 deletions devcontainer/features/test/ansible/scenarios.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"basic": {
"image": "buildpack-deps:22.04-curl",
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {},
"ansible": {}
}
}
}