-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: validate chains and warp routes, change jobs to run on main (#457
) ### Description <!-- Summary of change. Example: Add sepolia chain --> Fixes #439 and #209 - Change `combine` and `optimize-svg` jobs to only run when commited to `main` - Add script to validate chains and warp routes - Add `step` in `ci.ym`l test job to run these - For chains it will check for missing `deployer` field and if its missing logo file - For warp routes it will check for missing config file and if chain names are ordered correctly - Updated `chain` test to check if `isTestnet` is set properly - Update `warp-routes` test to check for `logoURI` field ### Backward compatibility <!-- Are these changes backward compatible? Note that additions are backwards compatible. Yes/No --> Yes ### Testing Manual
- Loading branch information
Showing
23 changed files
with
234 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@hyperlane-xyz/registry': patch | ||
--- | ||
|
||
Warp Routes: add logoURI for tokens that did not have it and rename chain names that were not sorted alphabetically | ||
Chains: Add missing deployer field |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import { readYaml } from './utils.js'; | ||
|
||
const chainsDir = './chains'; | ||
const warpRoutesDir = './deployments/warp_routes'; | ||
|
||
// chains errors | ||
const missingDeployerField = []; | ||
const noLogoFileError = []; | ||
|
||
// warp routes errors | ||
const noConfigFileError = []; | ||
const unorderedChainNamesError = []; | ||
|
||
function validateChains() { | ||
if (!fs.existsSync(chainsDir)) { | ||
console.error(`Directory does not exist: ${chainsDir}`); | ||
return; | ||
} | ||
|
||
const entries = fs.readdirSync(chainsDir, { withFileTypes: true }); | ||
|
||
entries.forEach((entry) => { | ||
if (!entry.isDirectory()) return; | ||
|
||
const entryPath = path.join(chainsDir, entry.name); | ||
const addressesPath = path.join(entryPath, 'addresses.yaml'); | ||
const metadataPath = path.join(entryPath, 'metadata.yaml'); | ||
|
||
// check if logo file exists | ||
const logoFile = fs.readdirSync(entryPath).find((file) => file.includes('logo.svg')); | ||
if (!logoFile) noLogoFileError.push(entryPath); | ||
|
||
if (!fs.existsSync(metadataPath)) return; | ||
|
||
// if addresses.yaml exists, check if deployer field is missing in metadata.yaml | ||
const metadata = readYaml(metadataPath); | ||
if (fs.existsSync(addressesPath)) { | ||
if (!Object.keys(metadata).includes('deployer')) missingDeployerField.push(metadataPath); | ||
} | ||
}); | ||
} | ||
|
||
// This regex will make sure that we can split the filename when it contains the words | ||
// addresses or config that way we can grab all the chain names and exclude these words | ||
const filenameRegex = /^([\w-]+)-(addresses|config)\.yaml$/; | ||
|
||
// check if chain names in warp routes are ordered alphabetically | ||
function validateChainNameOrder(entryPath) { | ||
const yamlFiles = fs.readdirSync(entryPath).filter((file) => file.includes('.yaml')); | ||
|
||
yamlFiles.forEach((filename) => { | ||
const match = filename.match(filenameRegex); | ||
const filePath = path.join(entryPath, filename); | ||
|
||
if (!match) return; | ||
|
||
const chains = match[1]; | ||
const sortedChains = [...chains.split('-')].sort().join('-'); | ||
|
||
if (chains !== sortedChains) unorderedChainNamesError.push(filePath); | ||
}); | ||
} | ||
|
||
function validateConfigFiles(entryPath) { | ||
//Search for config files | ||
const configFiles = fs.readdirSync(entryPath).filter((file) => file.includes('-config.yaml')); | ||
|
||
if (configFiles.length === 0) { | ||
noConfigFileError.push(entryPath); | ||
return; | ||
} | ||
} | ||
|
||
function validateWarpRoutes() { | ||
if (!fs.existsSync(warpRoutesDir)) { | ||
console.error(`Directory does not exist: ${warpRoutesDir}`); | ||
return; | ||
} | ||
|
||
const entries = fs.readdirSync(warpRoutesDir, { withFileTypes: true }); | ||
|
||
entries.forEach((entry) => { | ||
if (!entry.isDirectory()) return; | ||
|
||
const entryPath = path.join(warpRoutesDir, entry.name); | ||
|
||
validateConfigFiles(entryPath); | ||
validateChainNameOrder(entryPath); | ||
}); | ||
} | ||
|
||
function validateErrors() { | ||
const errorCount = | ||
missingDeployerField.length + | ||
noConfigFileError.length + | ||
noLogoFileError.length + | ||
unorderedChainNamesError.length; | ||
|
||
if (errorCount === 0) return; | ||
|
||
console.error(`Number of errors found: ${errorCount}`); | ||
|
||
if (missingDeployerField.length > 0) | ||
console.error( | ||
'Error: Chain contains addresses.yaml but missing deployer field in metadata.yaml for the following paths:', | ||
missingDeployerField, | ||
); | ||
|
||
if (noLogoFileError.length > 0) console.error('Error: logo file missing at:', noLogoFileError); | ||
|
||
if (noConfigFileError.length > 0) | ||
console.error('Error: no config file at paths:', noConfigFileError); | ||
|
||
if (unorderedChainNamesError.length > 0) | ||
console.error( | ||
'Error: Chain names not ordered alphabetically at paths:', | ||
unorderedChainNamesError, | ||
); | ||
|
||
process.exit(1); | ||
} | ||
|
||
function main() { | ||
validateChains(); | ||
validateWarpRoutes(); | ||
validateErrors(); | ||
} | ||
|
||
main(); |
Oops, something went wrong.