Skip to content

fix: correct Bun systemd ExecStart to use openclaw binary directly #58

fix: correct Bun systemd ExecStart to use openclaw binary directly

fix: correct Bun systemd ExecStart to use openclaw binary directly #58

Workflow file for this run

name: Charm Tests
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
lint:
name: Lint Charm Code
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y shellcheck
- name: Lint shell scripts
run: |
find hooks -type f -executable -exec shellcheck {} +
- name: Check hook permissions
run: |
for hook in hooks/*; do
if [ -f "$hook" ] && [ ! -x "$hook" ]; then
echo "ERROR: Hook $hook is not executable"
exit 1
fi
done
- name: Validate metadata
run: |
if [ ! -f metadata.yaml ]; then
echo "ERROR: metadata.yaml not found"
exit 1
fi
# Check required fields
for field in name summary description; do
if ! grep -q "^${field}:" metadata.yaml; then
echo "ERROR: Required field '${field}' not found in metadata.yaml"
exit 1
fi
done
- name: Validate config
run: |
if [ ! -f config.yaml ]; then
echo "ERROR: config.yaml not found"
exit 1
fi
test-install:
name: Test Charm Installation
runs-on: ubuntu-24.04
needs: lint
strategy:
matrix:
install-method: [npm, pnpm, bun]
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up LXD
uses: canonical/setup-lxd@main
with:
channel: latest/stable
- name: Install Juju
run: |
sudo snap install juju --channel=3/stable
sudo snap install juju-wait --classic
sudo snap install charmcraft --classic
- name: Bootstrap Juju
run: |
lxc network set lxdbr0 ipv6.address none
juju bootstrap localhost test-controller
- name: Create test model
run: |
juju add-model test-openclaw
- name: Pack charm
run: |
charmcraft pack --destructive-mode
- name: Deploy charm
run: |
CHARM_FILE=$(ls openclaw_*.charm | head -1)
juju deploy ./$CHARM_FILE \
--config install-method=${{ matrix.install-method }} \
--config ai-provider="anthropic" \
--config ai-model="claude-sonnet-3-5" \
--config ai-api-key="test-key-placeholder"
- name: Wait for deployment
run: |
# Wait up to 15 minutes for installation to complete
juju-wait -v -m test-openclaw -t 900
- name: Verify installation
run: |
# Get unit IP
UNIT_IP=$(juju status openclaw --format=json | jq -r '.applications.openclaw.units | to_entries[0].value."public-address"')
echo "Unit IP: $UNIT_IP"
# Check if openclaw command exists (use login shell to load ~/.bashrc with Bun PATH)
juju ssh openclaw/0 'bash -l -c "which openclaw"'
# Check openclaw version
juju ssh openclaw/0 'bash -l -c "openclaw --version"' || echo "Version check skipped (may require config)"
# Check systemd service
juju ssh openclaw/0 'systemctl status openclaw.service' || true
# Check if port is open
juju ssh openclaw/0 'ss -tulpn | grep 18789' || echo "Port not bound (expected without valid API key)"
- name: Test configuration changes
run: |
# Change gateway port
juju config openclaw gateway-port=18790
# Wait for config change to apply
sleep 30
# Verify port change
juju ssh openclaw/0 'ss -tulpn | grep 18790' || echo "Port change test (may not bind without valid key)"
# Change back
juju config openclaw gateway-port=18789
- name: Collect logs on failure
if: failure()
run: |
echo "=== Juju Status ==="
juju status --format=yaml
echo "=== Debug Log ==="
juju debug-log --replay --no-tail --limit 500
echo "=== Unit Logs ==="
juju ssh openclaw/0 'journalctl -u openclaw.service -n 200' || true
echo "=== OpenClaw Config ==="
juju ssh openclaw/0 'cat /home/ubuntu/.openclaw/openclaw.json' || true
- name: Cleanup
if: always()
run: |
juju destroy-model test-openclaw -y --force --no-wait || true
juju destroy-controller test-controller -y --destroy-all-models --force --no-wait || true
test-channels:
name: Test Messaging Channel Configuration
runs-on: ubuntu-24.04
needs: lint
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up LXD
uses: canonical/setup-lxd@main
- name: Install Juju
run: |
sudo snap install juju --channel=3/stable
sudo snap install juju-wait --classic
sudo snap install charmcraft --classic
- name: Bootstrap Juju
run: |
lxc network set lxdbr0 ipv6.address none
juju bootstrap localhost test-controller
- name: Create test model
run: |
juju add-model test-channels
- name: Pack charm
run: |
charmcraft pack --destructive-mode
- name: Deploy with channel config
run: |
CHARM_FILE=$(ls openclaw_*.charm | head -1)
juju deploy ./$CHARM_FILE \
--config ai-provider="anthropic" \
--config ai-model="claude-sonnet-3-5" \
--config ai-api-key="test-key" \
--config telegram-bot-token="123456:TEST"
- name: Wait for deployment
run: |
juju-wait -v -m test-channels -t 900
- name: Verify channel configuration
run: |
# Check that config file contains channel configuration
juju ssh openclaw/0 'cat /home/ubuntu/.openclaw/openclaw.json' > config.json
if grep -q "telegram" config.json; then
echo "✓ Channel configuration verified"
else
echo "✗ Channel configuration missing"
exit 1
fi
- name: Cleanup
if: always()
run: |
juju destroy-model test-channels -y --force --no-wait || true
juju destroy-controller test-controller -y --destroy-all-models --force --no-wait || true
test-upgrade:
name: Test Charm Upgrade
runs-on: ubuntu-24.04
needs: lint
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up LXD
uses: canonical/setup-lxd@main
- name: Install Juju
run: |
sudo snap install juju --channel=3/stable
sudo snap install juju-wait --classic
sudo snap install charmcraft --classic
- name: Bootstrap Juju
run: |
lxc network set lxdbr0 ipv6.address none
juju bootstrap localhost test-controller
- name: Create test model
run: |
juju add-model test-upgrade
- name: Pack charm (v1)
run: |
charmcraft pack --destructive-mode
mv openclaw_*.charm openclaw-v1.charm
- name: Deploy v1
run: |
juju deploy ./openclaw-v1.charm \
--config ai-provider="anthropic" \
--config ai-model="claude-sonnet-3-5" \
--config ai-api-key="test-key"
- name: Wait for initial deployment
run: |
juju-wait -v -m test-upgrade -t 900
- name: Refresh charm (simulate upgrade)
run: |
juju refresh openclaw --path ./openclaw-v1.charm
sleep 60 # Give upgrade-charm hook time to complete
- name: Verify upgrade success
run: |
# Get unit workload status (field is "current", not "status")
status=$(juju status openclaw --format=json | jq -r '.applications.openclaw.units[]["workload-status"].current' | head -1)
echo "Current workload status: $status"
if [ "$status" = "active" ] || [ "$status" = "blocked" ]; then
echo "✓ Upgrade successful (status: $status)"
else
echo "✗ Upgrade failed - unexpected status: $status"
echo "Full juju status:"
juju status openclaw
exit 1
fi
- name: Cleanup
if: always()
run: |
juju destroy-model test-upgrade -y --force --no-wait || true
juju destroy-controller test-controller -y --destroy-all-models --force --no-wait || true