Merge branch 'main' into rework-entry

This commit is contained in:
qwerty287 2024-04-09 16:09:50 +02:00 committed by GitHub
commit 0b7837e66e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 75 additions and 31 deletions

View file

@ -79,7 +79,18 @@
"HEALTHCHECK",
"devx",
"gomod",
"laszlocph"
"laszlocph",
"charmbracelet",
"GODEBUG",
"netdns",
"BUILDPLATFORM",
"repology",
"WORKDIR",
"corepack",
"binutils",
"nocolor",
"logfile",
"Keyfunc"
],
"ignorePaths": [
"**/node_modules/**/*",
@ -103,10 +114,8 @@
"agent/",
"cli/",
"cmd/",
"docker/",
"docs/",
"pipeline/",
"shared/",
"server/"
],
"enableFiletypes": ["dockercompose"]

14
.github/renovate.json vendored
View file

@ -2,18 +2,28 @@
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["github>woodpecker-ci/renovate-config"],
"packageRules": [
{
"matchCurrentVersion": "<1.0.0",
"matchPackageNames": ["github.com/distribution/reference"],
"matchUpdateTypes": ["major", "minor"],
"dependencyDashboardApproval": true
},
{
"matchPackageNames": ["github.com/charmbracelet/huh/spinner"],
"enabled": false
},
{
"matchManagers": ["docker-compose"],
"matchFileNames": ["docker-compose.gitpod.yml"],
"addLabels": ["devx"]
},
{
"groupName": "golang (lang)",
"groupName": "golang-lang",
"matchPackagePatterns": ["^golang$", "xgo"],
"matchUpdateTypes": ["minor", "patch"]
},
{
"groupName": "golang (packages)",
"groupName": "golang-packages",
"matchManagers": ["gomod"],
"matchUpdateTypes": ["minor", "patch"]
},

View file

@ -5,7 +5,7 @@ repos:
- id: check-hooks-apply
- id: check-useless-excludes
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace

View file

@ -2,7 +2,7 @@ when:
event: tag
variables:
- &golang_image 'docker.io/golang:1.22.1'
- &golang_image 'docker.io/golang:1.22.2'
- &node_image 'docker.io/node:21-alpine'
- &xgo_image 'docker.io/techknowlogick/xgo:go-1.22.1'
- &xgo_version 'go-1.21.2'

View file

@ -1,5 +1,5 @@
variables:
- &golang_image 'docker.io/golang:1.22.1'
- &golang_image 'docker.io/golang:1.22.2'
- &node_image 'docker.io/node:21-alpine'
- &xgo_image 'docker.io/techknowlogick/xgo:go-1.22.1'
- &xgo_version 'go-1.21.2'

View file

@ -53,6 +53,7 @@ func (c *client) Close() error {
func (c *client) newBackOff() backoff.BackOff {
b := backoff.NewExponentialBackOff()
b.MaxElapsedTime = 0
b.MaxInterval = 10 * time.Second //nolint: gomnd
b.InitialInterval = 10 * time.Millisecond //nolint: gomnd
return b

2
go.mod
View file

@ -27,7 +27,7 @@ require (
github.com/go-ap/httpsig v0.0.0-20221203064646-3647b4d88fdf
github.com/go-sql-driver/mysql v1.8.1
github.com/golang-jwt/jwt/v5 v5.2.1
github.com/google/go-github/v60 v60.0.0
github.com/google/go-github/v61 v61.0.0
github.com/google/tink/go v1.7.0
github.com/gorilla/securecookie v1.1.2
github.com/jellydator/ttlcache/v3 v3.2.0

4
go.sum
View file

@ -191,8 +191,8 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-github/v60 v60.0.0 h1:oLG98PsLauFvvu4D/YPxq374jhSxFYdzQGNCyONLfn8=
github.com/google/go-github/v60 v60.0.0/go.mod h1:ByhX2dP9XT9o/ll2yXAu2VD8l5eNVg8hD4Cr0S/LmQk=
github.com/google/go-github/v61 v61.0.0 h1:VwQCBwhyE9JclCI+22/7mLB1PuU9eowCXKY5pNlu1go=
github.com/google/go-github/v61 v61.0.0/go.mod h1:0WR+KmsWX75G2EbpyGsGmradjo3IiciuI4BmdVCobQY=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=

View file

@ -213,7 +213,7 @@ func (e *docker) StartStep(ctx context.Context, step *backend.Step, taskUUID str
}
// add default volumes to the host configuration
hostConfig.Binds = utils.DedupStrings(append(hostConfig.Binds, e.volumes...))
hostConfig.Binds = utils.DeduplicateStrings(append(hostConfig.Binds, e.volumes...))
_, err := e.client.ContainerCreate(ctx, config, hostConfig, nil, nil, containerName)
if client.IsErrNotFound(err) {

View file

@ -17,6 +17,7 @@ package bitbucket
import (
"context"
"errors"
"fmt"
"net/http"
"net/url"
@ -232,9 +233,15 @@ func (c *config) Repos(ctx context.Context, u *model.User) ([]*model.Repo, error
func (c *config) File(ctx context.Context, u *model.User, r *model.Repo, p *model.Pipeline, f string) ([]byte, error) {
config, err := c.newClient(ctx, u).FindSource(r.Owner, r.Name, p.Commit, f)
if err != nil {
var rspErr internal.Error
if ok := errors.As(err, &rspErr); ok && rspErr.Status == http.StatusNotFound {
return nil, &forge_types.ErrConfigNotFound{
Configs: []string{f},
}
}
return nil, err
}
return []byte(*config), err
return []byte(*config), nil
}
// Dir fetches a folder from the bitbucket repository
@ -245,6 +252,12 @@ func (c *config) Dir(ctx context.Context, u *model.User, r *model.Repo, p *model
for {
filesResp, err := client.GetRepoFiles(r.Owner, r.Name, p.Commit, f, page)
if err != nil {
var rspErr internal.Error
if ok := errors.As(err, &rspErr); ok && rspErr.Status == http.StatusNotFound {
return nil, &forge_types.ErrConfigNotFound{
Configs: []string{f},
}
}
return nil, err
}
for _, file := range filesResp.Values {

View file

@ -18,6 +18,7 @@ package bitbucket
import (
"bytes"
"context"
"errors"
"net/http"
"net/http/httptest"
"testing"
@ -179,6 +180,7 @@ func Test_bitbucket(t *testing.T) {
g.It("Should handle not found error", func() {
_, err := c.File(ctx, fakeUser, fakeRepo, fakePipeline, "file_not_found")
g.Assert(err).IsNotNil()
g.Assert(errors.Is(err, &types.ErrConfigNotFound{})).IsTrue()
})
})
@ -222,8 +224,9 @@ func Test_bitbucket(t *testing.T) {
g.Assert(string(files[0].Data)).Equal("dummy payload")
})
g.It("Should handle not found errors", func() {
_, err := c.Dir(ctx, fakeUser, fakeRepo, fakePipeline, "/dir_not_found")
_, err := c.Dir(ctx, fakeUser, fakeRepo, fakePipeline, "dir_not_found/")
g.Assert(err).IsNotNil()
g.Assert(errors.Is(err, &types.ErrConfigNotFound{})).IsTrue()
})
})

View file

@ -118,7 +118,7 @@ func getChangedFilesFromPushHook(hook *pushHook) []string {
files = append(files, hook.HeadCommit.Removed...)
files = append(files, hook.HeadCommit.Modified...)
return utils.DedupStrings(files)
return utils.DeduplicateStrings(files)
}
// helper function that extracts the Pipeline data from a Gitea tag hook

View file

@ -18,7 +18,7 @@ package github
import (
"fmt"
"github.com/google/go-github/v60/github"
"github.com/google/go-github/v61/github"
"go.woodpecker-ci.org/woodpecker/v2/server/model"
)

View file

@ -19,7 +19,7 @@ import (
"testing"
"github.com/franela/goblin"
"github.com/google/go-github/v60/github"
"github.com/google/go-github/v61/github"
"go.woodpecker-ci.org/woodpecker/v2/server/model"
)

View file

@ -26,7 +26,7 @@ import (
"strconv"
"strings"
"github.com/google/go-github/v60/github"
"github.com/google/go-github/v61/github"
"github.com/rs/zerolog/log"
"golang.org/x/oauth2"
@ -630,7 +630,7 @@ func (c *client) loadChangedFilesFromPullRequest(ctx context.Context, pull *gith
opts.Page = resp.NextPage
}
return utils.DedupStrings(fileList), nil
return utils.DeduplicateStrings(fileList), nil
})
return pipeline, err

View file

@ -22,7 +22,7 @@ import (
"net/http"
"strings"
"github.com/google/go-github/v60/github"
"github.com/google/go-github/v61/github"
"go.woodpecker-ci.org/woodpecker/v2/server/forge/types"
"go.woodpecker-ci.org/woodpecker/v2/server/model"
@ -215,5 +215,5 @@ func getChangedFilesFromCommits(commits []*github.HeadCommit) []string {
files = append(files, cm.Removed...)
files = append(files, cm.Modified...)
}
return utils.DedupStrings(files)
return utils.DeduplicateStrings(files)
}

View file

@ -189,7 +189,7 @@ func convertPushHook(hook *gitlab.PushEvent) (*model.Repo, *model.Pipeline, erro
files = append(files, cm.Removed...)
files = append(files, cm.Modified...)
}
pipeline.ChangedFiles = utils.DedupStrings(files)
pipeline.ChangedFiles = utils.DeduplicateStrings(files)
return repo, pipeline, nil
}

View file

@ -808,7 +808,7 @@ func (g *GitLab) loadChangedFilesFromMergeRequest(ctx context.Context, tmpRepo *
for _, file := range changes {
files = append(files, file.NewPath, file.OldPath)
}
pipeline.ChangedFiles = utils.DedupStrings(files)
pipeline.ChangedFiles = utils.DeduplicateStrings(files)
return pipeline, nil
}

View file

@ -139,19 +139,19 @@ func keyFunc(token *Token, fn SecretFunc) jwt.Keyfunc {
// extract the token kind and cast to
// the expected type.
kindv, ok := claims["type"]
kind, ok := claims["type"]
if !ok {
return nil, jwt.ErrInvalidType
}
token.Kind, _ = kindv.(string)
token.Kind, _ = kind.(string)
// extract the token value and cast to
// expected type.
textv, ok := claims["text"]
text, ok := claims["text"]
if !ok {
return nil, jwt.ErrInvalidType
}
token.Text, _ = textv.(string)
token.Text, _ = text.(string)
// invoke the callback function to retrieve
// the secret key used to verify

View file

@ -14,8 +14,8 @@
package utils
// DedupStrings deduplicate string list, empty items are dropped
func DedupStrings(src []string) []string {
// DeduplicateStrings deduplicate string list, empty items are dropped
func DeduplicateStrings(src []string) []string {
m := make(map[string]struct{}, len(src))
dst := make([]string, 0, len(src))

View file

@ -21,7 +21,7 @@ import (
"github.com/stretchr/testify/assert"
)
func TestDedupStrings(t *testing.T) {
func TestDeduplicateStrings(t *testing.T) {
tests := []struct {
in []string
out []string
@ -37,7 +37,7 @@ func TestDedupStrings(t *testing.T) {
}}
for _, tc := range tests {
result := DedupStrings(tc.in)
result := DeduplicateStrings(tc.in)
sort.Strings(result)
if len(tc.out) == 0 {
assert.Len(t, result, 0)

View file

@ -391,6 +391,10 @@
"public": "Öffentlich"
},
"visibility": "Sichtbarkeit des Projekts"
},
"allow_deploy": {
"allow": "Deployments erlauben",
"desc": "Deployments von erolgreichen Pipelines erlauben. Nur benutzen, wenn du allen Nutzern mit Push-Zugriff vertraust."
}
},
"not_allowed": "Zugriff auf die Einstellungen dieses Repositories nicht erlaubt",

View file

@ -390,6 +390,10 @@
"public": "Publique"
},
"visibility": "Visibilité du projet"
},
"allow_deploy": {
"allow": "Autoriser les déploiements",
"desc": "Autoriser les déploiements depuis les pipelines ayant réussis. À utiliser que si vous avez confiance dans les utilisateurs ayant un accès en écriture."
}
},
"not_allowed": "Vous n'êtes pas autorisé à accéder aux paramètres de ce dépôt",