Skip to content

Commit

Permalink
feat(version): add version functionality and related tests (#544)
Browse files Browse the repository at this point in the history
- Add `version.go` with `Version()` function returning "3.0.0"
- Add `version_test.go` to validate semver format
- Add `versions.yaml` for module version management
- Update package name in `gomod_test.go` to `fries`
  • Loading branch information
flc1125 authored Jan 5, 2025
1 parent 22d34ea commit 68392bb
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 2 deletions.
1 change: 0 additions & 1 deletion docs.go

This file was deleted.

2 changes: 1 addition & 1 deletion gomod_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package components
package fries

import (
"os"
Expand Down
5 changes: 5 additions & 0 deletions version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package fries

func Version() string {
return "3.0.0"
}
20 changes: 20 additions & 0 deletions version_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package fries_test

import (
"regexp"
"testing"

"github.com/go-fries/fries/v3"
"github.com/stretchr/testify/assert"
)

// regex taken from https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
var versionRegex = regexp.MustCompile(`^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)` +
`(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)` +
`(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?` +
`(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$`)

func TestVersionSemver(t *testing.T) {
v := fries.Version()
assert.NotNil(t, versionRegex.FindStringSubmatch(v), "version is not semver: %s", v)
}
14 changes: 14 additions & 0 deletions versions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module-sets:
stable-v4:
version: v4.3.0
modules:
- github.com/flc1125/go-cron/v4
- github.com/flc1125/go-cron/crontest/v4
- github.com/flc1125/go-cron/middleware/delayoverlapping/v4
- github.com/flc1125/go-cron/middleware/distributednooverlapping/v4
- github.com/flc1125/go-cron/middleware/distributednooverlapping/redismutex/v4
- github.com/flc1125/go-cron/middleware/nooverlapping/v4
- github.com/flc1125/go-cron/middleware/otel/v4
- github.com/flc1125/go-cron/middleware/recovery/v4
excluded-modules:
- github.com/flc1125/go-cron/v4/internal/tools

0 comments on commit 68392bb

Please sign in to comment.