From c45657721ffc2f491a6023e33877047c2dbddb9d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 25 Apr 2025 15:55:30 +0300 Subject: [PATCH] fix(deps): update golang-packages (#5121) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Robert Kaussow --- cli/exec/metadata_test.go | 12 +++---- cli/pipeline/list_test.go | 2 +- cli/pipeline/pipeline_test.go | 2 +- cli/pipeline/purge_test.go | 2 +- cli/repo/repo_show_test.go | 2 +- cli/repo/repo_test.go | 2 +- cli/update/updater_test.go | 5 ++- go.mod | 18 +++++------ go.sum | 31 ++++++++++--------- pipeline/backend/dummy/dummy_test.go | 3 +- server/cron/cron_test.go | 3 +- server/forge/bitbucket/bitbucket_test.go | 3 +- .../bitbucketdatacenter_test.go | 3 +- .../internal/client_test.go | 3 +- server/forge/forgejo/forgejo_test.go | 3 +- server/forge/gitea/gitea_test.go | 3 +- server/forge/github/github_test.go | 3 +- server/forge/gitlab/convert.go | 4 +-- server/forge/gitlab/gitlab_test.go | 3 +- server/grpc/rpc_test.go | 5 ++- server/logging/log_test.go | 2 +- server/pubsub/pub_test.go | 2 +- server/queue/fifo_test.go | 28 ++++++++--------- server/services/config/combined_test.go | 3 +- server/services/config/forge_test.go | 3 +- .../datastore/migration/migration_test.go | 5 ++- 26 files changed, 72 insertions(+), 83 deletions(-) diff --git a/cli/exec/metadata_test.go b/cli/exec/metadata_test.go index 481f0105f..ae28ca014 100644 --- a/cli/exec/metadata_test.go +++ b/cli/exec/metadata_test.go @@ -42,7 +42,7 @@ func TestMetadataFromContext(t *testing.T) { return nil }, } - assert.NoError(t, c.Run(context.Background(), []string{"woodpecker-cli"})) + assert.NoError(t, c.Run(t.Context(), []string{"woodpecker-cli"})) } t.Run("LoadFromFile", func(t *testing.T) { @@ -55,7 +55,7 @@ func TestMetadataFromContext(t *testing.T) { runCommand(flags, func(c *cli.Command) { _ = c.Set("metadata-file", tempFileName) - m, err := metadataFromContext(context.Background(), c, nil, nil) + m, err := metadataFromContext(t.Context(), c, nil, nil) require.NoError(t, err) assert.Equal(t, "test-repo", m.Repo.Name) assert.Equal(t, int64(5), m.Curr.Number) @@ -76,7 +76,7 @@ func TestMetadataFromContext(t *testing.T) { _ = c.Set("repo-name", "aUser/override-repo") _ = c.Set("pipeline-number", "10") - m, err := metadataFromContext(context.Background(), c, nil, nil) + m, err := metadataFromContext(t.Context(), c, nil, nil) require.NoError(t, err) assert.Equal(t, "override-repo", m.Repo.Name) assert.Equal(t, int64(10), m.Curr.Number) @@ -98,7 +98,7 @@ func TestMetadataFromContext(t *testing.T) { runCommand(flags, func(c *cli.Command) { _ = c.Set("metadata-file", tempFile.Name()) - _, err = metadataFromContext(context.Background(), c, nil, nil) + _, err = metadataFromContext(t.Context(), c, nil, nil) assert.Error(t, err) }) }) @@ -110,7 +110,7 @@ func TestMetadataFromContext(t *testing.T) { } runCommand(flags, func(c *cli.Command) { - m, err := metadataFromContext(context.Background(), c, nil, nil) + m, err := metadataFromContext(t.Context(), c, nil, nil) require.NoError(t, err) if assert.NotNil(t, m) { assert.Equal(t, "test", m.Repo.Owner) @@ -123,7 +123,7 @@ func TestMetadataFromContext(t *testing.T) { t.Run("MatrixAxis", func(t *testing.T) { runCommand([]cli.Flag{}, func(c *cli.Command) { axis := matrix.Axis{"go": "1.16", "os": "linux"} - m, err := metadataFromContext(context.Background(), c, axis, nil) + m, err := metadataFromContext(t.Context(), c, axis, nil) require.NoError(t, err) assert.EqualValues(t, map[string]string{"go": "1.16", "os": "linux"}, m.Workflow.Matrix) }) diff --git a/cli/pipeline/list_test.go b/cli/pipeline/list_test.go index 969e06794..a93b31309 100644 --- a/cli/pipeline/list_test.go +++ b/cli/pipeline/list_test.go @@ -92,7 +92,7 @@ func TestPipelineList(t *testing.T) { return nil } - _ = command.Run(context.Background(), tt.args) + _ = command.Run(t.Context(), tt.args) }) } } diff --git a/cli/pipeline/pipeline_test.go b/cli/pipeline/pipeline_test.go index 5238a19fe..3cf14ee26 100644 --- a/cli/pipeline/pipeline_test.go +++ b/cli/pipeline/pipeline_test.go @@ -80,7 +80,7 @@ func TestPipelineOutput(t *testing.T) { }, } - _ = command.Run(context.Background(), tt.args) + _ = command.Run(t.Context(), tt.args) }) } } diff --git a/cli/pipeline/purge_test.go b/cli/pipeline/purge_test.go index b6e285492..8761d0276 100644 --- a/cli/pipeline/purge_test.go +++ b/cli/pipeline/purge_test.go @@ -120,7 +120,7 @@ func TestPipelinePurge(t *testing.T) { return nil } - _ = command.Run(context.Background(), tt.args) + _ = command.Run(t.Context(), tt.args) }) } } diff --git a/cli/repo/repo_show_test.go b/cli/repo/repo_show_test.go index 29ae822e0..4d4ce42ec 100644 --- a/cli/repo/repo_show_test.go +++ b/cli/repo/repo_show_test.go @@ -66,7 +66,7 @@ func TestRepoShow(t *testing.T) { return nil } - _ = command.Run(context.Background(), tt.args) + _ = command.Run(t.Context(), tt.args) }) } } diff --git a/cli/repo/repo_test.go b/cli/repo/repo_test.go index 82fc616a0..bdf17e892 100644 --- a/cli/repo/repo_test.go +++ b/cli/repo/repo_test.go @@ -79,7 +79,7 @@ func TestRepoOutput(t *testing.T) { }, } - _ = command.Run(context.Background(), tt.args) + _ = command.Run(t.Context(), tt.args) }) } } diff --git a/cli/update/updater_test.go b/cli/update/updater_test.go index 9de9001af..bb082a799 100644 --- a/cli/update/updater_test.go +++ b/cli/update/updater_test.go @@ -1,7 +1,6 @@ package update import ( - "context" "io" "net/http" "net/http/httptest" @@ -24,7 +23,7 @@ func TestCheckForUpdate(t *testing.T) { ts := httptest.NewServer(http.HandlerFunc(fixtureHandler)) defer ts.Close() - newVersion, err := checkForUpdate(context.Background(), ts.URL+"/version.json", false) + newVersion, err := checkForUpdate(t.Context(), ts.URL+"/version.json", false) if err != nil { t.Fatalf("Failed to check for updates: %v", err) } @@ -48,7 +47,7 @@ func TestDownloadNewVersion(t *testing.T) { ts := httptest.NewServer(http.HandlerFunc(fixtureHandler)) defer ts.Close() - file, err := downloadNewVersion(context.Background(), ts.URL+downloadFilePath) + file, err := downloadNewVersion(t.Context(), ts.URL+downloadFilePath) if err != nil { t.Fatalf("Failed to download new version: %v", err) } diff --git a/go.mod b/go.mod index 8193dd545..7386c21b0 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module go.woodpecker-ci.org/woodpecker/v3 -go 1.23.4 +go 1.24.0 require ( al.essio.dev/pkg/shellescape v1.6.0 @@ -56,7 +56,7 @@ require ( github.com/xeipuuv/gojsonschema v1.2.0 github.com/yaronf/httpsign v0.3.2 github.com/zalando/go-keyring v0.2.6 - gitlab.com/gitlab-org/api/client-go v0.127.0 + gitlab.com/gitlab-org/api/client-go v0.128.0 go.uber.org/multierr v1.11.0 golang.org/x/crypto v0.37.0 golang.org/x/net v0.39.0 @@ -67,9 +67,9 @@ require ( google.golang.org/grpc v1.72.0 google.golang.org/protobuf v1.36.6 gopkg.in/yaml.v3 v3.0.1 - k8s.io/api v0.32.3 - k8s.io/apimachinery v0.32.3 - k8s.io/client-go v0.32.3 + k8s.io/api v0.33.0 + k8s.io/apimachinery v0.33.0 + k8s.io/client-go v0.33.0 src.techknowlogick.com/xormigrate v1.7.1 xorm.io/builder v0.3.13 xorm.io/xorm v1.3.9 @@ -129,10 +129,9 @@ require ( github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/golang/snappy v0.0.4 // indirect - github.com/google/gnostic-models v0.6.8 // indirect + github.com/google/gnostic-models v0.6.9 // indirect github.com/google/go-cmp v0.7.0 // indirect github.com/google/go-querystring v1.1.0 // indirect - github.com/google/gofuzz v1.2.0 // indirect github.com/google/uuid v1.6.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-retryablehttp v0.7.7 // indirect @@ -207,9 +206,10 @@ require ( gopkg.in/inf.v0 v0.9.1 // indirect gotest.tools/v3 v3.4.0 // indirect k8s.io/klog/v2 v2.130.1 // indirect - k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect + k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff // indirect k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect + sigs.k8s.io/randfill v1.0.0 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/go.sum b/go.sum index 7f33e72b7..8330c0c16 100644 --- a/go.sum +++ b/go.sum @@ -237,8 +237,8 @@ github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8l github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= -github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= +github.com/google/gnostic-models v0.6.9 h1:MU/8wDLif2qCXZmzncUQ/BOfxWfthHi63KqpoNbWqVw= +github.com/google/gnostic-models v0.6.9/go.mod h1:CiWsm0s6BSQd1hRn8/QmxqB6BesYcbSZxsz9b0KuDBw= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -573,8 +573,8 @@ github.com/zalando/go-keyring v0.2.6 h1:r7Yc3+H+Ux0+M72zacZoItR3UDxeWfKTcabvkI8u github.com/zalando/go-keyring v0.2.6/go.mod h1:2TCrxYrbUNYfNS/Kgy/LSrkSQzZ5UPVH85RwfczwvcI= github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0= -gitlab.com/gitlab-org/api/client-go v0.127.0 h1:8xnxcNKGF2gDazEoMs+hOZfOspSSw8D0vAoWhQk9U+U= -gitlab.com/gitlab-org/api/client-go v0.127.0/go.mod h1:bYC6fPORKSmtuPRyD9Z2rtbAjE7UeNatu2VWHRf4/LE= +gitlab.com/gitlab-org/api/client-go v0.128.0 h1:Wvy1UIuluKemubao2k8EOqrl3gbgJ1PVifMIQmg2Da4= +gitlab.com/gitlab-org/api/client-go v0.128.0/go.mod h1:bYC6fPORKSmtuPRyD9Z2rtbAjE7UeNatu2VWHRf4/LE= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 h1:TT4fX+nBOA/+LUkobKGW1ydGcn+G3vRw9+g5HwCphpk= @@ -781,16 +781,16 @@ gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools/v3 v3.4.0 h1:ZazjZUfuVeZGLAmlKKuyv3IKP5orXcwtOwDQH6YVr6o= gotest.tools/v3 v3.4.0/go.mod h1:CtbdzLSsqVhDgMtKsx03ird5YTGB3ar27v0u/yKBW5g= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -k8s.io/api v0.32.3 h1:Hw7KqxRusq+6QSplE3NYG4MBxZw1BZnq4aP4cJVINls= -k8s.io/api v0.32.3/go.mod h1:2wEDTXADtm/HA7CCMD8D8bK4yuBUptzaRhYcYEEYA3k= -k8s.io/apimachinery v0.32.3 h1:JmDuDarhDmA/Li7j3aPrwhpNBA94Nvk5zLeOge9HH1U= -k8s.io/apimachinery v0.32.3/go.mod h1:GpHVgxoKlTxClKcteaeuF1Ul/lDVb74KpZcxcmLDElE= -k8s.io/client-go v0.32.3 h1:RKPVltzopkSgHS7aS98QdscAgtgah/+zmpAogooIqVU= -k8s.io/client-go v0.32.3/go.mod h1:3v0+3k4IcT9bXTc4V2rt+d2ZPPG700Xy6Oi0Gdl2PaY= +k8s.io/api v0.33.0 h1:yTgZVn1XEe6opVpP1FylmNrIFWuDqe2H0V8CT5gxfIU= +k8s.io/api v0.33.0/go.mod h1:CTO61ECK/KU7haa3qq8sarQ0biLq2ju405IZAd9zsiM= +k8s.io/apimachinery v0.33.0 h1:1a6kHrJxb2hs4t8EE5wuR/WxKDwGN1FKH3JvDtA0CIQ= +k8s.io/apimachinery v0.33.0/go.mod h1:BHW0YOu7n22fFv/JkYOEfkUYNRN0fj0BlvMFWA7b+SM= +k8s.io/client-go v0.33.0 h1:UASR0sAYVUzs2kYuKn/ZakZlcs2bEHaizrrHUZg0G98= +k8s.io/client-go v0.33.0/go.mod h1:kGkd+l/gNGg8GYWAPr0xF1rRKvVWvzh9vmZAMXtaKOg= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f h1:GA7//TjRY9yWGy1poLzYYJJ4JRdzg3+O6e8I+e+8T5Y= -k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f/go.mod h1:R/HEjbvWI0qdfb8viZUeVZm0X6IZnxAydC7YU42CMw4= +k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff h1:/usPimJzUKKu+m+TE36gUyGcf03XZEP0ZIKgKj35LS4= +k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= lukechampine.com/uint128 v1.1.1/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= @@ -834,8 +834,11 @@ nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYm rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA= -sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4= +sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= +sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= src.techknowlogick.com/xormigrate v1.7.1 h1:RKGLLUAqJ+zO8iZ7eOc7oLH7f0cs2gfXSZSvBRBHnlY= diff --git a/pipeline/backend/dummy/dummy_test.go b/pipeline/backend/dummy/dummy_test.go index 44e4034ae..c0d78d656 100644 --- a/pipeline/backend/dummy/dummy_test.go +++ b/pipeline/backend/dummy/dummy_test.go @@ -15,7 +15,6 @@ package dummy_test import ( - "context" "io" "testing" @@ -27,7 +26,7 @@ import ( func TestSmalPipelineDummyRun(t *testing.T) { dummyEngine := dummy.New() - ctx := context.Background() + ctx := t.Context() assert.True(t, dummyEngine.IsAvailable(ctx)) assert.EqualValues(t, "dummy", dummyEngine.Name()) diff --git a/server/cron/cron_test.go b/server/cron/cron_test.go index ca39839f1..76876ead9 100644 --- a/server/cron/cron_test.go +++ b/server/cron/cron_test.go @@ -15,7 +15,6 @@ package cron import ( - "context" "testing" "time" @@ -33,7 +32,7 @@ func TestCreatePipeline(t *testing.T) { _manager := mocks_manager.NewManager(t) _forge := mocks_forge.NewForge(t) store := mocks_store.NewStore(t) - ctx := context.Background() + ctx := t.Context() creator := &model.User{ ID: 1, diff --git a/server/forge/bitbucket/bitbucket_test.go b/server/forge/bitbucket/bitbucket_test.go index 9263f61f0..c6479d47f 100644 --- a/server/forge/bitbucket/bitbucket_test.go +++ b/server/forge/bitbucket/bitbucket_test.go @@ -17,7 +17,6 @@ package bitbucket import ( "bytes" - "context" "net/http" "net/http/httptest" "testing" @@ -48,7 +47,7 @@ func TestBitbucket(t *testing.T) { defer s.Close() c := &config{url: s.URL, API: s.URL} - ctx := context.Background() + ctx := t.Context() forge, _ := New(&Opts{}) netrc, _ := forge.Netrc(fakeUser, fakeRepo) diff --git a/server/forge/bitbucketdatacenter/bitbucketdatacenter_test.go b/server/forge/bitbucketdatacenter/bitbucketdatacenter_test.go index b85c1ebd3..3c960c1df 100644 --- a/server/forge/bitbucketdatacenter/bitbucketdatacenter_test.go +++ b/server/forge/bitbucketdatacenter/bitbucketdatacenter_test.go @@ -15,7 +15,6 @@ package bitbucketdatacenter import ( - "context" "testing" "time" @@ -57,7 +56,7 @@ func TestBitbucketDC(t *testing.T) { urlAPI: s.URL, } - ctx := context.Background() + ctx := t.Context() repo, err := c.Repo(ctx, fakeUser, model.ForgeRemoteID("1234"), "PRJ", "repo-slug") assert.NoError(t, err) diff --git a/server/forge/bitbucketdatacenter/internal/client_test.go b/server/forge/bitbucketdatacenter/internal/client_test.go index 94f01f084..490b611e5 100644 --- a/server/forge/bitbucketdatacenter/internal/client_test.go +++ b/server/forge/bitbucketdatacenter/internal/client_test.go @@ -15,7 +15,6 @@ package internal import ( - "context" "net/http" "net/http/httptest" "testing" @@ -32,7 +31,7 @@ func TestCurrentUser(t *testing.T) { defer s.Close() - ctx := context.Background() + ctx := t.Context() ts := mockSource("bearer-token") client := NewClientWithToken(ctx, ts, s.URL) uid, err := client.FindCurrentUser(ctx) diff --git a/server/forge/forgejo/forgejo_test.go b/server/forge/forgejo/forgejo_test.go index 1ed99e16d..d1a66ee55 100644 --- a/server/forge/forgejo/forgejo_test.go +++ b/server/forge/forgejo/forgejo_test.go @@ -16,7 +16,6 @@ package forgejo import ( "bytes" - "context" "net/http" "net/http/httptest" "testing" @@ -53,7 +52,7 @@ func Test_forgejo(t *testing.T) { }) mockStore := mocks_store.NewStore(t) - ctx := store.InjectToContext(context.Background(), mockStore) + ctx := store.InjectToContext(t.Context(), mockStore) t.Run("netrc with user token", func(t *testing.T) { forge, _ := New(Opts{}) diff --git a/server/forge/gitea/gitea_test.go b/server/forge/gitea/gitea_test.go index 02b868351..5f7f6053b 100644 --- a/server/forge/gitea/gitea_test.go +++ b/server/forge/gitea/gitea_test.go @@ -17,7 +17,6 @@ package gitea import ( "bytes" - "context" "net/http" "net/http/httptest" "testing" @@ -54,7 +53,7 @@ func Test_gitea(t *testing.T) { }) mockStore := mocks_store.NewStore(t) - ctx := store.InjectToContext(context.Background(), mockStore) + ctx := store.InjectToContext(t.Context(), mockStore) t.Run("netrc with user token", func(t *testing.T) { forge, _ := New(Opts{}) diff --git a/server/forge/github/github_test.go b/server/forge/github/github_test.go index 340cc330d..fbf5f47a6 100644 --- a/server/forge/github/github_test.go +++ b/server/forge/github/github_test.go @@ -16,7 +16,6 @@ package github import ( - "context" "net/http/httptest" "testing" @@ -53,7 +52,7 @@ func Test_github(t *testing.T) { defer s.Close() - ctx := context.Background() + ctx := t.Context() t.Run("netrc with user token", func(t *testing.T) { forge, _ := New(Opts{}) diff --git a/server/forge/gitlab/convert.go b/server/forge/gitlab/convert.go index c8ccdc119..fc1af6929 100644 --- a/server/forge/gitlab/convert.go +++ b/server/forge/gitlab/convert.go @@ -21,7 +21,7 @@ import ( "net/http" "strings" - "gitlab.com/gitlab-org/api/client-go" + gitlab "gitlab.com/gitlab-org/api/client-go" "go.woodpecker-ci.org/woodpecker/v3/server/model" "go.woodpecker-ci.org/woodpecker/v3/shared/utils" @@ -53,7 +53,7 @@ func (g *GitLab) convertGitLabRepo(_repo *gitlab.Project, projectMember *gitlab. Push: isWrite(projectMember), Admin: isAdmin(projectMember), }, - PREnabled: _repo.MergeRequestsEnabled, + PREnabled: _repo.MergeRequestsAccessLevel != gitlab.DisabledAccessControl, } if len(repo.Avatar) != 0 && !strings.HasPrefix(repo.Avatar, "http") { diff --git a/server/forge/gitlab/gitlab_test.go b/server/forge/gitlab/gitlab_test.go index 876696ca7..90668ae26 100644 --- a/server/forge/gitlab/gitlab_test.go +++ b/server/forge/gitlab/gitlab_test.go @@ -17,7 +17,6 @@ package gitlab import ( "bytes" - "context" "net/http" "net/url" "strconv" @@ -68,7 +67,7 @@ func Test_GitLab(t *testing.T) { Owner: "diaspora", } - ctx := context.Background() + ctx := t.Context() // Test projects method t.Run("Should return only non-archived projects is hidden", func(t *testing.T) { client.HideArchives = true diff --git a/server/grpc/rpc_test.go b/server/grpc/rpc_test.go index 798c39e35..af287fa61 100644 --- a/server/grpc/rpc_test.go +++ b/server/grpc/rpc_test.go @@ -15,7 +15,6 @@ package grpc import ( - "context" "testing" "time" @@ -54,7 +53,7 @@ func TestRegisterAgent(t *testing.T) { store: store, } ctx := metadata.NewIncomingContext( - context.Background(), + t.Context(), metadata.Pairs("hostname", "hostname", "agent_id", "1337"), ) agentID, err := grpc.RegisterAgent(ctx, rpc.AgentInfo{ @@ -96,7 +95,7 @@ func TestRegisterAgent(t *testing.T) { store: store, } ctx := metadata.NewIncomingContext( - context.Background(), + t.Context(), metadata.Pairs("hostname", "newHostname", "agent_id", "1337"), ) agentID, err := grpc.RegisterAgent(ctx, rpc.AgentInfo{ diff --git a/server/logging/log_test.go b/server/logging/log_test.go index 52020e6cc..28a4d9ffe 100644 --- a/server/logging/log_test.go +++ b/server/logging/log_test.go @@ -36,7 +36,7 @@ func TestLogging(t *testing.T) { ) ctx, cancel := context.WithCancelCause( - context.Background(), + t.Context(), ) receiver := make(LogChan, 10) diff --git a/server/pubsub/pub_test.go b/server/pubsub/pub_test.go index a8af81ede..b18d34793 100644 --- a/server/pubsub/pub_test.go +++ b/server/pubsub/pub_test.go @@ -33,7 +33,7 @@ func TestPubsub(t *testing.T) { ) ctx, cancel := context.WithCancelCause( - context.Background(), + t.Context(), ) broker := New() diff --git a/server/queue/fifo_test.go b/server/queue/fifo_test.go index c25d4a966..a2d37d152 100644 --- a/server/queue/fifo_test.go +++ b/server/queue/fifo_test.go @@ -39,7 +39,7 @@ var ( ) func TestFifo(t *testing.T) { - ctx, cancel := context.WithCancelCause(context.Background()) + ctx, cancel := context.WithCancelCause(t.Context()) t.Cleanup(func() { cancel(nil) }) q := NewMemoryQueue(ctx) @@ -68,7 +68,7 @@ func TestFifo(t *testing.T) { } func TestFifoExpire(t *testing.T) { - ctx, cancel := context.WithCancelCause(context.Background()) + ctx, cancel := context.WithCancelCause(t.Context()) t.Cleanup(func() { cancel(nil) }) q, _ := NewMemoryQueue(ctx).(*fifo) @@ -92,7 +92,7 @@ func TestFifoExpire(t *testing.T) { } func TestFifoWait(t *testing.T) { - ctx, cancel := context.WithCancelCause(context.Background()) + ctx, cancel := context.WithCancelCause(t.Context()) t.Cleanup(func() { cancel(nil) }) q, _ := NewMemoryQueue(ctx).(*fifo) @@ -120,7 +120,7 @@ func TestFifoWait(t *testing.T) { } func TestFifoEvict(t *testing.T) { - ctx, cancel := context.WithCancelCause(context.Background()) + ctx, cancel := context.WithCancelCause(t.Context()) t.Cleanup(func() { cancel(nil) }) q := NewMemoryQueue(ctx) @@ -144,7 +144,7 @@ func TestFifoEvict(t *testing.T) { } func TestFifoDependencies(t *testing.T) { - ctx, cancel := context.WithCancelCause(context.Background()) + ctx, cancel := context.WithCancelCause(t.Context()) t.Cleanup(func() { cancel(nil) }) task1 := genDummyTask() @@ -174,7 +174,7 @@ func TestFifoDependencies(t *testing.T) { } func TestFifoErrors(t *testing.T) { - ctx, cancel := context.WithCancelCause(context.Background()) + ctx, cancel := context.WithCancelCause(t.Context()) t.Cleanup(func() { cancel(nil) }) task1 := genDummyTask() @@ -216,7 +216,7 @@ func TestFifoErrors(t *testing.T) { } func TestFifoErrors2(t *testing.T) { - ctx, cancel := context.WithCancelCause(context.Background()) + ctx, cancel := context.WithCancelCause(t.Context()) t.Cleanup(func() { cancel(nil) }) task1 := genDummyTask() @@ -256,7 +256,7 @@ func TestFifoErrors2(t *testing.T) { } func TestFifoErrorsMultiThread(t *testing.T) { - ctx, cancel := context.WithCancelCause(context.Background()) + ctx, cancel := context.WithCancelCause(t.Context()) t.Cleanup(func() { cancel(nil) }) task1 := genDummyTask() @@ -348,7 +348,7 @@ func TestFifoErrorsMultiThread(t *testing.T) { } func TestFifoTransitiveErrors(t *testing.T) { - ctx, cancel := context.WithCancelCause(context.Background()) + ctx, cancel := context.WithCancelCause(t.Context()) t.Cleanup(func() { cancel(nil) }) task1 := genDummyTask() @@ -389,7 +389,7 @@ func TestFifoTransitiveErrors(t *testing.T) { } func TestFifoCancel(t *testing.T) { - ctx, cancel := context.WithCancelCause(context.Background()) + ctx, cancel := context.WithCancelCause(t.Context()) t.Cleanup(func() { cancel(nil) }) task1 := genDummyTask() @@ -425,7 +425,7 @@ func TestFifoCancel(t *testing.T) { } func TestFifoPause(t *testing.T) { - ctx, cancel := context.WithCancelCause(context.Background()) + ctx, cancel := context.WithCancelCause(t.Context()) t.Cleanup(func() { cancel(nil) }) q, _ := NewMemoryQueue(ctx).(*fifo) @@ -458,7 +458,7 @@ func TestFifoPause(t *testing.T) { } func TestFifoPauseResume(t *testing.T) { - ctx, cancel := context.WithCancelCause(context.Background()) + ctx, cancel := context.WithCancelCause(t.Context()) t.Cleanup(func() { cancel(nil) }) q, _ := NewMemoryQueue(ctx).(*fifo) @@ -474,7 +474,7 @@ func TestFifoPauseResume(t *testing.T) { } func TestWaitingVsPending(t *testing.T) { - ctx, cancel := context.WithCancelCause(context.Background()) + ctx, cancel := context.WithCancelCause(t.Context()) t.Cleanup(func() { cancel(nil) }) task1 := genDummyTask() @@ -583,7 +583,7 @@ func TestShouldRun(t *testing.T) { } func TestFifoWithScoring(t *testing.T) { - ctx, cancel := context.WithCancelCause(context.Background()) + ctx, cancel := context.WithCancelCause(t.Context()) t.Cleanup(func() { cancel(nil) }) q := NewMemoryQueue(ctx) diff --git a/server/services/config/combined_test.go b/server/services/config/combined_test.go index 6097f9805..46d9b868d 100644 --- a/server/services/config/combined_test.go +++ b/server/services/config/combined_test.go @@ -15,7 +15,6 @@ package config_test import ( - "context" "crypto/ed25519" "crypto/rand" "encoding/json" @@ -218,7 +217,7 @@ func TestFetchFromConfigService(t *testing.T) { forgeFetcher := config.NewForge(time.Second*3, 3) configFetcher := config.NewCombined(forgeFetcher, httpFetcher) files, err := configFetcher.Fetch( - context.Background(), + t.Context(), f, &model.User{AccessToken: "xxx"}, repo, diff --git a/server/services/config/forge_test.go b/server/services/config/forge_test.go index 898d511e4..dfcb75f6d 100644 --- a/server/services/config/forge_test.go +++ b/server/services/config/forge_test.go @@ -15,7 +15,6 @@ package config_test import ( - "context" "fmt" "path/filepath" "testing" @@ -310,7 +309,7 @@ func TestFetch(t *testing.T) { 3, ) files, err := configFetcher.Fetch( - context.Background(), + t.Context(), f, &model.User{AccessToken: "xxx"}, repo, diff --git a/server/store/datastore/migration/migration_test.go b/server/store/datastore/migration/migration_test.go index 41461217a..d6421a091 100644 --- a/server/store/datastore/migration/migration_test.go +++ b/server/store/datastore/migration/migration_test.go @@ -15,7 +15,6 @@ package migration import ( - "context" "os" "testing" "time" @@ -96,7 +95,7 @@ func testDB(t *testing.T, initNewDB bool) (engine *xorm.Engine, closeDB func()) func TestMigrate(t *testing.T) { // init new db engine, closeDB := testDB(t, true) - assert.NoError(t, Migrate(context.Background(), engine, true)) + assert.NoError(t, Migrate(t.Context(), engine, true)) closeDB() dbType := engine.Dialect().URI().DBType @@ -107,6 +106,6 @@ func TestMigrate(t *testing.T) { // migrate old db engine, closeDB = testDB(t, false) - assert.NoError(t, Migrate(context.Background(), engine, true)) + assert.NoError(t, Migrate(t.Context(), engine, true)) closeDB() }