chore: unify pipeline with klz-2026 standards and harden registry auth
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 41s
Build & Deploy / 🧪 QA (push) Failing after 1m2s
Build & Deploy / 🏗️ Build (push) Has been skipped
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 1s
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 41s
Build & Deploy / 🧪 QA (push) Failing after 1m2s
Build & Deploy / 🏗️ Build (push) Has been skipped
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 1s
This commit is contained in:
74
scripts/smoke.ts
Normal file
74
scripts/smoke.ts
Normal file
@@ -0,0 +1,74 @@
|
||||
import puppeteer from 'puppeteer';
|
||||
|
||||
const targetUrl = process.argv[2] || process.env.NEXT_PUBLIC_BASE_URL || 'http://localhost:3000';
|
||||
const gatekeeperPassword = process.env.GATEKEEPER_PASSWORD || 'etib2026';
|
||||
|
||||
async function run() {
|
||||
console.log(`🚀 Smoke Test: ${targetUrl}`);
|
||||
|
||||
const browser = await puppeteer.launch({
|
||||
headless: true,
|
||||
executablePath: process.env.PUPPETEER_EXECUTABLE_PATH || undefined,
|
||||
args: ['--no-sandbox', '--disable-setuid-sandbox'],
|
||||
});
|
||||
const page = await browser.newPage();
|
||||
|
||||
try {
|
||||
// 1. Login via Gatekeeper
|
||||
console.log('🔑 Authenticating...');
|
||||
await page.goto(targetUrl, { waitUntil: 'networkidle2' });
|
||||
|
||||
const isGatekeeper = await page.$('input[name="password"]');
|
||||
if (isGatekeeper) {
|
||||
await page.type('input[name="password"]', gatekeeperPassword);
|
||||
await Promise.all([
|
||||
page.waitForNavigation({ waitUntil: 'networkidle2' }),
|
||||
page.click('button[type="submit"]'),
|
||||
]);
|
||||
}
|
||||
|
||||
// 2. Check Key Pages
|
||||
const pages = ['/', '/de/kontakt', '/en/contact', '/de/blog'];
|
||||
for (const p of pages) {
|
||||
console.log(`📄 Checking ${p}...`);
|
||||
const res = await page.goto(`${targetUrl}${p}`, { waitUntil: 'domcontentloaded' });
|
||||
if (res?.status() !== 200) throw new Error(`Page ${p} returned ${res?.status()}`);
|
||||
|
||||
// Check for broken images
|
||||
const images = await page.$$eval('img', (imgs) => imgs.map((img) => img.src).filter(Boolean));
|
||||
console.log(` Checking ${images.length} images...`);
|
||||
|
||||
const brokenImages = await page.evaluate(async (urls) => {
|
||||
const broken: string[] = [];
|
||||
await Promise.all(
|
||||
urls.map(async (url) => {
|
||||
if (url.includes('openstreetmap.org') || url.includes('unpkg.com')) return;
|
||||
try {
|
||||
const res = await fetch(url, { method: 'HEAD' });
|
||||
if (res.status >= 400) {
|
||||
broken.push(`${url} (Status: ${res.status})`);
|
||||
}
|
||||
} catch (e) {
|
||||
broken.push(`${url} (Fetch failed)`);
|
||||
}
|
||||
}),
|
||||
);
|
||||
return broken;
|
||||
}, images);
|
||||
|
||||
if (brokenImages.length > 0) {
|
||||
console.warn(`⚠️ Found ${brokenImages.length} broken images on ${p}`);
|
||||
}
|
||||
}
|
||||
|
||||
console.log('✅ Smoke test passed!');
|
||||
process.exit(0);
|
||||
} catch (err: any) {
|
||||
console.error(`❌ Smoke test failed: ${err.message}`);
|
||||
process.exit(1);
|
||||
} finally {
|
||||
await browser.close();
|
||||
}
|
||||
}
|
||||
|
||||
run();
|
||||
Reference in New Issue
Block a user