Files
dokku-docker-compose/.github/workflows/test.yml

103 lines
3.2 KiB
YAML

name: Test
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
services:
dokku:
image: dokku/dokku:latest
ports:
- "2222:22"
- "8080:80"
- "8443:443"
env:
DOKKU_HOST: localhost
DOKKU_SKIP_APP_WEB_CONFIG: 1
volumes:
- /var/run/docker.sock:/var/run/docker.sock
options: >-
--health-cmd "nc -z localhost 22"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y bats ssh netcat-openbsd
- name: Set up SSH
run: |
# Create .ssh directory
mkdir -p ~/.ssh
chmod 700 ~/.ssh
# Generate SSH key without passphrase
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -N "" -C "github-actions@dokku-test"
# Add to SSH agent
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
# Create SSH config
cat > ~/.ssh/config << 'EOL'
Host dokku-test
HostName localhost
Port 2222
User dokku
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
IdentityFile ~/.ssh/id_ed25519
IdentitiesOnly yes
EOL
# Set permissions
chmod 600 ~/.ssh/config
chmod 600 ~/.ssh/id_ed25519*
# Add public key to Dokku container
echo "Waiting for Dokku SSH to be ready..."
until nc -z localhost 2222; do sleep 1; done
sleep 5 # Give it a moment to fully start
# Install the public key in the Dokku container
cat ~/.ssh/id_ed25519.pub | ssh-keyscan -p 2222 -t ed25519 localhost > /dev/null 2>&1 || true
# Wait for Dokku to be ready
echo "Waiting for Dokku to be ready..."
until docker exec dokku ps | grep -q sshd; do sleep 1; done
sleep 5
# Add the key to the dokku user
cat ~/.ssh/id_ed25519.pub | ssh -p 2222 -o StrictHostKeyChecking=no dokku@localhost "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys" || true
# Test SSH connection
echo "Testing SSH connection..."
ssh -T dokku-test "echo 'SSH connection successful!'" || echo "SSH test failed, but continuing..."
- name: Install Dokku plugins
run: |
ssh -T dokku-test "\
dokku plugin:install https://github.com/dokku/dokku-postgres.git postgres && \
dokku plugin:install https://github.com/dokku/dokku-redis.git redis && \
dokku plugin:install https://github.com/dokku/dokku-mysql.git mysql"
- name: Run unit tests
run: bats tests/parser.bats
- name: Run integration tests
run: bats tests/integration.bats
- name: Run deployment tests
run: |
# Install Node.js for deployment tests
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt-get install -y nodejs
# Run deployment tests
bats tests/deploy.bats