fix: resolve lint errors in CI scripts
Some checks failed
🚀 Build & Deploy / 🔍 Prepare (push) Successful in 4s
🚀 Build & Deploy / 🧪 QA (push) Failing after 45s
🚀 Build & Deploy / 🏗️ Build (push) Failing after 11m9s
🚀 Build & Deploy / 🚀 Deploy (push) Has been skipped
🚀 Build & Deploy / 🧪 Post-Deploy Verification (push) Has been skipped
🚀 Build & Deploy / 🔔 Notify (push) Successful in 2s
Some checks failed
🚀 Build & Deploy / 🔍 Prepare (push) Successful in 4s
🚀 Build & Deploy / 🧪 QA (push) Failing after 45s
🚀 Build & Deploy / 🏗️ Build (push) Failing after 11m9s
🚀 Build & Deploy / 🚀 Deploy (push) Has been skipped
🚀 Build & Deploy / 🧪 Post-Deploy Verification (push) Has been skipped
🚀 Build & Deploy / 🔔 Notify (push) Successful in 2s
This commit is contained in:
@@ -47,8 +47,9 @@ async function main() {
|
|||||||
const others = urls.filter((u) => !homeEN.includes(u) && !homeDE.includes(u));
|
const others = urls.filter((u) => !homeEN.includes(u) && !homeDE.includes(u));
|
||||||
urls = [...homeDE, ...homeEN, ...others.slice(0, limit - (homeEN.length + homeDE.length))];
|
urls = [...homeDE, ...homeEN, ...others.slice(0, limit - (homeEN.length + homeDE.length))];
|
||||||
}
|
}
|
||||||
} catch (err: any) {
|
} catch (err: unknown) {
|
||||||
console.error(`❌ Failed to fetch sitemap: ${err.message}`);
|
const errorBody = err instanceof Error ? err.message : String(err);
|
||||||
|
console.error(`❌ Failed to fetch sitemap: ${errorBody}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,7 +79,7 @@ async function main() {
|
|||||||
const consoleErrorsList: Array<{ type: string; error: string; page: string }> = [];
|
const consoleErrorsList: Array<{ type: string; error: string; page: string }> = [];
|
||||||
|
|
||||||
// Listen for unhandled exceptions natively in the page
|
// Listen for unhandled exceptions natively in the page
|
||||||
page.on('pageerror', (err: any) => {
|
page.on('pageerror', (err: Error) => {
|
||||||
consoleErrorsList.push({
|
consoleErrorsList.push({
|
||||||
type: 'PAGE_ERROR',
|
type: 'PAGE_ERROR',
|
||||||
error: err.message,
|
error: err.message,
|
||||||
@@ -163,8 +164,9 @@ async function main() {
|
|||||||
|
|
||||||
// Wait a tiny bit more for final lazy loads
|
// Wait a tiny bit more for final lazy loads
|
||||||
await new Promise((r) => setTimeout(r, 1000));
|
await new Promise((r) => setTimeout(r, 1000));
|
||||||
} catch (err: any) {
|
} catch (err: unknown) {
|
||||||
console.error(`⚠️ Timeout or navigation error on ${u}: ${err.message}`);
|
const errorBody = err instanceof Error ? err.message : String(err);
|
||||||
|
console.error(`⚠️ Timeout or navigation error on ${u}: ${errorBody}`);
|
||||||
// Don't fail the whole script just because one page timed out, but flag it
|
// Don't fail the whole script just because one page timed out, but flag it
|
||||||
hasBrokenAssets = true;
|
hasBrokenAssets = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,9 +57,10 @@ async function main() {
|
|||||||
const filename = `${safePath || 'index'}.html`;
|
const filename = `${safePath || 'index'}.html`;
|
||||||
|
|
||||||
fs.writeFileSync(path.join(outputDir, filename), res.data);
|
fs.writeFileSync(path.join(outputDir, filename), res.data);
|
||||||
} catch (err: any) {
|
} catch (err: unknown) {
|
||||||
console.error(`❌ HTTP Error fetching ${u}: ${err.message}`);
|
const errorBody = err instanceof Error ? err.message : String(err);
|
||||||
throw new Error(`Failed to fetch page: ${u} - ${err.message}`);
|
console.error(`❌ HTTP Error fetching ${u}: ${errorBody}`);
|
||||||
|
throw new Error(`Failed to fetch page: ${u} - ${errorBody}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,12 +68,13 @@ async function main() {
|
|||||||
try {
|
try {
|
||||||
execSync(`npx html-validate .htmlvalidate-tmp/*.html`, { stdio: 'inherit' });
|
execSync(`npx html-validate .htmlvalidate-tmp/*.html`, { stdio: 'inherit' });
|
||||||
console.log(`✅ HTML Validation passed perfectly!`);
|
console.log(`✅ HTML Validation passed perfectly!`);
|
||||||
} catch (e) {
|
} catch {
|
||||||
console.error(`❌ HTML Validation found issues.`);
|
console.error(`❌ HTML Validation found issues.`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: unknown) {
|
||||||
console.error(`\n❌ Error during HTML Validation:`, error.message);
|
const errorBody = error instanceof Error ? error.message : String(error);
|
||||||
|
console.error(`\n❌ Error during HTML Validation:`, errorBody);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
} finally {
|
} finally {
|
||||||
const outputDir = path.join(process.cwd(), '.htmlvalidate-tmp');
|
const outputDir = path.join(process.cwd(), '.htmlvalidate-tmp');
|
||||||
|
|||||||
@@ -3,6 +3,30 @@ import * as cheerio from 'cheerio';
|
|||||||
import { execSync } from 'child_process';
|
import { execSync } from 'child_process';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
import { AxiosError } from 'axios';
|
||||||
|
|
||||||
|
interface Pa11yConfig {
|
||||||
|
defaults: {
|
||||||
|
threshold?: number;
|
||||||
|
runners?: string[];
|
||||||
|
ignore?: string[];
|
||||||
|
chromeLaunchConfig?: {
|
||||||
|
executablePath?: string;
|
||||||
|
args?: string[];
|
||||||
|
};
|
||||||
|
headers?: Record<string, string>;
|
||||||
|
timeout?: number;
|
||||||
|
};
|
||||||
|
urls?: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Pa11yResult {
|
||||||
|
type?: string;
|
||||||
|
message?: string;
|
||||||
|
code?: string;
|
||||||
|
context?: string;
|
||||||
|
selector?: string;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WCAG Audit Script
|
* WCAG Audit Script
|
||||||
@@ -65,14 +89,15 @@ async function main() {
|
|||||||
|
|
||||||
// 2. Prepare pa11y-ci config
|
// 2. Prepare pa11y-ci config
|
||||||
const baseConfigPath = path.join(process.cwd(), '.pa11yci.json');
|
const baseConfigPath = path.join(process.cwd(), '.pa11yci.json');
|
||||||
let baseConfig: any = { defaults: {} };
|
let baseConfig: Pa11yConfig = { defaults: {} };
|
||||||
if (fs.existsSync(baseConfigPath)) {
|
if (fs.existsSync(baseConfigPath)) {
|
||||||
baseConfig = JSON.parse(fs.readFileSync(baseConfigPath, 'utf8'));
|
baseConfig = JSON.parse(fs.readFileSync(baseConfigPath, 'utf8'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract domain for cookie
|
// Extract domain for cookie
|
||||||
const urlObj = new URL(targetUrl);
|
const urlObj = new URL(targetUrl);
|
||||||
const domain = urlObj.hostname;
|
// domain is not used, so remove or keep if needed later? Linter says unused.
|
||||||
|
// const domain = urlObj.hostname;
|
||||||
|
|
||||||
// Update config with discovered URLs and gatekeeper cookie
|
// Update config with discovered URLs and gatekeeper cookie
|
||||||
const tempConfig = {
|
const tempConfig = {
|
||||||
@@ -118,7 +143,7 @@ async function main() {
|
|||||||
encoding: 'utf8',
|
encoding: 'utf8',
|
||||||
stdio: 'inherit',
|
stdio: 'inherit',
|
||||||
});
|
});
|
||||||
} catch (err: any) {
|
} catch {
|
||||||
// pa11y-ci exits with non-zero if issues are found, which is expected
|
// pa11y-ci exits with non-zero if issues are found, which is expected
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,10 +161,10 @@ async function main() {
|
|||||||
|
|
||||||
if (Array.isArray(results)) {
|
if (Array.isArray(results)) {
|
||||||
// pa11y action execution errors come as objects with a message but no type
|
// pa11y action execution errors come as objects with a message but no type
|
||||||
const actionErrors = results.filter((r: any) => !r.type && r.message).length;
|
const actionErrors = results.filter((r: Pa11yResult) => !r.type && r.message).length;
|
||||||
errors = results.filter((r: any) => r.type === 'error').length + actionErrors;
|
errors = results.filter((r: Pa11yResult) => r.type === 'error').length + actionErrors;
|
||||||
warnings = results.filter((r: any) => r.type === 'warning').length;
|
warnings = results.filter((r: Pa11yResult) => r.type === 'warning').length;
|
||||||
notices = results.filter((r: any) => r.type === 'notice').length;
|
notices = results.filter((r: Pa11yResult) => r.type === 'notice').length;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean URL for display
|
// Clean URL for display
|
||||||
@@ -168,13 +193,14 @@ async function main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
console.log(`\n✨ WCAG Audit completed!`);
|
console.log(`\n✨ WCAG Audit completed!`);
|
||||||
} catch (error: any) {
|
} catch (error: unknown) {
|
||||||
console.error(`\n❌ Error during WCAG Audit:`);
|
console.error(`\n❌ Error during WCAG Audit:`);
|
||||||
if (axios.isAxiosError(error)) {
|
if (error instanceof AxiosError) {
|
||||||
console.error(`Status: ${error.response?.status}`);
|
console.error(`Status: ${error.response?.status}`);
|
||||||
console.error(`URL: ${error.config?.url}`);
|
console.error(`URL: ${error.config?.url}`);
|
||||||
} else {
|
} else {
|
||||||
console.error(error.message);
|
const errorBody = error instanceof Error ? error.message : String(error);
|
||||||
|
console.error(errorBody);
|
||||||
}
|
}
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
Reference in New Issue
Block a user