Skip to content

Commit

Permalink
chore: bump go version to 1.24 (#833)
Browse files Browse the repository at this point in the history
  • Loading branch information
smsunarto authored Mar 8, 2025
1 parent 58d7567 commit f7a82c2
Show file tree
Hide file tree
Showing 84 changed files with 669 additions and 565 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci-go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
- "docs/**"

env:
GO_VERSION: 1.22.1
GO_VERSION: 1.24

permissions:
contents: read
Expand All @@ -22,7 +22,7 @@ jobs:
name: Lint (go)
runs-on: namespace-profile-linux-4vcpu-8gb-cached
env:
GO_VERSION: 1.22.1
GO_VERSION: 1.24
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -47,7 +47,7 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
with:
version: v1.62.2
version: latest
args: --timeout=10m -v ${{ steps.go-dir.outputs.path }}
## skip cache, use Namespace volume cache
skip-cache: true
Expand Down
267 changes: 136 additions & 131 deletions .golangci.yaml

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions assert/assert.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,21 +209,21 @@ func NotContains(t testify.TestingT, s, contains interface{}, msgAndArgs ...inte
}

func Subset(t testify.TestingT, list, subset interface{}, msgAndArgs ...interface{}) (ok bool) {
if ht, ok := t.(helperT); ok {
if ht, isHelperT := t.(helperT); isHelperT {
ht.Helper()
}
return testify.Subset(t, list, subset, msgAndArgs...)
}

func NotSubset(t testify.TestingT, list, subset interface{}, msgAndArgs ...interface{}) (ok bool) {
if ht, ok := t.(helperT); ok {
if ht, isHelperT := t.(helperT); isHelperT {
ht.Helper()
}
return testify.NotSubset(t, list, subset, msgAndArgs...)
}

func ElementsMatch(t testify.TestingT, listA, listB interface{}, msgAndArgs ...interface{}) (ok bool) {
if ht, ok := t.(helperT); ok {
if ht, isHelperT := t.(helperT); isHelperT {
ht.Helper()
}
return testify.ElementsMatch(t, listA, listB, msgAndArgs...)
Expand Down
2 changes: 1 addition & 1 deletion assert/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module pkg.world.dev/world-engine/assert

go 1.22.1
go 1.24

require (
github.com/rotisserie/eris v0.5.4
Expand Down
2 changes: 1 addition & 1 deletion cardinal/abi/abi.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func GenerateABIType(goStruct any) (*abi.Type, error) {

func getArgumentsForType(rt reflect.Type) ([]abi.ArgumentMarshaling, error) {
args := make([]abi.ArgumentMarshaling, 0, rt.NumField())
for i := 0; i < rt.NumField(); i++ {
for i := range rt.NumField() {
field := rt.Field(i)
kind := field.Type.Kind()
fieldType := field.Type.String()
Expand Down
4 changes: 1 addition & 3 deletions cardinal/cardinal.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,7 @@ func EachMessage[In any, Out any](wCtx WorldContext, fn func(TxData[In]) (Out, e
return nil
}

// RegisterMessage registers a message to the world. Cardinal will automatically set up HTTP routes that map to each
// registered message. Message URLs are take the form of "group.name". A default group, "game", is used
// unless the WithCustomMessageGroup option is used. Example: game.throw-rock
// unless the WithCustomMessageGroup option is used. Example: game.throw-rock.
func RegisterMessage[In any, Out any](world *World, name string, opts ...MessageOption[In, Out]) error {
if world.worldStage.Current() != worldstage.Init {
return eris.Errorf(
Expand Down
2 changes: 1 addition & 1 deletion cardinal/component/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"pkg.world.dev/world-engine/cardinal/types"
)

// Interface guard
// Interface guard.
var _ types.ComponentMetadata = (*componentMetadata[types.Component])(nil)

// Option is a type that can be passed to NewComponentMetadata to augment the creation
Expand Down
4 changes: 2 additions & 2 deletions cardinal/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const (
DefaultRedisAddress = "localhost:6379"
DefaultBaseShardSequencerAddress = "localhost:9601"

// Toml config file related
// Toml config file related.
configFilePathEnvVariable = "CARDINAL_CONFIG"
defaultConfigFileName = "world.toml"
)
Expand Down Expand Up @@ -215,7 +215,7 @@ func setupViper() {
val := reflect.ValueOf(&defaultConfig).Elem()
typ := val.Type()

for i := 0; i < val.NumField(); i++ {
for i := range val.NumField() {
field := typ.Field(i)
tag := field.Tag.Get("mapstructure")
if tag != "" {
Expand Down
2 changes: 1 addition & 1 deletion cardinal/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ func TestWorldConfig_loadWorldConfigUsingOverrideByenv(t *testing.T) {
assert.Equal(t, "my-world-env", cfg.CardinalNamespace)
}

// CleanupViper resets Viper configuration
// CleanupViper resets Viper configuration.
func CleanupViper(t *testing.T) {
viper.Reset()

Expand Down
4 changes: 1 addition & 3 deletions cardinal/filter/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ func MatchComponentMetadata(
return false
}

// CreateComponentMatcher creates a function given a slice of components. This function will
// take a parameter that is a single component and return true if it is in the slice of components
// or false otherwise
// or false otherwise.
func CreateComponentMatcher(components []types.Component) func(types.Component) bool {
mapStringToComponent := make(map[string]types.Component, len(components))
for _, component := range components {
Expand Down
13 changes: 6 additions & 7 deletions cardinal/gamestate/ecb_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package gamestate_test

import (
"context"
"runtime"
"testing"
"time"
Expand Down Expand Up @@ -81,7 +80,7 @@ func init() {

func TestCanCreateEntityAndSetComponent(t *testing.T) {
manager := newCmdBufferForTest(t)
ctx := context.Background()
ctx := t.Context()
wantValue := Foo{99}

id, err := manager.CreateEntity(fooComp)
Expand All @@ -104,7 +103,7 @@ func TestCanCreateEntityAndSetComponent(t *testing.T) {

func TestDiscardedComponentChangeRevertsToOriginalValue(t *testing.T) {
manager := newCmdBufferForTest(t)
ctx := context.Background()
ctx := t.Context()
wantValue := Foo{99}

id, err := manager.CreateEntity(fooComp)
Expand Down Expand Up @@ -135,7 +134,7 @@ func TestDiscardedComponentChangeRevertsToOriginalValue(t *testing.T) {

func TestDiscardedEntityIDsWillBeAssignedAgain(t *testing.T) {
manager := newCmdBufferForTest(t)
ctx := context.Background()
ctx := t.Context()

ids, err := manager.CreateManyEntities(10, fooComp)
assert.NilError(t, err)
Expand Down Expand Up @@ -245,7 +244,7 @@ func TestCannotRemoveAComponentFromAnEntityThatDoesNotHaveThatComponent(t *testi

func TestCanAddAComponentToAnEntity(t *testing.T) {
manager := newCmdBufferForTest(t)
ctx := context.Background()
ctx := t.Context()

id, err := manager.CreateEntity(fooComp)
assert.NilError(t, err)
Expand Down Expand Up @@ -572,7 +571,7 @@ func TestCannotSaveStateBeforeRegisteringComponents(t *testing.T) {
Password: "", // no password set
DB: 0, // use default DB
}
ctx := context.Background()
ctx := t.Context()

client := redis.NewClient(&options)
storage := gamestate.NewRedisPrimitiveStorage(client)
Expand All @@ -591,7 +590,7 @@ func TestCannotSaveStateBeforeRegisteringComponents(t *testing.T) {
// resources when processing the same amount of data.
func TestFinalizeTickPerformanceIsConsistent(t *testing.T) {
manager := newCmdBufferForTest(t)
ctx := context.Background()
ctx := t.Context()

// CreateAndFinalizeEntities cardinal.Creates some entities and then calls FinalizeTick. It returns the amount
// of time it took to execute FinalizeTick and how many bytes of memory were allocated during the call.
Expand Down
3 changes: 1 addition & 2 deletions cardinal/gamestate/primitivestorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import (
"context"
)

// PrimitiveStorage is the interface for all available stores related to the game loop
// there is another store like interface for other logistical values located in `ecs.storage`
// there is another store like interface for other logistical values located in `ecs.storage`.
type PrimitiveStorage[K comparable] interface {
GetFloat64(ctx context.Context, key K) (float64, error)
GetFloat32(ctx context.Context, key K) (float32, error)
Expand Down
13 changes: 6 additions & 7 deletions cardinal/gamestate/read_only_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package gamestate_test

import (
"context"
"testing"

"pkg.world.dev/world-engine/assert"
Expand All @@ -12,7 +11,7 @@ import (

func TestReadOnly_CanGetComponent(t *testing.T) {
manager := newCmdBufferForTest(t)
ctx := context.Background()
ctx := t.Context()

id, err := manager.CreateEntity(fooComp)
assert.NilError(t, err)
Expand All @@ -34,7 +33,7 @@ func TestReadOnly_CanGetComponent(t *testing.T) {

func TestReadOnly_CanGetComponentTypesForEntityAndArchID(t *testing.T) {
manager := newCmdBufferForTest(t)
ctx := context.Background()
ctx := t.Context()

testCases := []struct {
name string
Expand Down Expand Up @@ -81,7 +80,7 @@ func TestReadOnly_CanGetComponentTypesForEntityAndArchID(t *testing.T) {

func TestReadOnly_GetEntitiesForArchID(t *testing.T) {
manager := newCmdBufferForTest(t)
ctx := context.Background()
ctx := t.Context()
testCases := []struct {
name string
idsToCreate int
Expand Down Expand Up @@ -121,7 +120,7 @@ func TestReadOnly_GetEntitiesForArchID(t *testing.T) {

func TestReadOnly_CanFindEntityIDAfterChangingArchetypes(t *testing.T) {
manager := newCmdBufferForTest(t)
ctx := context.Background()
ctx := t.Context()
id, err := manager.CreateEntity(fooComp)
assert.NilError(t, err)
assert.NilError(t, manager.FinalizeTick(ctx))
Expand Down Expand Up @@ -155,7 +154,7 @@ func TestReadOnly_CanFindEntityIDAfterChangingArchetypes(t *testing.T) {

func TestReadOnly_ArchetypeCount(t *testing.T) {
manager := newCmdBufferForTest(t)
ctx := context.Background()
ctx := t.Context()
roManager := manager.ToReadOnly()

// No archetypes have been cardinal.Created yet
Expand All @@ -179,7 +178,7 @@ func TestReadOnly_ArchetypeCount(t *testing.T) {

func TestReadOnly_SearchFrom(t *testing.T) {
manager := newCmdBufferForTest(t)
ctx := context.Background()
ctx := t.Context()

tf := cardinal.NewTestFixture(t, nil, cardinal.WithStoreManager(manager))
world := tf.World
Expand Down
25 changes: 12 additions & 13 deletions cardinal/gamestate/recovery_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package gamestate_test

import (
"context"
"testing"

"pkg.world.dev/world-engine/assert"
Expand All @@ -11,7 +10,7 @@ import (

func TestLoadingFromRedisShouldNotRepeatEntityIDs(t *testing.T) {
manager, client := newCmdBufferAndRedisClientForTest(t, nil)
ctx := context.Background()
ctx := t.Context()

ids, err := manager.CreateManyEntities(50, fooComp)
assert.NilError(t, err)
Expand All @@ -29,7 +28,7 @@ func TestLoadingFromRedisShouldNotRepeatEntityIDs(t *testing.T) {

func TestComponentSetsCanBeRecovered(t *testing.T) {
manager, client := newCmdBufferAndRedisClientForTest(t, nil)
ctx := context.Background()
ctx := t.Context()

firstID, err := manager.CreateEntity(barComp)
assert.NilError(t, err)
Expand Down Expand Up @@ -65,7 +64,7 @@ func getArchIDForEntity(t *testing.T, m *gamestate.EntityCommandBuffer, id types

func TestComponentSetsAreRememberedFromPreviousDB(t *testing.T) {
manager, client := newCmdBufferAndRedisClientForTest(t, nil)
ctx := context.Background()
ctx := t.Context()

_, err := manager.CreateEntity(barComp)
assert.NilError(t, err)
Expand All @@ -86,7 +85,7 @@ func TestComponentSetsAreRememberedFromPreviousDB(t *testing.T) {

func TestAddedComponentsCanBeDiscarded(t *testing.T) {
manager := newCmdBufferForTest(t)
ctx := context.Background()
ctx := t.Context()

id, err := manager.CreateEntity(fooComp)
assert.NilError(t, err)
Expand All @@ -113,7 +112,7 @@ func TestAddedComponentsCanBeDiscarded(t *testing.T) {

func TestCanGetComponentTypesAfterReload(t *testing.T) {
manager, client := newCmdBufferAndRedisClientForTest(t, nil)
ctx := context.Background()
ctx := t.Context()

var id types.EntityID
_, err := manager.CreateEntity(fooComp)
Expand All @@ -132,7 +131,7 @@ func TestCanGetComponentTypesAfterReload(t *testing.T) {

func TestCanDiscardPreviouslyAddedComponent(t *testing.T) {
manager := newCmdBufferForTest(t)
ctx := context.Background()
ctx := t.Context()

id, err := manager.CreateEntity(fooComp)
assert.NilError(t, err)
Expand All @@ -151,7 +150,7 @@ func TestCanDiscardPreviouslyAddedComponent(t *testing.T) {

func TestEntitiesCanBeFetchedAfterReload(t *testing.T) {
manager, client := newCmdBufferAndRedisClientForTest(t, nil)
ctx := context.Background()
ctx := t.Context()

ids, err := manager.CreateManyEntities(10, fooComp, barComp)
assert.NilError(t, err)
Expand All @@ -177,7 +176,7 @@ func TestEntitiesCanBeFetchedAfterReload(t *testing.T) {

func TestTheRemovalOfEntitiesCanBeDiscarded(t *testing.T) {
manager := newCmdBufferForTest(t)
ctx := context.Background()
ctx := t.Context()

ids, err := manager.CreateManyEntities(10, fooComp)
assert.NilError(t, err)
Expand Down Expand Up @@ -211,7 +210,7 @@ func TestTheRemovalOfEntitiesCanBeDiscarded(t *testing.T) {

func TestTheRemovalOfEntitiesIsRememberedAfterReload(t *testing.T) {
manager, client := newCmdBufferAndRedisClientForTest(t, nil)
ctx := context.Background()
ctx := t.Context()

startingIDs, err := manager.CreateManyEntities(10, fooComp, barComp)
assert.NilError(t, err)
Expand Down Expand Up @@ -239,7 +238,7 @@ func TestTheRemovalOfEntitiesIsRememberedAfterReload(t *testing.T) {

func TestRemovedComponentDataCanBeRecovered(t *testing.T) {
manager := newCmdBufferForTest(t)
ctx := context.Background()
ctx := t.Context()

id, err := manager.CreateEntity(fooComp, barComp)
assert.NilError(t, err)
Expand Down Expand Up @@ -268,7 +267,7 @@ func TestRemovedComponentDataCanBeRecovered(t *testing.T) {

func TestArchetypeCountTracksDiscardedChanges(t *testing.T) {
manager := newCmdBufferForTest(t)
ctx := context.Background()
ctx := t.Context()

_, err := manager.CreateEntity(fooComp)
assert.NilError(t, err)
Expand All @@ -289,7 +288,7 @@ func TestArchetypeCountTracksDiscardedChanges(t *testing.T) {

func TestCannotFetchComponentOnRemovedEntityAfterCommit(t *testing.T) {
manager := newCmdBufferForTest(t)
ctx := context.Background()
ctx := t.Context()

id, err := manager.CreateEntity(fooComp, barComp)
assert.NilError(t, err)
Expand Down
3 changes: 1 addition & 2 deletions cardinal/gamestate/redis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package gamestate
// internal state of redis is correct, so they need access to the package private methods in keys.go.

import (
"context"
"testing"

"github.com/alicebob/miniredis/v2"
Expand All @@ -28,7 +27,7 @@ func (b Beta) Name() string {
}

func TestComponentValuesAreDeletedFromRedis(t *testing.T) {
ctx := context.Background()
ctx := t.Context()
s := miniredis.RunT(t)
options := redis.Options{
Addr: s.Addr(),
Expand Down
Loading

0 comments on commit f7a82c2

Please sign in to comment.