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

CI: test against go1.22 #1195

Merged
merged 2 commits into from
Apr 29, 2024
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
6 changes: 3 additions & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
strategy:
matrix:
os: ["ubuntu-latest", "windows-latest"]
go: ["1.20.x", "1.21.x"]
go: ["1.21.x", "1.22.x"]
Copy link

Choose a reason for hiding this comment

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

I recently learned a trick via uber-go/tally#258 (comment)


steps:
- name: Checkout code
Expand Down Expand Up @@ -52,7 +52,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.21.x
go-version: 1.22.x

- name: Test
run: make cover COVER_MODULES=./docs
Expand All @@ -68,7 +68,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.21.x
go-version: 1.22.x
cache: false # managed by golangci-lint

- uses: golangci/golangci-lint-action@v5
Expand Down
41 changes: 41 additions & 0 deletions app_121_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright (c) 2024 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

//go:build !go1.22
// +build !go1.22

package fx_test

import (
"testing"

"github.com/stretchr/testify/assert"

. "go.uber.org/fx"
)

func TestNopLoggerOptionString(t *testing.T) {
t.Parallel()

assert.Equal(t,
"fx.WithLogger(go.uber.org/fx.glob..func1())",
NopLogger.String(),
)
}
41 changes: 41 additions & 0 deletions app_122_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright (c) 2024 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

//go:build go1.22
// +build go1.22

package fx_test

import (
"testing"

"github.com/stretchr/testify/assert"

. "go.uber.org/fx"
)

func TestNopLoggerOptionString(t *testing.T) {
t.Parallel()

assert.Equal(t,
"fx.WithLogger(go.uber.org/fx.init.func1())",
NopLogger.String(),
)
}
5 changes: 0 additions & 5 deletions app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2542,11 +2542,6 @@ func TestOptionString(t *testing.T) {
give: WithLogger(func() fxevent.Logger { return testLogger{t} }),
want: "fx.WithLogger(go.uber.org/fx_test.TestOptionString.func3())",
},
{
desc: "NopLogger",
give: NopLogger,
want: "fx.WithLogger(go.uber.org/fx.glob..func1())",
},
{
desc: "ErrorHook",
give: ErrorHook(testErrorHandler{t}),
Expand Down
4 changes: 2 additions & 2 deletions internal/fxreflect/stack_121_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

//go:build go1.21
// +build go1.21
//go:build (go1.21 && !go1.22)
// +build go1.21,!go1.22

package fxreflect

Expand Down
50 changes: 50 additions & 0 deletions internal/fxreflect/stack_122_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright (c) 2023 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

//go:build go1.22
// +build go1.22

package fxreflect

import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestDeepStack(t *testing.T) {
t.Run("nest", func(t *testing.T) {
// Introduce a few frames.
frames := func() []Frame {
return func() []Frame {
return CallerStack(0, 0)
}()
}()

require.True(t, len(frames) > 3, "expected at least three frames")
for i, name := range []string{"func1.TestDeepStack.func1.1.2", "func1.1", "func1"} {
f := frames[i]
assert.Equal(t, "go.uber.org/fx/internal/fxreflect.TestDeepStack."+name, f.Function)
assert.Contains(t, f.File, "internal/fxreflect/stack_122_test.go")
assert.NotZero(t, f.Line)
}
})
}