10const checkDeployedGitSha = async ({hostname, ptenv}: {hostname: string, ptenv: Ptenv}) => { 12 const {mkTestGqlFetch} = appCfg || {} 13 const testGqlFetch = mkTestGqlFetch ? await mkTestGqlFetch(ptenv) : null 14 const doFetch = testGqlFetch?.fetch ?? gqlFetch 15 const getKey = testGqlFetch?.mapKey ?? ((k: string) => k) 17 const baseUrl = `https://${hostname}` 18 const resp = await doFetch({baseUrl, query: '{ gqDeployInfo }'}) 19 const deployedSha = resp?.data?.[getKey('gqDeployInfo')] 21 if (!deployedSha) return { passed: false, msg: 'no deployed SHA returned' } 26 if (!lastDeploy?.gitSha) return { passed: true, msg: `SHA ${deployedSha.slice(0,7)} (no deploy history to compare)`, skipped: true } 27 if (lastDeploy.imageReused) return { passed: true, msg: `SHA ${deployedSha.slice(0,7)} (image reused/cached)`, skipped: true } 29 const expectedSha = lastDeploy.buildSha || lastDeploy.gitSha 30 const matches = deployedSha === expectedSha 32 ? { passed: true, msg: `SHA ${deployedSha.slice(0,7)} matches` } 33 : { passed: false, msg: `deployed ${deployedSha.slice(0,7)} != expected ${expectedSha.slice(0,7)}` } 36export const runDeployverifySuite: SuiteRunner = async ({ ptenv, isTestdeploy }) => { 37 if (!isTestdeploy) return skipSuite('deployverify only runs during testdeploy') 40 if (!hostname) return skipSuite('no deployed hostname') 43 suiteName: 'deployverify', 45 name: 'gitShaMatchesDeployedTrue', 46 fn: () => checkDeployedGitSha({hostname, ptenv}), 51export const deployverifySuiteConfig = { name: 'deployverify', runner: runDeployverifySuite, deps: [] as const }