amp-cli: add a smoketest for the binary

Just runs --version. Amp will try create a log directory in your
homedir, so we need to give it a homedir it can write to.

Additionally we remove the rec and use finalAttrs instead.
This commit is contained in:
Keegan Carruthers-Smith 2025-05-29 08:44:00 +02:00
parent a98db0d69e
commit c85d7c7db5

View file

@ -4,14 +4,15 @@
fetchzip, fetchzip,
ripgrep, ripgrep,
makeWrapper, makeWrapper,
testers,
}: }:
buildNpmPackage rec { buildNpmPackage (finalAttrs: {
pname = "amp-cli"; pname = "amp-cli";
version = "0.0.1748404992-ga3f78f"; version = "0.0.1748404992-ga3f78f";
src = fetchzip { src = fetchzip {
url = "https://registry.npmjs.org/@sourcegraph/amp/-/amp-${version}.tgz"; url = "https://registry.npmjs.org/@sourcegraph/amp/-/amp-${finalAttrs.version}.tgz";
hash = "sha256-axd5VP7afa4ptAl/y8CEVguqoRKVRhWfRDSI0sgyXqA="; hash = "sha256-axd5VP7afa4ptAl/y8CEVguqoRKVRhWfRDSI0sgyXqA=";
}; };
@ -25,7 +26,7 @@ buildNpmPackage rec {
"version": "0.0.0", "version": "0.0.0",
"license": "UNLICENSED", "license": "UNLICENSED",
"dependencies": { "dependencies": {
"@sourcegraph/amp": "${version}" "@sourcegraph/amp": "${finalAttrs.version}"
}, },
"bin": { "bin": {
"amp": "./bin/amp-wrapper.js" "amp": "./bin/amp-wrapper.js"
@ -69,6 +70,10 @@ buildNpmPackage rec {
''; '';
passthru.updateScript = ./update.sh; passthru.updateScript = ./update.sh;
passthru.tests.version = testers.testVersion {
package = finalAttrs.finalPackage;
command = "HOME=$(mktemp -d) amp --version";
};
meta = { meta = {
description = "CLI for Amp, an agentic coding agent in research preview from Sourcegraph"; description = "CLI for Amp, an agentic coding agent in research preview from Sourcegraph";
@ -81,4 +86,4 @@ buildNpmPackage rec {
]; ];
mainProgram = "amp"; mainProgram = "amp";
}; };
} })