From a5aef43a71eb0b620954f997ccc21b7058906810 Mon Sep 17 00:00:00 2001 From: felipegenef Date: Thu, 28 May 2026 15:55:44 -0300 Subject: [PATCH 1/4] fix(migrate-v2): seed go.mod with current CLI version instead of hardcoded v2.0.0 --- cmd/migrate_v2.go | 5 +++-- cmd/version.go | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cmd/migrate_v2.go b/cmd/migrate_v2.go index 31c6d27..6856cb8 100644 --- a/cmd/migrate_v2.go +++ b/cmd/migrate_v2.go @@ -246,10 +246,11 @@ func rewriteGoMod(path string, content []byte, dryRun bool) (bool, error) { for _, r := range mf.Require { if r.Mod.Path == oldModulePath { // /v2 modules require a v2.x.x version per SemVer import compatibility. - // We seed with v2.0.0; `go mod tidy` will resolve to the actual latest. + // Seed with the current CLI version so `go mod tidy` starts from a + // version that is guaranteed to exist on the registry. newVersion := r.Mod.Version if !strings.HasPrefix(newVersion, "v2.") { - newVersion = "v2.0.0" + newVersion = CURRENT_VERSION } if err := mf.AddRequire(newModulePath, newVersion); err != nil { return false, err diff --git a/cmd/version.go b/cmd/version.go index e2af7c2..21a6296 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -9,7 +9,7 @@ import ( "github.com/spf13/cobra" ) -var CURRENT_VERSION string = "v2.17.2" +var CURRENT_VERSION string = "v2.17.3" // versionCmd represents the version command var versionCmd = &cobra.Command{ From 96aa318ce92bc133f64af33128de7e2089b130d2 Mon Sep 17 00:00:00 2001 From: felipegenef Date: Thu, 28 May 2026 16:13:16 -0300 Subject: [PATCH 2/4] feat add PR test requirement --- .github/workflows/ci.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..179d196 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,20 @@ +name: CI + +on: + pull_request: + branches: [main] + +jobs: + test: + name: Go Tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + + - name: Run tests + run: go test ./cmd/... ./pkg/cli/... ./pkg/helpers/proxy/... ./pkg/helpers/routes/... -v From a4c3ac95b11a9d6349c3f4610c3472dbab4bae71 Mon Sep 17 00:00:00 2001 From: felipegenef Date: Thu, 28 May 2026 16:18:45 -0300 Subject: [PATCH 3/4] make tests pass --- branch-name.md | 1 + cmd/migrate_v2_test.go | 43 +++++++++++++++--------------------------- commit-message.md | 1 + release-notes.md | 10 ++++++++++ 4 files changed, 27 insertions(+), 28 deletions(-) create mode 100644 branch-name.md create mode 100644 commit-message.md create mode 100644 release-notes.md diff --git a/branch-name.md b/branch-name.md new file mode 100644 index 0000000..2c9d798 --- /dev/null +++ b/branch-name.md @@ -0,0 +1 @@ +fix/migrate-v2-seed-version diff --git a/cmd/migrate_v2_test.go b/cmd/migrate_v2_test.go index e435fe9..7193952 100644 --- a/cmd/migrate_v2_test.go +++ b/cmd/migrate_v2_test.go @@ -43,38 +43,29 @@ func readFile(t *testing.T, p string) string { return string(b) } -// equalGoMod compares two go.mod contents semantically (module + requires). -func equalGoMod(t *testing.T, gotPath, wantPath string) bool { +// assertGoMod checks that the migrated go.mod requires newModulePath at CURRENT_VERSION. +func assertGoMod(t *testing.T, gotPath string) { t.Helper() gb, err := os.ReadFile(gotPath) if err != nil { - t.Fatalf("read got: %v", err) - } - wb, err := os.ReadFile(wantPath) - if err != nil { - t.Fatalf("read want: %v", err) + t.Fatalf("read go.mod: %v", err) } g, err := modfile.Parse(gotPath, gb, nil) if err != nil { - t.Fatalf("parse got: %v", err) - } - w, err := modfile.Parse(wantPath, wb, nil) - if err != nil { - t.Fatalf("parse want: %v", err) + t.Fatalf("parse go.mod: %v", err) } - if g.Module.Mod.Path != w.Module.Mod.Path { - return false - } - if len(g.Require) != len(w.Require) { - return false - } - for i := range g.Require { - if g.Require[i].Mod.Path != w.Require[i].Mod.Path || - g.Require[i].Mod.Version != w.Require[i].Mod.Version { - return false + for _, r := range g.Require { + if r.Mod.Path == oldModulePath { + t.Errorf("go.mod still requires old path %s", oldModulePath) + } + if r.Mod.Path == newModulePath { + if r.Mod.Version != CURRENT_VERSION { + t.Errorf("go.mod: want %s %s, got %s", newModulePath, CURRENT_VERSION, r.Mod.Version) + } + return } } - return true + t.Errorf("go.mod: %s not found in require directives", newModulePath) } func setupTempProject(t *testing.T) string { @@ -96,11 +87,7 @@ func TestMigrateV2_Migration(t *testing.T) { afterDir := filepath.Join("testdata", "migrate_v2", "after") - if !equalGoMod(t, filepath.Join(dir, "go.mod"), filepath.Join(afterDir, "go.mod")) { - t.Errorf("go.mod mismatch.\ngot:\n%s\nwant:\n%s", - readFile(t, filepath.Join(dir, "go.mod")), - readFile(t, filepath.Join(afterDir, "go.mod"))) - } + assertGoMod(t, filepath.Join(dir, "go.mod")) for _, name := range []string{"main.go", "page.templ"} { got := readFile(t, filepath.Join(dir, name)) want := readFile(t, filepath.Join(afterDir, name)) diff --git a/commit-message.md b/commit-message.md new file mode 100644 index 0000000..b2de128 --- /dev/null +++ b/commit-message.md @@ -0,0 +1 @@ +fix(migrate-v2): seed go.mod with current CLI version instead of hardcoded v2.0.0 diff --git a/release-notes.md b/release-notes.md new file mode 100644 index 0000000..5110cc7 --- /dev/null +++ b/release-notes.md @@ -0,0 +1,10 @@ +## v2.17.3 + +### Bug Fixes + +- **migrate-v2:** Fixed a critical error where `migrate-v2` seeded `go.mod` with the hardcoded version `v2.0.0` (which does not exist on the registry), causing `go mod tidy` to fail. The command now seeds the `github.com/felipegenef/gothicframework/v2` requirement with the current CLI version, guaranteeing the seeded version is resolvable. + +### Infrastructure + +- **CI:** Added `.github/workflows/ci.yml` — all Go tests must pass before a PR can be merged into `main`. +- **Branch cleanup:** Enabled "Automatically delete head branches" in repository settings — merged branches are deleted automatically after a PR is closed. From e5fdd03aca94d65d0d65d3cc38360869bc36dc81 Mon Sep 17 00:00:00 2001 From: felipegenef Date: Thu, 28 May 2026 16:27:49 -0300 Subject: [PATCH 4/4] add codecov and test pipelines --- .github/workflows/ci.yml | 16 +++++++++++++++- README.md | 3 +++ branch-name.md | 1 - commit-message.md | 1 - release-notes.md | 10 ---------- 5 files changed, 18 insertions(+), 13 deletions(-) delete mode 100644 branch-name.md delete mode 100644 commit-message.md delete mode 100644 release-notes.md diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 179d196..7cfa7ac 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,5 +16,19 @@ jobs: with: go-version-file: go.mod + - name: Install gotestfmt + run: go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest + - name: Run tests - run: go test ./cmd/... ./pkg/cli/... ./pkg/helpers/proxy/... ./pkg/helpers/routes/... -v + run: | + go test ./cmd/... ./pkg/cli/... ./pkg/helpers/proxy/... ./pkg/helpers/routes/... \ + -json -coverprofile=coverage.out -covermode=atomic \ + 2>&1 | tee /tmp/gotest.log | gotestfmt + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 + with: + files: coverage.out + fail_ci_if_error: true + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/README.md b/README.md index 8d8d135..a803a31 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ background doc +[![CI](https://github.com/felipegenef/gothicframework/actions/workflows/ci.yml/badge.svg)](https://github.com/felipegenef/gothicframework/actions/workflows/ci.yml) +[![codecov](https://codecov.io/gh/felipegenef/gothicframework/branch/main/graph/badge.svg)](https://codecov.io/gh/felipegenef/gothicframework) +