Skip to content

Commit 8e9fd3c

Browse files
authored
Internal links checker (#2854)
* ignore price feeds pages * remove feeds pages redirects * add 10s buffer delay * reduce CI server load
1 parent 4aa0e6e commit 8e9fd3c

File tree

3 files changed

+50
-80
lines changed

3 files changed

+50
-80
lines changed

src/features/redirects/redirects.json

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,16 +1015,6 @@
10151015
"destination": "any-api/introduction",
10161016
"statuscode": 301
10171017
},
1018-
{
1019-
"source": "docs/xdai-price-feeds",
1020-
"destination": "data-feeds/price-feeds/addresses/?network=gnosis-chain",
1021-
"statuscode": 301
1022-
},
1023-
{
1024-
"source": "docs/binance-smart-chain-price-feeds",
1025-
"destination": "data-feeds/price-feeds/addresses/?network=bnb-chain",
1026-
"statuscode": 301
1027-
},
10281018
{
10291019
"source": "docs/faq",
10301020
"destination": "ethereum",
@@ -1255,36 +1245,6 @@
12551245
"destination": "data-feeds/feed-registry/feed-registry-functions",
12561246
"statuscode": 301
12571247
},
1258-
{
1259-
"source": "docs/arbitrum-price-feeds",
1260-
"destination": "data-feeds/price-feeds/addresses/?network=arbitrum",
1261-
"statuscode": 301
1262-
},
1263-
{
1264-
"source": "docs/avalanche-price-feeds",
1265-
"destination": "data-feeds/price-feeds/addresses/?network=avalanche",
1266-
"statuscode": 301
1267-
},
1268-
{
1269-
"source": "docs/bnb-chain-addresses",
1270-
"destination": "data-feeds/price-feeds/addresses/?network=bnb-chain",
1271-
"statuscode": 301
1272-
},
1273-
{
1274-
"source": "docs/ethereum-addresses",
1275-
"destination": "data-feeds/price-feeds/addresses/?network=ethereum",
1276-
"statuscode": 301
1277-
},
1278-
{
1279-
"source": "docs/fantom-price-feeds",
1280-
"destination": "data-feeds/price-feeds/addresses/?network=fantom",
1281-
"statuscode": 301
1282-
},
1283-
{
1284-
"source": "docs/data-feeds-gnosis-chain",
1285-
"destination": "data-feeds/price-feeds/addresses/?network=gnosis-chain",
1286-
"statuscode": 301
1287-
},
12881248
{
12891249
"source": "docs/harmony-price-feeds",
12901250
"destination": "data-feeds/price-feeds/addresses",
@@ -1300,31 +1260,6 @@
13001260
"destination": "data-feeds/price-feeds/addresses",
13011261
"statuscode": 301
13021262
},
1303-
{
1304-
"source": "docs/data-feeds-metis",
1305-
"destination": "data-feeds/price-feeds/addresses/?network=metis",
1306-
"statuscode": 301
1307-
},
1308-
{
1309-
"source": "docs/data-feeds-moonbeam",
1310-
"destination": "data-feeds/price-feeds/addresses/?network=moonbeam",
1311-
"statuscode": 301
1312-
},
1313-
{
1314-
"source": "docs/data-feeds-moonriver",
1315-
"destination": "data-feeds/price-feeds/addresses/?network=moonriver",
1316-
"statuscode": 301
1317-
},
1318-
{
1319-
"source": "docs/optimism-price-feeds",
1320-
"destination": "data-feeds/price-feeds/addresses/?network=optimism",
1321-
"statuscode": 301
1322-
},
1323-
{
1324-
"source": "docs/matic-addresses",
1325-
"destination": "data-feeds/price-feeds/addresses/?network=polygon",
1326-
"statuscode": 301
1327-
},
13281263
{
13291264
"source": "docs/ens",
13301265
"destination": "data-feeds/ens",

src/scripts/link-check/ignoredfiles-internal.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,11 @@ _astro\/.*.css$
55
# Exclude /ccip/directory/* URLs from internal link checking
66
\/ccip\/directory\/.*
77

8+
# Exclude data-feeds price-feeds addresses pages
9+
\/data-feeds\/price-feeds\/addresses\?.*
10+
11+
# Exclude data-feeds smartdata addresses pages
12+
\/data-feeds\/smartdata\/addresses\?.*
13+
814
sitemap-index.xml
915
@vite/client

src/scripts/link-check/linkcheck.ts

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const BASE_URL = "http://localhost:4321"
1313
const TEMP_DIR = `${cwd()}/temp`
1414
const LOG_FILE = `${TEMP_DIR}/link-checker.log`
1515

16-
const LINK_CHUNK_SIZE = 300
16+
const LINK_CHUNK_SIZE = 150
1717

1818
// ================================
1919
// HELPER FUNCTIONS
@@ -42,14 +42,36 @@ function displayLogFile() {
4242

4343
/**
4444
* Wait for the dev server to be "ready" by checking for a 2xx status on BASE_URL.
45+
* Uses multiple checks to ensure server stability.
4546
*/
4647
async function waitForServerReadiness(url: string, attempts = 20) {
4748
for (let i = 1; i <= attempts; i++) {
4849
try {
4950
const response = await fetch(url)
5051
if (response.ok) {
51-
console.log(`Server is ready at ${url}`)
52-
return
52+
// Server responded, but few more checks to ensure stability
53+
console.log(`Server responded on attempt ${i}, verifying stability...`)
54+
55+
let stableChecks = 0
56+
for (let j = 0; j < 3; j++) {
57+
await new Promise((resolve) => setTimeout(resolve, 2000))
58+
try {
59+
const checkResponse = await fetch(url)
60+
if (checkResponse.ok) {
61+
stableChecks++
62+
}
63+
} catch {
64+
// Stability check failed
65+
break
66+
}
67+
}
68+
69+
if (stableChecks === 3) {
70+
console.log(`Server is ready and stable at ${url}`)
71+
return
72+
} else {
73+
console.log(`Server not yet stable, continuing checks...`)
74+
}
5375
}
5476
} catch {
5577
// Connection error or not ready yet
@@ -247,22 +269,29 @@ async function main() {
247269
const chunkFiles = await processSiteMap(mode)
248270
console.log(`Created ${chunkFiles.length} chunk files.`)
249271

250-
// 6) Run link check on each chunk in parallel, collecting any failures
251-
const checkPromises = chunkFiles.map((chunkFile, index) => {
272+
// 6) Run link check on each chunk sequentially to reduce CI resource pressure
273+
const results: { chunkNumber: number; failed: boolean }[] = []
274+
275+
for (let index = 0; index < chunkFiles.length; index++) {
276+
const chunkFile = chunkFiles[index]
252277
const chunkNumber = index + 1
253278
console.log(`\n>>> Checking chunk ${chunkNumber} of ${chunkFiles.length}: ${chunkFile}\n`)
254279

255-
return checkChunkFile(chunkFile, mode).then((code) => {
256-
if (code !== 0) {
257-
console.error(`Link checker failed on chunk ${chunkNumber} (exit code: ${code})`)
258-
// We'll store chunkNumber with the failure
259-
return { chunkNumber, failed: true }
260-
}
261-
return { chunkNumber, failed: false }
262-
})
263-
})
280+
const code = await checkChunkFile(chunkFile, mode)
281+
if (code !== 0) {
282+
console.error(`Link checker failed on chunk ${chunkNumber} (exit code: ${code})`)
283+
results.push({ chunkNumber, failed: true })
284+
} else {
285+
results.push({ chunkNumber, failed: false })
286+
}
287+
288+
// Add a small delay between chunks to reduce server pressure
289+
if (index < chunkFiles.length - 1) {
290+
console.log("Waiting 2 seconds before next chunk...")
291+
await new Promise((resolve) => setTimeout(resolve, 2000))
292+
}
293+
}
264294

265-
const results = await Promise.all(checkPromises)
266295
const failedChunks = results.filter((r) => r.failed).map((r) => r.chunkNumber)
267296

268297
// 7) If any chunks failed, exit with error after we've checked them all

0 commit comments

Comments
 (0)