Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use version appropriate Go module path #307

Merged
merged 1 commit into from
Nov 2, 2023
Merged

fix: use version appropriate Go module path #307

merged 1 commit into from
Nov 2, 2023

Conversation

per1234
Copy link
Contributor

@per1234 per1234 commented Oct 27, 2023

There are two problems that cause editorconfig-checker to be difficult to use via the Go module framework:

The first of these problems is resolved here by adding the required /v2 suffix to the Go module path, bringing it into compliance with the requirements of the Go module framework.

Non-Compliant Module Path

A Go module is identified by a "module path". The Go module framework requires that this path have a major version suffix if the project is at a version of 2.0.0 or above:

https://go.dev/ref/mod#major-version-suffixes

This project is at version 2.x, so its previous Go module path github.com/editorconfig-checker/editorconfig-checker violated this requirement.

Non-Compliant Tag Names

The Go module framework requires that tag names use a "v" prefix (e.g., v2.7.3). The tag name format currently used by editorconfig-checker does not have this prefix (e.g., 2.7.2). The Go module framework does not recognize these tags as release markers.

Installation via go install

The non-compliances cause the command:

go install github.com/editorconfig-checker/editorconfig-checker/cmd/editorconfig-checker@latest

to unexpectedly install a potentially unstable beta version of editorconfig-checker from the tip of the default branch.

Once the project is brought into compliance, the equivalent command:

go install github.com/editorconfig-checker/editorconfig-checker/v2/cmd/editorconfig-checker@latest

will instead install the latest production release of the tool, which will be best practices for those using editorconfig-checker normally. It will still be possible for beta testers to install the development version of the tool by using @main, etc. as the ref in place of @latest.

Use as Go Module Dependency

The Go module might be specified as a dependency of other projects for either of the following reasons:

  • The project uses the module's packages in its own Go code
  • The project uses editorconfig-checker as a tool dependency and wants to manage the versioning of that dependency using a dummy "tools" Go package

In either of these use cases, the project maintainer will typically have the following goals for managing the dependency:

  • Pin the dependency at the latest stable release version on introduction
  • Bump the dependency at each new stable release in a controlled manner

The non-compliances make both of these difficult:

By default, the Go module framework will pin the dependency at the unstable tip of the default branch if no compliant tags are found.

When there isn't a compliant tag to pin to, the Go module framework, a "pseudo-version" (e.g., v0.0.0-20231013082012-98f0d6560dba) is used for the dependency's versioning. The popular Dependabot dependency management service will not offer updates for Go module dependencies using a pseudo-version, meaning the project maintainer must manage the dependency entirely manually.

Documentation

The installation documentation has been updated to use the new module path.

Backwards Compatibility

Due to the lack of any compliant tags in the repository, go get and go install commands using the old module path github.com/editorconfig-checker/editorconfig-checker that don't use an explicit ref in the version query will no longer work after the path change proposed here:

$ go get github.com/editorconfig-checker/editorconfig-checker

go: github.com/editorconfig-checker/editorconfig-checker: no matching versions for query "upgrade"

$ go install github.com/editorconfig-checker/editorconfig-checker/cmd/editorconfig-checker@latest

go: github.com/editorconfig-checker/editorconfig-checker/cmd/editorconfig-checker@latest: no matching versions for query "latest"

Commands that use a commit hash ref (which includes projects that already have the dependency in their go.mod/go.sum files) will continue to work as before:

$ go get github.com/editorconfig-checker/editorconfig-checker@98f0d6560dba

go: downloading github.com/editorconfig-checker/editorconfig-checker v0.0.0-20231013082012-98f0d6560dba
go: added github.com/editorconfig-checker/editorconfig-checker v0.0.0-20231013082012-98f0d6560dba

$ go install github.com/editorconfig-checker/editorconfig-checker/cmd/editorconfig-checker@98f0d6560dba

go: downloading github.com/editorconfig-checker/editorconfig-checker v0.0.0-20231013082012-98f0d6560dba
[...]

Conclusion

The problem of non-compliant tag names must be fixed by an adjustment to the release procedure rather than a change to the repository contents. However, the change to a compliant module path name made here lays the groundwork for bringing the project into full compliance once compliant tag names are used for future releases.

Using a compliant module path as well as compliant tag names would benefit the users of editorconfig-checker by allowing them to install and manage it as a project dependency in a safe and efficient manner.

Copy link

codecov bot commented Nov 2, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Files Coverage Δ
pkg/config/config.go 100.00% <ø> (ø)
pkg/error/error.go 86.36% <ø> (ø)
pkg/files/files.go 59.73% <ø> (ø)
pkg/validation/validation.go 88.02% <ø> (ø)
pkg/validation/validators/validators.go 100.00% <ø> (ø)

📢 Thoughts on this report? Let us know!.

@mstruebing mstruebing enabled auto-merge (squash) November 2, 2023 12:18
@mstruebing
Copy link
Member

Hey, thank you very much for this grad and descriptive PR.
Could you update the Makefile as well to respect the version?
There are a couple of occurrences where this would matter I think, i.e.:

_build_dockerfile:
	docker build -t mstruebing/editorconfig-checker:$(shell grep 'const version' cmd/editorconfig-checker/main.go | sed 's/.*"\(.*\)"/\1/') .

_push_dockerfile:
	docker push mstruebing/editorconfig-checker:$(shell grep 'const version' cmd/editorconfig-checker/main.go | sed 's/.*"\(.*\)"/\1/')

