Skip to content

Commit

Permalink
feat: add auto-update functionality and improve test script in amber …
Browse files Browse the repository at this point in the history
…project (#212)

Signed-off-by: Jérémy Audiger <[email protected]>
  • Loading branch information
jaudiger authored Jan 28, 2025
1 parent 4f8fd12 commit 3089eb6
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions packages/amber/project.bri
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import nushell from "nushell";
import * as std from "std";
import { cargoBuild } from "rust";

Expand All @@ -19,8 +20,32 @@ export default function amber(): std.Recipe<std.Directory> {
});
}

export function test() {
return std.runBash`
amber --version | tee "$BRIOCHE_OUTPUT"
export async function test() {
const script = std.runBash`
amber --version | tr -d '\n' | tee "$BRIOCHE_OUTPUT"
`.dependencies(amber());

const result = await script.toFile().read();

// Check that the result contains the expected version
const expected = `amber ${project.version}`;
std.assert(result === expected, `expected '${expected}', got '${result}'`);

return script;
}

export function autoUpdate() {
const src = std.file(std.indoc`
let version = http get https://api.github.com/repos/amber-lang/amber/releases/latest
| get tag_name
$env.project | from json | update version $version | to json
`);

return std.withRunnable(std.directory(), {
command: "nu",
args: [src],
env: { project: JSON.stringify(project) },
dependencies: [nushell()],
});
}

0 comments on commit 3089eb6

Please sign in to comment.