From 73f00a8f6029c3d4a0942f393113403cccc9591a Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Thu, 15 Oct 2026 15:28:42 -0700 Subject: [PATCH 1/2] ci: run go test There were no Go tests so far, but we are about to add one. Add test target to Makefile, and run it from CI. Signed-off-by: Kir Kolyshkin --- .github/workflows/build.yml | 2 ++ Makefile | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 07deb7fcc..20174137a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -31,6 +31,8 @@ jobs: set -x make install.tools + make test + make .gitvalidation make docs make -C schema test diff --git a/Makefile b/Makefile index bf058ba37..1ebe2e281 100644 --- a/Makefile +++ b/Makefile @@ -54,6 +54,10 @@ endif version.md: ./specs-go/version.go go run ./.tool/version-doc.go > $@ +.PHONY: test +test: + go test ./... + .PHONY: lint lint: golangci-lint run From c9a066eb2db910e6053bbfaf8929dbe336c90b8a Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Thu, 15 Oct 2026 15:26:02 -0700 Subject: [PATCH 2/2] specs-go: make Version a string literal Version is initialized during package initialization, which happens on every start of any program importing this package (for example, runc, which re-executes itself on every container start and exec). Using fmt.Sprintf for that takes about 4us and 5 allocations (2920 bytes). Remove all this, making it a plain string literal. Kept as a variable rather than a constant, since some users overwrite it, and changing it to a constant would break them. Add a test to make sure Version is in sync with the constants, and update the release checklist accordingly. Signed-off-by: Kir Kolyshkin --- RELEASES.md | 4 ++-- specs-go/version.go | 4 +--- specs-go/version_test.go | 13 +++++++++++++ 3 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 specs-go/version_test.go diff --git a/RELEASES.md b/RELEASES.md index 071910aed..80b2de480 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -61,8 +61,8 @@ Releases usually follow a few steps: * [ ] delete the `(^M|^A|^D)` lines, `:%!grep -vE '(^M|^A|^D)'` * [ ] merge multi-commit PRs (so each line has a `(#num)` suffix) * [ ] drop hash and indent, `:'<,'> s/^\w* /^I* /` - * [ ] a commit bumping `./specs-go/version.go` to next version and empty the `VersionDev` variable - * [ ] a commit adding back the "+dev" to `VersionDev` + * [ ] a commit bumping `./specs-go/version.go` to next version and empty the `VersionDev` variable (update `Version` accordingly) + * [ ] a commit adding back the "+dev" to `VersionDev` and `Version` * [ ] send email to * [ ] copy the exact commit hash for bumping the version from the pull-request (since master always stays as "-dev") * [ ] count the PRs since last release (that this version is tracking, in the cases of multiple branching), like `git log --pretty=oneline --no-merges --decorate $priorTag..$versionBumpCommit | grep \(pr\/ | wc -l` diff --git a/specs-go/version.go b/specs-go/version.go index 9a985a528..72d57132d 100644 --- a/specs-go/version.go +++ b/specs-go/version.go @@ -1,7 +1,5 @@ package specs -import "fmt" - const ( // VersionMajor is for an API incompatible changes VersionMajor = 1 @@ -15,4 +13,4 @@ const ( ) // Version is the specification version that the package types support. -var Version = fmt.Sprintf("%d.%d.%d%s", VersionMajor, VersionMinor, VersionPatch, VersionDev) +var Version = "1.3.0+dev" diff --git a/specs-go/version_test.go b/specs-go/version_test.go new file mode 100644 index 000000000..4b8012d93 --- /dev/null +++ b/specs-go/version_test.go @@ -0,0 +1,13 @@ +package specs + +import ( + "strconv" + "testing" +) + +func TestVersionSynced(t *testing.T) { + wantVer := strconv.Itoa(VersionMajor) + "." + strconv.Itoa(VersionMinor) + "." + strconv.Itoa(VersionPatch) + VersionDev + if Version != wantVer { + t.Fatalf("Version mismatch: got %q, want %q", Version, wantVer) + } +}