And maybe even in the _tag_version target automatically add a v in front of the version if that's not present?

I think this is a breaking change? Correct me if I'm wrong but if so, we could merge #255 as well before releasing a new version.
Let me know what you think.

There are two problems that cause editorconfig-checker to be difficult to use via the Go module framework:

* Non-compliant module path
* Non-compliant tag names

The first of these problems is resolved here by adding the required `/v2` suffix to the Go module path, bringing it into
compliance with the requirements of the Go module framework.

Non-Compliant Module Path
-------------------------

A Go module is identified by a "module path". The Go module framework requires that this path have a major version
suffix if the project is at a version of 2.0.0 or above:

https://go.dev/ref/mod#major-version-suffixes

This project is at version 2.x, so its previous Go module path `github.com/editorconfig-checker/editorconfig-checker`
violated this requirement.

Non-Compliant Tag Names
-----------------------

The Go module framework requires that tag names use a "v" prefix (e.g., v2.7.3). The tag name format currently used by
editorconfig-checker does not have this prefix. The Go module framework does not recognize these tags as release
markers.

Installation via `go install`
-----------------------------

The non-compliances cause the command:

go install github.com/editorconfig-checker/editorconfig-checker/cmd/editorconfig-checker@latest

to unexpectedly install a potentially unstable beta version of editorconfig-checker from the tip of the default branch.

Once the project is brought into compliance, the equivalent command:

go install github.com/editorconfig-checker/editorconfig-checker/v2/cmd/editorconfig-checker@latest

will instead install the latest production release of the tool, which will be best practices for those using
editorconfig-checker normally. It will still be possible for beta testers to install the development version of the tool
by using @main as the ref in place of @latest.

Use as Go Module Dependency
---------------------------

The Go module might be specified as a dependency of other projects for either of the following reasons:

* The project uses the module's packages in its own Go code
* The project uses editorconfig-checker as a tool dependency and wants to manage the versioning of that dependency using
a dummy "tools" Go package

In either of these use cases, the project maintainer will typically have the following goals for managing the
dependency:

* Pin the dependency at the latest stable release version on introduction
* Bump the dependency at each new stable release in a controlled manner

The non-compliances make both of these difficult:

By default, the Go module framework will pin the dependency at the unstable tip of the default branch if no compliant
tags are found.

When there isn't a compliant tag to pin to, the Go module framework, a "pseudo-version" is used for the dependency's
versioning. The popular Dependabot dependency management service will not offer updates for Go module dependencies using
a pseudo-version, meaning the project maintainer must manage the dependency entirely manually.

Documentation
-------------

The installation documentation has been updated to use the new module path.

Backwards Compatibility
-----------------------

Due to the lack of any compliant tags in the repository, `go get` and `go install` commands using the old module path
`github.com/editorconfig-checker/editorconfig-checker` without an explicit ref will no longer work after this path
change. Commands that use a commit hash ref (which includes projects that already have the dependency in their
`go.mod`/`go.sum` files) will continue to work as before.

Conclusion
----------

The problem of non-compliant tag names must be fixed by an adjustment to the release procedure rather than a change to
the repository contents. However, the change to a compliant module path name made here lays the groundwork for bringing
the project into full compliance once compliant tag names are used for future releases.

Using a compliant module path as well as compliant tag names would benefit the users of editorconfig-checker by allowing
them to install and manage it as a project dependency in a safe and efficient manner.
@mstruebing mstruebing merged commit b32b0c9 into editorconfig-checker:main Nov 2, 2023
3 checks passed
@per1234 per1234 changed the title Use version appropriate Go module path fix: use version appropriate Go module path Nov 2, 2023
@per1234
Copy link
Contributor Author

per1234 commented Nov 2, 2023

You are welcome, and thanks for fixing the problem with the Makefile for me. I apologize for not having the PR in a fully ready to merge state before submission.

I think this is a breaking change?

It is breaking for go get and go install commands using the old module path github.com/editorconfig-checker/editorconfig-checker that don't use an explicit ref in the version query.

This breakage occurred at the moment the PR was merged (though it might not be immediately reproducible when using a module mirror; I had to disable it by setting the environment variable GOPROXY=direct to reproduce):

$ go get github.com/editorconfig-checker/editorconfig-checker

go: github.com/editorconfig-checker/editorconfig-checker: no matching versions for query "upgrade"

$ go install github.com/editorconfig-checker/editorconfig-checker/cmd/editorconfig-checker@latest

go: github.com/editorconfig-checker/editorconfig-checker/cmd/editorconfig-checker@latest: no matching versions for query "latest"

The breakage could be mitigated by creating a compliant tag for the 1.x major version series of editorconfig-checker:

git tag v1.3.0 1.3.0 && git push https://github.com/editorconfig-checker/editorconfig-checker v1.3.0

With that v1.3.0 in the repository, the go get and go install commands using the old module path github.com/editorconfig-checker/editorconfig-checker will succeed. However, there will be a significant difference in the result of these commands in that they will now install version 1.3.0 of editorconfig-checker instead of the version from the tip of the default branch as they did before.

@mstruebing
Copy link
Member

mstruebing commented Nov 3, 2023

I think I've merged this as a mistake, did a lot of maintenance work in different repositories yesterday.
The Makefile/build/release adjustments are not yet done.
I will do that today.

Thank you for your detailed explanation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants