Skip to content

Bump x/tools for tools, to support go 1.22 #1336

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

Merged
merged 1 commit into from
May 20, 2024

Conversation

Groxx
Copy link
Member

@Groxx Groxx commented May 20, 2024

Mockery is currently failing on go 1.22 on Linux due to golang/go#64812
tl;dr, changes in go 1.22 break the popular x/tools/go/packages.Load tool, which Mockery uses.

Upgrading our tools' x/tools (to latest) resolves it, and appears to work fine for go 1.19 and above on both Linux and OSX, and has zero effect on our users.

Mockery is currenty failing on 1.22 due to golang/go#64812
Copy link

codecov bot commented May 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.20%. Comparing base (73b12d5) to head (2bde54c).

Additional details and impacted files

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 73b12d5...2bde54c. Read the comment docs.

@Groxx Groxx merged commit fc1d544 into cadence-workflow:master May 20, 2024
13 checks passed
@Groxx Groxx deleted the x/tools branch May 20, 2024 21:16
mrombout pushed a commit to softsense/cadence-client that referenced this pull request Feb 26, 2025
Mockery is currently failing on go 1.22 on Linux due to golang/go#64812
tl;dr, changes in go 1.22 break the popular `x/tools/go/packages.Load` tool, which Mockery uses.

Upgrading our tools' `x/tools` (to latest) resolves it, and appears to work fine for go 1.19 and above on both Linux and OSX, and has zero effect on our users.
Groxx added a commit that referenced this pull request May 5, 2025
Mockery is failing when run with go 1.24 due to vektra/mockery#914 , so let's upgrade it.

Basic steps to upgrade are:
```
# add go toolchain to go.mod to enforce a higher minimum
cd internal/tools
go get golang.org/x/tools@latest github.com/vektra/mockery/v2@latest
cd ../..
make all
```
and some careful reading to verify the results.

And then some changes to address our CI needs, e.g. since runtime and tool-time versions have diverged (currently) we now automatically pull and build with the old version.
Most of these version values can be found by doing a grep like
```
❯ rg 'go(lang)?.?1.?2\d'
go.mod
3:go 1.21                # intentionally different

docker/buildkite/Dockerfile
1:FROM golang:1.24

Makefile
36:EXPECTED_GO_VERSION := go1.24

CHANGELOG.md
28:- Bump x/tools for tools, to support go 1.22 (#1336)
143:- Fix TestActivityWorkerStop: it times out with go 1.20 by @dkrotx in #1223

internal/tools/go.mod
3:go 1.23.0
5:toolchain go1.24.2
```

I had _expected_ `go 1.21` in go.mod to take care of this kind of check, but apparently not: golang/go#73603
so it's now done by hand.

---

There are *some* changes which I think stand a very small chance of causing problems:
- Our RPC client's mocks now check for `.Get(0).(func(args) (any, error)` signatures where before they did not
  - I believe anyone using this would've hit a `.Error` further down after these changes, so hopefully this just fixes buggy behavior and does not cause any existing tests to fail
- Many funcs gained a `if len(ret) == 0 { panic(..) }` check
  - Since there's a `ret.Get(0)` immediately after which also panics, I suspect this just gives better error messages.
- Our mocks now have a `DoAndReturn` method
  - Since there are no interfaces for all this, this should be fine, ignoring reflection (which we must ignore or else we will go mad).

Otherwise seems like nothing exciting, and this does not affect any user-facing libraries or Go versions.
Since this needs a newer CI Go version to build, I've updated those references too.

---

Separately, this was the source of some rather disturbing TILs:
```bash
❯ bash -ec '
[[[ "$a" = "foo"]] && echo first
echo second
'
bash: line 2: [[[: command not found
second

❯ echo $?
0
```

Apparently syntax errors are (sometimes) not script failures, even with `set -e`.

And `sh` does not support `[[`, so it was _printing an error_ and continuing without erroring.  CI uses `sh`, locally we generally get bash or zsh, so a locally-working `[[` may be a remote-silently-failing command.

Madness.  Absolute madness.  This is going to haunt me for a while, unless I can find a way to prevent it (without shellcheck).
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.

3 participants