Skip to content

Commit

Permalink
validate registry commit before deploying warp monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbalaji committed Jan 22, 2025
1 parent 622bdce commit f3ee01a
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions typescript/infra/scripts/warp-routes/deploy-warp-monitor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { input } from '@inquirer/prompts';
import chalk from 'chalk';
import { execSync } from 'child_process';

import {
LogFormat,
Expand All @@ -8,6 +10,7 @@ import {
} from '@hyperlane-xyz/utils';

import { Contexts } from '../../config/contexts.js';
import { getRegistry } from '../../config/registry.js';
import { HelmCommand } from '../../src/utils/helm.js';
import { WarpRouteMonitorHelmManager } from '../../src/warp/helm.js';
import {
Expand All @@ -19,6 +22,24 @@ import {
} from '../agent-utils.js';
import { getEnvironmentConfig } from '../core-utils.js';

async function validateRegistryCommit(commit: string) {
const registry = getRegistry();
const registryUri = registry.getUri();

try {
rootLogger.info(
chalk.grey.italic(`Attempting to fetch registry commit ${commit}...`),
);
execSync(`cd ${registryUri} && git fetch origin ${commit}`, {
stdio: 'inherit',
});
rootLogger.info(chalk.grey.italic('Fetch completed successfully.'));
} catch (_) {
rootLogger.error(chalk.red(`Unable to fetch registry commit ${commit}.`));
process.exit(1);
}
}

async function main() {
configureRootLogger(LogFormat.Pretty, LogLevel.Info);
const { environment, warpRouteId } = await withWarpRouteId(getArgs()).argv;
Expand All @@ -34,6 +55,7 @@ async function main() {
message:
'Enter the registry version to use (can be a commit, branch or tag):',
});
await validateRegistryCommit(registryCommit);

await assertCorrectKubeContext(getEnvironmentConfig(environment));
const agentConfig = getAgentConfig(Contexts.Hyperlane, environment);
Expand Down

0 comments on commit f3ee01a

Please sign in to comment.