From 798e42eefccbb1132ac7b0f66422fcbe4b87842a Mon Sep 17 00:00:00 2001 From: number571 Date: Sun, 5 Oct 2025 10:55:28 +0700 Subject: [PATCH] update --- build/build_version.go | 28 ++++ build/version.yml | 1 + changelog_test.go | 53 ++++++++ test/result/badge_coverage.svg | 2 +- test/result/coverage.svg | 226 +++++++++++++++++---------------- 5 files changed, 199 insertions(+), 111 deletions(-) create mode 100644 build/build_version.go create mode 100644 build/version.yml create mode 100644 changelog_test.go diff --git a/build/build_version.go b/build/build_version.go new file mode 100644 index 00000000..0a23e497 --- /dev/null +++ b/build/build_version.go @@ -0,0 +1,28 @@ +// nolint: err113 +package build + +import ( + _ "embed" + + "github.com/number571/go-peer/pkg/encoding" +) + +var ( + //go:embed version.yml + gVersionVal []byte + gVersion string +) + +func init() { + var versionYAML struct { + FVersion string `yaml:"version"` + } + if err := encoding.DeserializeYAML(gVersionVal, &versionYAML); err != nil { + panic(err) + } + gVersion = versionYAML.FVersion +} + +func GetVersion() string { + return gVersion +} diff --git a/build/version.yml b/build/version.yml new file mode 100644 index 00000000..288625ad --- /dev/null +++ b/build/version.yml @@ -0,0 +1 @@ +version: v1.7.11~ \ No newline at end of file diff --git a/changelog_test.go b/changelog_test.go new file mode 100644 index 00000000..51054000 --- /dev/null +++ b/changelog_test.go @@ -0,0 +1,53 @@ +package gopeer + +import ( + _ "embed" + "regexp" + "strings" + "testing" + + "github.com/number571/go-peer/build" +) + +var ( + //go:embed CHANGELOG.md + tgCHANGELOG string +) + +func TestHiddenLakeVersion(t *testing.T) { + t.Parallel() + + re := regexp.MustCompile(`##\s+(v\d+\.\d+\.\d+~?)\s+`) + match := re.FindAllStringSubmatch(tgCHANGELOG, -1) + if len(match) < 2 { + t.Fatal("versions not found") + } + + version := build.GetVersion() + if strings.HasSuffix(version, "~") { + if match[0][1] != version { + t.Fatal("the versions do not match") + } + } else { + // current version is always previous version in the changelog + if match[1][1] != version { + t.Fatal("the versions do not match") + } + } + + if match[0][1] == match[1][1] { + t.Fatal("the same versions inline") + } + + for i := 0; i < len(match); i++ { + for j := i + 1; j < len(match)-1; j++ { + if match[i][1] == match[j][1] { + t.Fatalf("found the same versions (i=%d, j=%d)", i, j) + } + } + } + + if strings.Count(tgCHANGELOG, "*??? ??, ????*") != 1 { + t.Fatal("is there no new version or more than one new version?") + } +} diff --git a/test/result/badge_coverage.svg b/test/result/badge_coverage.svg index 9fd7bd14..65824887 100644 --- a/test/result/badge_coverage.svg +++ b/test/result/badge_coverage.svg @@ -1 +1 @@ -coverage: 97%coverage97% \ No newline at end of file +coverage: 96%coverage96% \ No newline at end of file diff --git a/test/result/coverage.svg b/test/result/coverage.svg index 2380d9cc..6dae8b34 100644 --- a/test/result/coverage.svg +++ b/test/result/coverage.svg @@ -7,7 +7,7 @@ > - + - + + + + + + + - + - + - + client @@ -65,12 +71,12 @@ - + crypto @@ -78,12 +84,12 @@ - + encoding @@ -91,12 +97,12 @@ - + logger @@ -104,12 +110,12 @@ - + message @@ -117,7 +123,7 @@ - + - + payload @@ -143,12 +149,12 @@ - + state @@ -156,12 +162,12 @@ - + storage @@ -169,12 +175,12 @@ - + action.go @@ -182,13 +188,13 @@ - + - + - + - + head.go @@ -220,12 +226,12 @@ - + logger/log_builder.go @@ -233,12 +239,12 @@ - + queue @@ -246,12 +252,12 @@ - + settings.go @@ -259,12 +265,12 @@ - + client.go @@ -272,12 +278,12 @@ - + asymmetric @@ -285,12 +291,12 @@ - + hashing @@ -298,18 +304,18 @@ - + - + puzzle/puzzle.go @@ -317,12 +323,12 @@ - + random/random.go @@ -330,12 +336,12 @@ - + symmetric/symmetric.go @@ -343,12 +349,12 @@ - + bytes.go @@ -356,30 +362,30 @@ - + - + - + - + serialize_yaml.go @@ -387,12 +393,12 @@ - + logger.go @@ -400,18 +406,18 @@ - + - + layer1 @@ -419,12 +425,12 @@ - + layer2 @@ -432,12 +438,12 @@ - + conn @@ -445,12 +451,12 @@ - + connkeeper @@ -458,7 +464,7 @@ - + - + settings.go @@ -484,12 +490,12 @@ - + joiner @@ -497,12 +503,12 @@ - + payload32.go @@ -510,12 +516,12 @@ - + payload64.go @@ -523,18 +529,18 @@ - + - + cache/lru.go @@ -542,12 +548,12 @@ - + database @@ -555,18 +561,18 @@ - + - + queue.go @@ -574,12 +580,12 @@ - + settings.go @@ -587,12 +593,12 @@ - + dsa.go @@ -600,12 +606,12 @@ - + kem.go @@ -613,12 +619,12 @@ - + key.go @@ -626,30 +632,30 @@ - + - + - + - + message.go @@ -657,12 +663,12 @@ - + settings.go @@ -670,12 +676,12 @@ - + message.go @@ -683,12 +689,12 @@ - + conn.go @@ -696,12 +702,12 @@ - + settings.go @@ -709,12 +715,12 @@ - + connkeeper.go @@ -722,18 +728,18 @@ - + - + joiner32.go @@ -741,12 +747,12 @@ - + database.go