Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
195 changes: 195 additions & 0 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
name: Integration Tests

on:
push:
branches: [ main, develop, fix/* ]
pull_request:
branches: [ main, develop ]

jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23'

- name: Run unit tests
run: |
go test -v ./...

- name: Build binary
run: |
go build -buildvcs=false -o lxc-compose ./cmd/lxc-compose/

- name: Upload binary artifact
uses: actions/upload-artifact@v3
with:
name: lxc-compose-binary
path: lxc-compose

lxc-integration:
runs-on: ubuntu-latest
needs: unit-tests
strategy:
matrix:
ubuntu-version: ['20.04', '22.04']

steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23'

- name: Install LXC and dependencies
run: |
sudo apt-get update
sudo apt-get install -y lxc lxc-utils lxc-templates bridge-utils debootstrap

# Configure LXC networking
sudo systemctl enable lxc-net
sudo systemctl start lxc-net

# Setup bridge manually if needed
if ! ip link show lxcbr0 >/dev/null 2>&1; then
sudo brctl addbr lxcbr0 || true
sudo ip addr add 10.0.3.1/24 dev lxcbr0 || true
sudo ip link set lxcbr0 up || true
fi

- name: Verify LXC environment
run: |
lxc-create --version
sudo systemctl status lxc-net || true
ip addr show lxcbr0 || echo "Bridge not available"

# Test basic LXC functionality
echo "Testing LXC basic functionality..."
sudo lxc-create -n test-basic -t download -- -d ubuntu -r focal -a amd64 || echo "Container creation test failed (expected in CI)"
sudo lxc-destroy -n test-basic || true

- name: Download binary artifact
uses: actions/download-artifact@v3
with:
name: lxc-compose-binary

- name: Make binary executable
run: chmod +x lxc-compose

- name: Test binary functionality
run: |
./lxc-compose --help
./lxc-compose version || echo "Version command not implemented"

- name: Test configuration parsing
run: |
cd integration-test/docker-lxc/test-data
../../../lxc-compose -f lxc-compose.yml config || echo "Config validation not implemented"

- name: Test container operations (basic)
run: |
cd integration-test/docker-lxc/test-data

# Test basic operations (may fail in CI due to LXC limitations)
echo "Testing container operations..."
sudo ../../../lxc-compose -f lxc-compose.yml up web || echo "Container creation failed (expected in CI)"
sudo lxc-ls -f || true
sudo ../../../lxc-compose ps || echo "PS command not implemented"
sudo ../../../lxc-compose down web || true

echo "Basic integration tests completed"

docker-build-test:
runs-on: ubuntu-latest
needs: unit-tests

steps:
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build integration test image
run: |
cd integration-test/docker-lxc
docker build -t lxc-compose-test .

- name: Test Docker environment
run: |
cd integration-test/docker-lxc
docker run --rm --privileged \
-v "$(pwd)/../../:/opt/lxc-compose-test/source:ro" \
-v "$(pwd)/test-data:/opt/lxc-compose-test/test-data:ro" \
-v "$(pwd)/basic-test.sh:/opt/lxc-compose-test/basic-test.sh:ro" \
lxc-compose-test /opt/lxc-compose-test/basic-test.sh

multiarch-build:
runs-on: ubuntu-latest
needs: unit-tests
strategy:
matrix:
goos: [linux]
goarch: [amd64, arm64]

steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23'

- name: Build for ${{ matrix.goos }}/${{ matrix.goarch }}
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
go build -buildvcs=false -o lxc-compose-${{ matrix.goos }}-${{ matrix.goarch }} ./cmd/lxc-compose/

- name: Upload multiarch binary
uses: actions/upload-artifact@v3
with:
name: lxc-compose-${{ matrix.goos }}-${{ matrix.goarch }}
path: lxc-compose-${{ matrix.goos }}-${{ matrix.goarch }}

release-test:
runs-on: ubuntu-latest
needs: [lxc-integration, docker-build-test, multiarch-build]
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/'))

steps:
- uses: actions/checkout@v4

- name: Download all artifacts
uses: actions/download-artifact@v3

- name: List artifacts
run: |
echo "Available artifacts:"
find . -name "lxc-compose*" -type f

- name: Test artifacts
run: |
chmod +x lxc-compose-binary/lxc-compose
./lxc-compose-binary/lxc-compose --help

# Test multiarch binaries
file lxc-compose-linux-amd64/lxc-compose-linux-amd64
file lxc-compose-linux-arm64/lxc-compose-linux-arm64

- name: Create release assets
if: startsWith(github.ref, 'refs/heads/release/')
run: |
mkdir -p release
cp lxc-compose-binary/lxc-compose release/lxc-compose-linux-amd64
cp lxc-compose-linux-arm64/lxc-compose-linux-arm64 release/

# Create checksums
cd release
sha256sum * > checksums.txt
ls -la
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ release_todos.md

# package
/lxc-compose
templates
templates

.specstory
39 changes: 35 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,20 @@ The tool includes an intelligent caching system for OCI images:

## Usage

Basic workflow for creating containers:
```bash
# Start containers
lxc-compose up
# 1. Pull the image
lxc-compose images pull alpine:3.19

# 2. Convert it to LXC format
lxc-compose convert alpine:3.19

# 3. Create and start containers
lxc-compose up -f your-compose.yml
```

Other common commands:
```bash
# Stop containers
lxc-compose down

Expand All @@ -200,18 +210,20 @@ This will convert the Ubuntu 20.04 Docker image to an LXC template.

### Configuration File (lxc-compose.yml)

The service key in your configuration will be used as the container name.

```yaml
version: "1.0"
services:
web:
# This container will be named "nginx-web"
nginx-web: # <- This key is used as the container name
image: ubuntu:20.04
security:
isolation: strict
apparmor_profile: lxc-container-default-restricted
capabilities:
- NET_ADMIN
- SYS_TIME
selinux_context: system_u:system_r:container_t:s0
cpu:
cores: 2
shares: 1024
Expand Down Expand Up @@ -268,6 +280,25 @@ The tool supports comprehensive security configuration for containers:
- SYS_TIME
```

## Testing

### Quick Start Testing

```bash
cd integration-test
./quick-test.sh # Interactive test menu
./setup-env.sh # Configure SSH testing (first time)
```

### Testing Methods

1. **SSH Testing** (Most Accurate) - Tests on real Proxmox/LXC hosts
2. **Multipass VM** - Clean Ubuntu VMs with native LXC
3. **Docker Testing** - Fast validation with containerized LXC
4. **Vagrant VM** - Traditional full VM testing

See [integration-test/README.md](integration-test/README.md) for detailed testing documentation.

## Development

### Prerequisites
Expand Down
Loading
Loading