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

Only upgrade go version in genmod, don't downgrade #1418

Merged
merged 2 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,19 @@ jobs:
- name: Unit tests
run: make test

check-update-modules:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: stable
cache: true
cache-dependency-path: '**/go.sum'
- name: Check Update Modules Command
run: make update-modules

coverage:
runs-on: ubuntu-latest
timeout-minutes: 20
Expand Down
1 change: 1 addition & 0 deletions scripts/genmod/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module genmod
require (
github.com/pkg/errors v0.9.1
go.elastic.co/apm/v2 v2.1.0
golang.org/x/mod v0.5.1
)

replace go.elastic.co/apm/v2 => ../..
Expand Down
2 changes: 0 additions & 2 deletions scripts/genmod/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU=
github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
github.com/santhosh-tekuri/jsonschema v1.2.4 h1:hNhW8e7t+H1vgY+1QeEQpveR6D4+OwKPXCfD2aieJis=
github.com/santhosh-tekuri/jsonschema v1.2.4/go.mod h1:TEAUOeZSmIxTTuHatJzrvARHiuO9LYd+cIxzgEHCQI4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
Expand Down
3 changes: 2 additions & 1 deletion scripts/genmod/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"strings"

"github.com/pkg/errors"
"golang.org/x/mod/semver"

"go.elastic.co/apm/v2"
)
Expand Down Expand Up @@ -138,7 +139,7 @@ func updateModule(dir string, gomod *GoMod, modules map[string]*GoMod) error {
"-require", require.Path + "@" + *versionFlag,
"-replace", require.Path + "=" + relDir,
}
if *goVersionFlag != "" {
if *goVersionFlag != "" && semver.Compare("v"+*goVersionFlag, "v"+gomod.Go) == 1 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if this would be acceptable for all cases since it might break the compatibility of agents if go.mod for a specific module is unintentionally upgraded. @axw can probably clarify this.

Alternatively, we can add another option to exclude certain modules and execute 2 separate commands in the update-modules (might be more of a hack as the list might grow).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If go.mod is unintentionally upgraded, wouldn't PR reviews be there to prevent that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine releasing new modules with a version greater than the agent's minimum, just not the other way around. If the version of a module is updated after release such that compatibility is broken, I would consider that a bug that we would fix by reverting.

args = append(args, "-go", *goVersionFlag)
}
cmd := exec.Command("go", args...)
Expand Down