Skip to content

Commit 253c1b9

Browse files
committed
fix: Smoke test freshly downloaded puya binary before releasing the file lock
1 parent bd81564 commit 253c1b9

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/puya/puya-binary.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { Constants } from '../constants'
88
import { InternalError } from '../errors'
99
import { logger } from '../logger'
1010
import { generateTempDir } from '../util/generate-temp-file'
11+
import { runPuya } from './run-puya'
1112
import type { SemVer } from './semver'
1213

1314
/**
@@ -123,10 +124,26 @@ export async function downloadPuyaBinary(puyaStorageDir: string, version: SemVer
123124
throw new InternalError(`Binary file ${binaryFileName} not found in the extracted archive`)
124125
}
125126

127+
await smokeTestBinary(extractedBinaryPath)
128+
126129
logger.debug(undefined, `Successfully downloaded and extracted Puya binary to ${extractedBinaryPath}`)
127130
return extractedBinaryPath
128131
}
129132

133+
async function smokeTestBinary(path: string) {
134+
logger.debug(undefined, `Smoke testing downloaded binary @ ${path}`)
135+
136+
let output = ''
137+
await runPuya({
138+
command: path,
139+
args: ['--version'],
140+
onOutput: (line) => (output += line),
141+
})
142+
if (!/^puya ((\d+)\.(\d+)\.(\d+)(-.*)?)$/.test(output)) {
143+
throw new InternalError(`Unexpected output from puya --version : ${output}`)
144+
}
145+
}
146+
130147
/**
131148
* Downloads a file from a URL to a specified path
132149
* @param url The URL to download from

0 commit comments

Comments
 (0)