mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-06-16 12:20:45 +00:00
Merge branch 'main' into woodpecker-fix-log-tail-cpu-lock
This commit is contained in:
commit
85d03a63b0
15
.cspell.json
15
.cspell.json
|
@ -79,7 +79,18 @@
|
||||||
"HEALTHCHECK",
|
"HEALTHCHECK",
|
||||||
"devx",
|
"devx",
|
||||||
"gomod",
|
"gomod",
|
||||||
"laszlocph"
|
"laszlocph",
|
||||||
|
"charmbracelet",
|
||||||
|
"GODEBUG",
|
||||||
|
"netdns",
|
||||||
|
"BUILDPLATFORM",
|
||||||
|
"repology",
|
||||||
|
"WORKDIR",
|
||||||
|
"corepack",
|
||||||
|
"binutils",
|
||||||
|
"nocolor",
|
||||||
|
"logfile",
|
||||||
|
"Keyfunc"
|
||||||
],
|
],
|
||||||
"ignorePaths": [
|
"ignorePaths": [
|
||||||
"**/node_modules/**/*",
|
"**/node_modules/**/*",
|
||||||
|
@ -103,10 +114,8 @@
|
||||||
"agent/",
|
"agent/",
|
||||||
"cli/",
|
"cli/",
|
||||||
"cmd/",
|
"cmd/",
|
||||||
"docker/",
|
|
||||||
"docs/",
|
"docs/",
|
||||||
"pipeline/",
|
"pipeline/",
|
||||||
"shared/",
|
|
||||||
"server/"
|
"server/"
|
||||||
],
|
],
|
||||||
"enableFiletypes": ["dockercompose"]
|
"enableFiletypes": ["dockercompose"]
|
||||||
|
|
|
@ -53,6 +53,7 @@ func (c *client) Close() error {
|
||||||
|
|
||||||
func (c *client) newBackOff() backoff.BackOff {
|
func (c *client) newBackOff() backoff.BackOff {
|
||||||
b := backoff.NewExponentialBackOff()
|
b := backoff.NewExponentialBackOff()
|
||||||
|
b.MaxElapsedTime = 0
|
||||||
b.MaxInterval = 10 * time.Second //nolint: gomnd
|
b.MaxInterval = 10 * time.Second //nolint: gomnd
|
||||||
b.InitialInterval = 10 * time.Millisecond //nolint: gomnd
|
b.InitialInterval = 10 * time.Millisecond //nolint: gomnd
|
||||||
return b
|
return b
|
||||||
|
|
|
@ -213,7 +213,7 @@ func (e *docker) StartStep(ctx context.Context, step *backend.Step, taskUUID str
|
||||||
}
|
}
|
||||||
|
|
||||||
// add default volumes to the host configuration
|
// 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)
|
_, err := e.client.ContainerCreate(ctx, config, hostConfig, nil, nil, containerName)
|
||||||
if client.IsErrNotFound(err) {
|
if client.IsErrNotFound(err) {
|
||||||
|
|
|
@ -17,6 +17,7 @@ package bitbucket
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"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) {
|
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)
|
config, err := c.newClient(ctx, u).FindSource(r.Owner, r.Name, p.Commit, f)
|
||||||
if err != nil {
|
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 nil, err
|
||||||
}
|
}
|
||||||
return []byte(*config), err
|
return []byte(*config), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dir fetches a folder from the bitbucket repository
|
// 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 {
|
for {
|
||||||
filesResp, err := client.GetRepoFiles(r.Owner, r.Name, p.Commit, f, page)
|
filesResp, err := client.GetRepoFiles(r.Owner, r.Name, p.Commit, f, page)
|
||||||
if err != nil {
|
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 nil, err
|
||||||
}
|
}
|
||||||
for _, file := range filesResp.Values {
|
for _, file := range filesResp.Values {
|
||||||
|
|
|
@ -18,6 +18,7 @@ package bitbucket
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -179,6 +180,7 @@ func Test_bitbucket(t *testing.T) {
|
||||||
g.It("Should handle not found error", func() {
|
g.It("Should handle not found error", func() {
|
||||||
_, err := c.File(ctx, fakeUser, fakeRepo, fakePipeline, "file_not_found")
|
_, err := c.File(ctx, fakeUser, fakeRepo, fakePipeline, "file_not_found")
|
||||||
g.Assert(err).IsNotNil()
|
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.Assert(string(files[0].Data)).Equal("dummy payload")
|
||||||
})
|
})
|
||||||
g.It("Should handle not found errors", func() {
|
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(err).IsNotNil()
|
||||||
|
g.Assert(errors.Is(err, &types.ErrConfigNotFound{})).IsTrue()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,7 @@ func getChangedFilesFromPushHook(hook *pushHook) []string {
|
||||||
files = append(files, hook.HeadCommit.Removed...)
|
files = append(files, hook.HeadCommit.Removed...)
|
||||||
files = append(files, hook.HeadCommit.Modified...)
|
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
|
// helper function that extracts the Pipeline data from a Gitea tag hook
|
||||||
|
|
|
@ -630,7 +630,7 @@ func (c *client) loadChangedFilesFromPullRequest(ctx context.Context, pull *gith
|
||||||
|
|
||||||
opts.Page = resp.NextPage
|
opts.Page = resp.NextPage
|
||||||
}
|
}
|
||||||
return utils.DedupStrings(fileList), nil
|
return utils.DeduplicateStrings(fileList), nil
|
||||||
})
|
})
|
||||||
|
|
||||||
return pipeline, err
|
return pipeline, err
|
||||||
|
|
|
@ -215,5 +215,5 @@ func getChangedFilesFromCommits(commits []*github.HeadCommit) []string {
|
||||||
files = append(files, cm.Removed...)
|
files = append(files, cm.Removed...)
|
||||||
files = append(files, cm.Modified...)
|
files = append(files, cm.Modified...)
|
||||||
}
|
}
|
||||||
return utils.DedupStrings(files)
|
return utils.DeduplicateStrings(files)
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,7 +189,7 @@ func convertPushHook(hook *gitlab.PushEvent) (*model.Repo, *model.Pipeline, erro
|
||||||
files = append(files, cm.Removed...)
|
files = append(files, cm.Removed...)
|
||||||
files = append(files, cm.Modified...)
|
files = append(files, cm.Modified...)
|
||||||
}
|
}
|
||||||
pipeline.ChangedFiles = utils.DedupStrings(files)
|
pipeline.ChangedFiles = utils.DeduplicateStrings(files)
|
||||||
|
|
||||||
return repo, pipeline, nil
|
return repo, pipeline, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -808,7 +808,7 @@ func (g *GitLab) loadChangedFilesFromMergeRequest(ctx context.Context, tmpRepo *
|
||||||
for _, file := range changes {
|
for _, file := range changes {
|
||||||
files = append(files, file.NewPath, file.OldPath)
|
files = append(files, file.NewPath, file.OldPath)
|
||||||
}
|
}
|
||||||
pipeline.ChangedFiles = utils.DedupStrings(files)
|
pipeline.ChangedFiles = utils.DeduplicateStrings(files)
|
||||||
|
|
||||||
return pipeline, nil
|
return pipeline, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,19 +139,19 @@ func keyFunc(token *Token, fn SecretFunc) jwt.Keyfunc {
|
||||||
|
|
||||||
// extract the token kind and cast to
|
// extract the token kind and cast to
|
||||||
// the expected type.
|
// the expected type.
|
||||||
kindv, ok := claims["type"]
|
kind, ok := claims["type"]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, jwt.ErrInvalidType
|
return nil, jwt.ErrInvalidType
|
||||||
}
|
}
|
||||||
token.Kind, _ = kindv.(string)
|
token.Kind, _ = kind.(string)
|
||||||
|
|
||||||
// extract the token value and cast to
|
// extract the token value and cast to
|
||||||
// expected type.
|
// expected type.
|
||||||
textv, ok := claims["text"]
|
text, ok := claims["text"]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, jwt.ErrInvalidType
|
return nil, jwt.ErrInvalidType
|
||||||
}
|
}
|
||||||
token.Text, _ = textv.(string)
|
token.Text, _ = text.(string)
|
||||||
|
|
||||||
// invoke the callback function to retrieve
|
// invoke the callback function to retrieve
|
||||||
// the secret key used to verify
|
// the secret key used to verify
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
package utils
|
package utils
|
||||||
|
|
||||||
// DedupStrings deduplicate string list, empty items are dropped
|
// DeduplicateStrings deduplicate string list, empty items are dropped
|
||||||
func DedupStrings(src []string) []string {
|
func DeduplicateStrings(src []string) []string {
|
||||||
m := make(map[string]struct{}, len(src))
|
m := make(map[string]struct{}, len(src))
|
||||||
dst := make([]string, 0, len(src))
|
dst := make([]string, 0, len(src))
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ import (
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDedupStrings(t *testing.T) {
|
func TestDeduplicateStrings(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
in []string
|
in []string
|
||||||
out []string
|
out []string
|
||||||
|
@ -37,7 +37,7 @@ func TestDedupStrings(t *testing.T) {
|
||||||
}}
|
}}
|
||||||
|
|
||||||
for _, tc := range tests {
|
for _, tc := range tests {
|
||||||
result := DedupStrings(tc.in)
|
result := DeduplicateStrings(tc.in)
|
||||||
sort.Strings(result)
|
sort.Strings(result)
|
||||||
if len(tc.out) == 0 {
|
if len(tc.out) == 0 {
|
||||||
assert.Len(t, result, 0)
|
assert.Len(t, result, 0)
|
||||||
|
|
Loading…
Reference in a new issue