06386e445b
Simplify deploy step to call scripts/deploy-plugin-via-volume.sh directly instead of duplicating copy logic. Align env var names (PLUGIN_VOLUME_PATH, HEADLAMP_DEPLOY) with the deploy script's expected interface from PR #59. Co-Authored-By: Paperclip <noreply@paperclip.ing>
103 lines
3.2 KiB
YAML
103 lines
3.2 KiB
YAML
name: E2E Tests
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
workflow_dispatch:
|
|
|
|
env:
|
|
PLUGIN_VOLUME_PATH: /mnt/headlamp-plugins
|
|
HEADLAMP_NAMESPACE: kube-system
|
|
HEADLAMP_DEPLOY: headlamp
|
|
|
|
jobs:
|
|
e2e:
|
|
runs-on: local-ubuntu-latest
|
|
timeout-minutes: 15
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '22'
|
|
cache: 'npm'
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Build plugin
|
|
run: npm run build
|
|
|
|
- name: Deploy plugin via shared volume
|
|
run: scripts/deploy-plugin-via-volume.sh
|
|
|
|
- name: Preflight — verify Headlamp and plugin availability
|
|
env:
|
|
HEADLAMP_URL: ${{ secrets.HEADLAMP_URL || 'http://headlamp.kube-system.svc.cluster.local' }}
|
|
run: |
|
|
PLUGIN_NAME=$(node -p "require('./package.json').name")
|
|
EXPECTED=$(node -p "require('./package.json').version")
|
|
echo "Expecting: $PLUGIN_NAME@$EXPECTED"
|
|
|
|
# Wait for Headlamp to be reachable
|
|
for i in $(seq 1 30); do
|
|
HTTP_CODE=$(curl -s -o /dev/null -w '%{http_code}' --connect-timeout 5 "$HEADLAMP_URL" || true)
|
|
if [ "$HTTP_CODE" != "000" ]; then
|
|
echo "Headlamp responded HTTP $HTTP_CODE"
|
|
break
|
|
fi
|
|
echo "Waiting for Headlamp... ($i/30)"
|
|
sleep 2
|
|
done
|
|
|
|
if [ "$HTTP_CODE" = "000" ]; then
|
|
echo "::error::Cannot reach Headlamp at $HEADLAMP_URL after 60s"
|
|
exit 1
|
|
fi
|
|
|
|
# Verify plugin is visible
|
|
PLUGIN_JSON=$(curl -sf --connect-timeout 10 "$HEADLAMP_URL/plugins" 2>/dev/null || echo "[]")
|
|
node -e "
|
|
const plugins = JSON.parse(process.argv[1]);
|
|
console.log('Installed plugins:');
|
|
for (const p of plugins) console.log(' ' + p.name + '@' + (p.version||'unknown'));
|
|
const ours = plugins.find(p => p.name === '$PLUGIN_NAME' || p.name === 'polaris' || p.name.includes('polaris'));
|
|
if (!ours) {
|
|
console.log('::warning::Plugin $PLUGIN_NAME not yet visible — Headlamp may need a restart');
|
|
} else {
|
|
console.log('Found plugin: ' + ours.name + ' at path ' + ours.path);
|
|
}
|
|
" "$PLUGIN_JSON"
|
|
|
|
- name: Install Playwright browsers
|
|
run: npx playwright install --with-deps chromium
|
|
|
|
- name: Run E2E tests
|
|
run: npm run e2e
|
|
env:
|
|
HEADLAMP_URL: ${{ secrets.HEADLAMP_URL || 'http://headlamp.kube-system.svc.cluster.local' }}
|
|
HEADLAMP_TOKEN: ${{ secrets.HEADLAMP_TOKEN }}
|
|
AUTHENTIK_USERNAME: ${{ secrets.AUTHENTIK_USERNAME }}
|
|
AUTHENTIK_PASSWORD: ${{ secrets.AUTHENTIK_PASSWORD }}
|
|
|
|
- name: Upload Playwright report
|
|
uses: actions/upload-artifact@v4
|
|
if: failure()
|
|
with:
|
|
name: playwright-report
|
|
path: playwright-report/
|
|
retention-days: 7
|
|
|
|
- name: Upload test results
|
|
uses: actions/upload-artifact@v4
|
|
if: failure()
|
|
with:
|
|
name: test-results
|
|
path: test-results/
|
|
retention-days: 7
|