feat: make development builds visibly identifiable
This commit is contained in:
1 parent
0554f41d12
commit
2ed9bf0236
13 files changed
+285
-35
No files matched your search
@@ -0,0 +1,61 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { formatDevVersion, parseGitDescribe, resolveVersionInfo } from "./version.js";
|
||||
|
||||
describe("build version metadata", () => {
|
||||
test("parses tagged commits and dirty state", () => {
|
||||
expect(parseGitDescribe("v0.8.6-3-gabc1234")).toMatchObject({
|
||||
baseVersion: "0.8.6",
|
||||
commitsAhead: 3,
|
||||
commit: "abc1234",
|
||||
dirty: false,
|
||||
});
|
||||
expect(parseGitDescribe("v0.8.6-dirty")).toMatchObject({
|
||||
baseVersion: "0.8.6",
|
||||
commitsAhead: 0,
|
||||
dirty: true,
|
||||
});
|
||||
});
|
||||
|
||||
test("formats a visible semver development version", () => {
|
||||
expect(formatDevVersion("0.8.6", 2, "abc1234", false)).toBe("0.8.6-dev.2+gabc1234");
|
||||
expect(formatDevVersion("0.8.6", 2, "abc1234", true)).toBe("0.8.6-dev.2+gabc1234.dirty");
|
||||
});
|
||||
|
||||
test("uses compile-time release metadata when a binary provides it", () => {
|
||||
expect(resolveVersionInfo({
|
||||
env: {
|
||||
HOSE_BUILD_VERSION: "0.8.6",
|
||||
HOSE_BUILD_CHANNEL: "release",
|
||||
HOSE_BUILD_IS_RELEASE: "true",
|
||||
},
|
||||
})).toEqual({ name: "hose-use", version: "0.8.6", channel: "release", isRelease: true });
|
||||
});
|
||||
|
||||
test("includes git metadata in development mode", () => {
|
||||
const info = resolveVersionInfo({
|
||||
env: {
|
||||
HOSE_BUILD_VERSION: "0.8.6-dev.2+gabc1234",
|
||||
HOSE_BUILD_CHANNEL: "dev",
|
||||
HOSE_BUILD_IS_RELEASE: "false",
|
||||
HOSE_BUILD_GIT_BASE: "0.8.6",
|
||||
HOSE_BUILD_GIT_COMMITS_AHEAD: "2",
|
||||
HOSE_BUILD_GIT_COMMIT: "abc1234",
|
||||
HOSE_BUILD_GIT_DIRTY: "true",
|
||||
HOSE_BUILD_GIT_DESCRIBE: "v0.8.6-2-gabc1234-dirty",
|
||||
},
|
||||
});
|
||||
expect(info).toEqual({
|
||||
name: "hose-use",
|
||||
version: "0.8.6-dev.2+gabc1234",
|
||||
channel: "dev",
|
||||
isRelease: false,
|
||||
git: {
|
||||
baseVersion: "0.8.6",
|
||||
commitsAhead: 2,
|
||||
commit: "abc1234",
|
||||
dirty: true,
|
||||
describe: "v0.8.6-2-gabc1234-dirty",
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user