ci: improve E2E preflight with version mismatch detection (#32)

Enhances the preflight step to:
- Check the deployed plugin version against the repo version
- Emit a clear warning annotation when there's a mismatch
- Report the plugin name from artifacthub metadata
- Still runs tests (warning, not error) so we catch other issues

This makes plugin version mismatches immediately visible in the
CI summary instead of requiring investigators to dig through
14 timeout failures.

Co-authored-by: hugh-hackman[bot] <hugh-hackman[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit was merged in pull request #32.
This commit is contained in:
hugh-hackman[bot]
2026-03-09 13:16:16 -04:00
committed by GitHub
parent 9ad0b24580
commit 7603dfeb29
+29 -19
View File
@@ -25,35 +25,45 @@ jobs:
- name: Install dependencies - name: Install dependencies
run: npm ci run: npm ci
- name: Preflight — verify Headlamp connectivity - name: Preflight — verify Headlamp and plugin version
env: env:
HEADLAMP_URL: ${{ secrets.HEADLAMP_URL || 'http://headlamp.kube-system.svc.cluster.local' }} HEADLAMP_URL: ${{ secrets.HEADLAMP_URL || 'http://headlamp.kube-system.svc.cluster.local' }}
run: | run: |
echo "::group::Expected plugin version"
EXPECTED=$(node -p "require('./package.json').version") EXPECTED=$(node -p "require('./package.json').version")
echo "Plugin version in repo: $EXPECTED" PLUGIN_NAME=$(node -p "require('./package.json').artifacthub?.name || require('./package.json').name")
echo "::endgroup::" echo "Expected: $PLUGIN_NAME@$EXPECTED"
echo "::group::Headlamp connectivity" # Check Headlamp connectivity
HTTP_CODE=$(curl -s -o /dev/null -w '%{http_code}' --connect-timeout 10 "$HEADLAMP_URL" || true) HTTP_CODE=$(curl -s -o /dev/null -w '%{http_code}' --connect-timeout 10 "$HEADLAMP_URL" || true)
if [ "$HTTP_CODE" = "000" ]; then if [ "$HTTP_CODE" = "000" ]; then
echo "::error::Cannot reach Headlamp at $HEADLAMP_URL — E2E tests will fail" echo "::error::Cannot reach Headlamp at $HEADLAMP_URL"
exit 1 exit 1
fi fi
echo "Headlamp responded with HTTP $HTTP_CODE at $HEADLAMP_URL" echo "Headlamp responded HTTP $HTTP_CODE"
echo "::endgroup::"
echo "::group::Installed plugins" # Check installed plugins and version match
# Headlamp serves plugin metadata at /plugins — no auth required PLUGIN_JSON=$(curl -sf --connect-timeout 10 "$HEADLAMP_URL/plugins" 2>/dev/null || echo "[]")
curl -sf --connect-timeout 10 "$HEADLAMP_URL/plugins" 2>/dev/null \ node -e "
| node -e " const expected = '$EXPECTED';
const d = require('fs').readFileSync(0,'utf8'); const pluginName = '$PLUGIN_NAME';
try { const plugins = JSON.parse(process.argv[1]);
const plugins = JSON.parse(d); console.log('Installed plugins:');
for (const p of plugins) console.log(' ' + p.name + '@' + (p.version||'unknown')); for (const p of plugins) console.log(' ' + p.name + '@' + (p.version||'unknown'));
} catch { console.log(' (could not parse plugin list)'); } const ours = plugins.find(p => p.name === pluginName || p.name === 'polaris' || p.name.includes('polaris'));
" || echo " (plugin list endpoint not available — tests will validate at runtime)" if (!ours) {
echo "::endgroup::" 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: Install Playwright browsers - name: Install Playwright browsers
run: npx playwright install --with-deps chromium run: npx playwright install --with-deps chromium