This repository has been archived on 2026-06-16. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
headlamp-polaris-plugin/.github/workflows/e2e.yaml
T
Gandalf the Greybeard 57f3a59ae1 ci: add kubectl setup and kubeconfig configuration to E2E workflow
The deploy-plugin-to-headlamp.sh script requires kubectl to copy built
plugin files into the Headlamp pod. Install kubectl via azure/setup-kubectl
and configure kubeconfig from either a KUBECONFIG secret (base64-encoded)
or the in-cluster service account token.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-03-16 01:10:56 +00:00

127 lines
5.1 KiB
YAML

name: E2E Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
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: Preflight — verify Headlamp and plugin version
env:
HEADLAMP_URL: ${{ secrets.HEADLAMP_URL || 'http://headlamp.kube-system.svc.cluster.local' }}
run: |
EXPECTED=$(node -p "require('./package.json').version")
PLUGIN_NAME=$(node -p "require('./package.json').artifacthub?.name || require('./package.json').name")
echo "Expected: $PLUGIN_NAME@$EXPECTED"
# Check Headlamp connectivity
HTTP_CODE=$(curl -s -o /dev/null -w '%{http_code}' --connect-timeout 10 "$HEADLAMP_URL" || true)
if [ "$HTTP_CODE" = "000" ]; then
echo "::error::Cannot reach Headlamp at $HEADLAMP_URL"
exit 1
fi
echo "Headlamp responded HTTP $HTTP_CODE"
# Check installed plugins and version match
PLUGIN_JSON=$(curl -sf --connect-timeout 10 "$HEADLAMP_URL/plugins" 2>/dev/null || echo "[]")
node -e "
const expected = '$EXPECTED';
const pluginName = '$PLUGIN_NAME';
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 === pluginName || p.name === 'polaris' || p.name.includes('polaris'));
if (!ours) {
console.log('::warning::Plugin ' + pluginName + ' not found in Headlamp — data-dependent tests will fail');
} else {
console.log('Found plugin: ' + ours.name + ' at path ' + ours.path);
}
" "$PLUGIN_JSON"
# Fetch deployed plugin version from package.json
DEPLOYED_VERSION=$(curl -sf --connect-timeout 10 "$HEADLAMP_URL/plugins/$PLUGIN_NAME/package.json" 2>/dev/null \
| node -p "JSON.parse(require('fs').readFileSync(0,'utf8')).version" 2>/dev/null || echo "unknown")
echo "Deployed version: $DEPLOYED_VERSION"
if [ "$DEPLOYED_VERSION" != "$EXPECTED" ] && [ "$DEPLOYED_VERSION" != "unknown" ]; then
echo "::warning::Version mismatch — repo has $EXPECTED but Headlamp runs $DEPLOYED_VERSION. Tests may fail due to stale plugin."
fi
- name: Build plugin
run: npm run build
- name: Setup kubectl
uses: azure/setup-kubectl@v4
- name: Configure kubeconfig
env:
KUBECONFIG_DATA: ${{ secrets.KUBECONFIG }}
run: |
if [ -n "$KUBECONFIG_DATA" ]; then
mkdir -p ~/.kube
echo "$KUBECONFIG_DATA" | base64 -d > ~/.kube/config
chmod 600 ~/.kube/config
elif [ -f /var/run/secrets/kubernetes.io/serviceaccount/token ]; then
SA_TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
CA_CERT=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt
NAMESPACE=$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace)
kubectl config set-cluster in-cluster --server=https://kubernetes.default.svc --certificate-authority="$CA_CERT"
kubectl config set-credentials sa-user --token="$SA_TOKEN"
kubectl config set-context in-cluster --cluster=in-cluster --user=sa-user --namespace="$NAMESPACE"
kubectl config use-context in-cluster
fi
kubectl version --client
kubectl cluster-info || echo "::warning::Cannot reach cluster API — deploy step may fail"
- name: Deploy plugin to Headlamp
env:
HEADLAMP_URL: ${{ secrets.HEADLAMP_URL || 'http://headlamp.kube-system.svc.cluster.local' }}
HEADLAMP_NS: ${{ secrets.HEADLAMP_NS || 'kube-system' }}
HEADLAMP_PLUGIN_DIR: ${{ secrets.HEADLAMP_PLUGIN_DIR || '/headlamp/static-plugins/polaris' }}
run: ./scripts/deploy-plugin-to-headlamp.sh
- 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