diff --git a/publisher/Dockerfile b/publisher/Dockerfile index e910897..c5d73ef 100644 --- a/publisher/Dockerfile +++ b/publisher/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.23.3-alpine AS builder +FROM golang:1.23.4-alpine AS builder COPY . /app RUN --mount=type=cache,target=/go/pkg/mod cd /app && \ diff --git a/publisher/go.mod b/publisher/go.mod index b9c01f8..bfc1d23 100644 --- a/publisher/go.mod +++ b/publisher/go.mod @@ -1,6 +1,6 @@ module github.com/PingCAP-QE/ee-apps/publisher -go 1.23 +go 1.23.4 require ( github.com/Masterminds/sprig/v3 v3.3.0 @@ -14,6 +14,7 @@ require ( goa.design/clue v1.0.7 goa.design/goa/v3 v3.19.1 goa.design/plugins/v3 v3.19.1 + golang.org/x/mod v0.21.0 gopkg.in/yaml.v3 v3.0.1 oras.land/oras-go/v2 v2.5.0 ) @@ -56,7 +57,6 @@ require ( go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect golang.org/x/crypto v0.28.0 // indirect - golang.org/x/mod v0.21.0 // indirect golang.org/x/net v0.30.0 // indirect golang.org/x/sync v0.8.0 // indirect golang.org/x/sys v0.26.0 // indirect diff --git a/publisher/pkg/impl/funcs_fs.go b/publisher/pkg/impl/funcs_fs.go index df83971..c532595 100644 --- a/publisher/pkg/impl/funcs_fs.go +++ b/publisher/pkg/impl/funcs_fs.go @@ -8,6 +8,7 @@ import ( "strings" "github.com/PingCAP-QE/ee-apps/dl/pkg/oci" + "golang.org/x/mod/semver" ) var reTagOsArchSuffix = regexp.MustCompile(`_(linux|darwin)_(amd64|arm64)$`) @@ -208,6 +209,11 @@ func targetFsFullPaths(p *PublishInfo) []string { // the / path: pingcap//// ret = append(ret, filepath.Join("download/builds/pingcap", p.Name, strings.ReplaceAll(p.Version, "#", "/"), p.EntryPoint)) + // if the part before the '#' char in p.Version is semver git tag format, then we need only one path. + if semver.IsValid(strings.Split(p.Version, "#")[0]) { + return ret + } + // the / path: pingcap/// ret = append(ret, filepath.Join("download/builds/pingcap", p.Name, filepath.Base(strings.ReplaceAll(p.Version, "#", "/")), p.EntryPoint)) diff --git a/publisher/pkg/impl/funcs_fs_test.go b/publisher/pkg/impl/funcs_fs_test.go index 79c32b2..fc3f946 100644 --- a/publisher/pkg/impl/funcs_fs_test.go +++ b/publisher/pkg/impl/funcs_fs_test.go @@ -346,8 +346,8 @@ func Test_targetFsFullPaths(t *testing.T) { EntryPoint: "bin/tidb-server", }, want: []string{ - "pingcap/tidb/master/abc123def/bin/tidb-server", - "pingcap/tidb/abc123def/bin/tidb-server", + "download/builds/pingcap/tidb/master/abc123def/bin/tidb-server", + "download/builds/pingcap/tidb/abc123def/bin/tidb-server", }, }, { @@ -358,8 +358,8 @@ func Test_targetFsFullPaths(t *testing.T) { EntryPoint: "pd-server", }, want: []string{ - "pingcap/pd/release-5.0/abc/pd-server", - "pingcap/pd/abc/pd-server", + "download/builds/pingcap/pd/release-5.0/abc/pd-server", + "download/builds/pingcap/pd/abc/pd-server", }, }, { @@ -370,8 +370,19 @@ func Test_targetFsFullPaths(t *testing.T) { EntryPoint: "opt/tiflash/bin/tiflash-server", }, want: []string{ - "pingcap/tiflash/nightly/xyz789/opt/tiflash/bin/tiflash-server", - "pingcap/tiflash/xyz789/opt/tiflash/bin/tiflash-server", + "download/builds/pingcap/tiflash/nightly/xyz789/opt/tiflash/bin/tiflash-server", + "download/builds/pingcap/tiflash/xyz789/opt/tiflash/bin/tiflash-server", + }, + }, + { + name: "tag", + p: &PublishInfo{ + Name: "tiflash", + Version: "v7.1.1#abcdef", + EntryPoint: "opt/tiflash/bin/tiflash-server", + }, + want: []string{ + "download/builds/pingcap/tiflash/v7.1.1/abcdef/opt/tiflash/bin/tiflash-server", }, }, } diff --git a/publisher/pkg/impl/tiup_worker.go b/publisher/pkg/impl/tiup_worker.go index b762f68..469dd32 100644 --- a/publisher/pkg/impl/tiup_worker.go +++ b/publisher/pkg/impl/tiup_worker.go @@ -157,7 +157,7 @@ func (p *tiupWorker) handle(data *PublishRequest) cloudevents.Result { Int("tried", i+1). Int("max_retries", tiupUploadingMaxRetries). Err(err). - Msgf("publish to mirror failed, i will retry after %s.") + Msgf("publish to mirror failed, i will retry after %s.", tiupUploadingRetryDelay) time.Sleep(tiupUploadingRetryDelay) } } diff --git a/publisher/pkg/impl/tiup_worker_test.go b/publisher/pkg/impl/tiup_worker_test.go index aba4dfa..28d0404 100644 --- a/publisher/pkg/impl/tiup_worker_test.go +++ b/publisher/pkg/impl/tiup_worker_test.go @@ -15,7 +15,7 @@ func Test_tiupWorker_notifyLark(t *testing.T) { type fields struct { logger zerolog.Logger - redisClient redis.Cmdable + redisClient *redis.Client options struct { LarkWebhookURL string MirrorURL string