Skip to content

Commit

Permalink
feat(publisher): add tag artifacts to fileserver (#210)
Browse files Browse the repository at this point in the history
avoid conflict with the branch objects

Signed-off-by: wuhuizuo <[email protected]>

---------

Signed-off-by: wuhuizuo <[email protected]>
  • Loading branch information
wuhuizuo authored Dec 5, 2024
1 parent 8c2a836 commit 2fd2a9b
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 11 deletions.
2 changes: 1 addition & 1 deletion publisher/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 && \
Expand Down
4 changes: 2 additions & 2 deletions publisher/go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
)
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions publisher/pkg/impl/funcs_fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)$`)
Expand Down Expand Up @@ -208,6 +209,11 @@ func targetFsFullPaths(p *PublishInfo) []string {

// the <branch>/<commit> path: pingcap/<comp>/<branch>/<commit>/<entrypoint>
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 <branch>/<commit> path: pingcap/<comp>/<commit>/<entrypoint>
ret = append(ret, filepath.Join("download/builds/pingcap", p.Name, filepath.Base(strings.ReplaceAll(p.Version, "#", "/")), p.EntryPoint))

Expand Down
23 changes: 17 additions & 6 deletions publisher/pkg/impl/funcs_fs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
},
{
Expand All @@ -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",
},
},
{
Expand All @@ -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",
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion publisher/pkg/impl/tiup_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
2 changes: 1 addition & 1 deletion publisher/pkg/impl/tiup_worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2fd2a9b

Please sign in to comment.