Skip to content

Commit 2fd2a9b

Browse files
authored
feat(publisher): add tag artifacts to fileserver (#210)
avoid conflict with the branch objects Signed-off-by: wuhuizuo <wuhuizuo@126.com> --------- Signed-off-by: wuhuizuo <wuhuizuo@126.com>
1 parent 8c2a836 commit 2fd2a9b

6 files changed

Lines changed: 28 additions & 11 deletions

File tree

publisher/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.23.3-alpine AS builder
1+
FROM golang:1.23.4-alpine AS builder
22

33
COPY . /app
44
RUN --mount=type=cache,target=/go/pkg/mod cd /app && \

publisher/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/PingCAP-QE/ee-apps/publisher
22

3-
go 1.23
3+
go 1.23.4
44

55
require (
66
github.com/Masterminds/sprig/v3 v3.3.0
@@ -14,6 +14,7 @@ require (
1414
goa.design/clue v1.0.7
1515
goa.design/goa/v3 v3.19.1
1616
goa.design/plugins/v3 v3.19.1
17+
golang.org/x/mod v0.21.0
1718
gopkg.in/yaml.v3 v3.0.1
1819
oras.land/oras-go/v2 v2.5.0
1920
)
@@ -56,7 +57,6 @@ require (
5657
go.uber.org/multierr v1.11.0 // indirect
5758
go.uber.org/zap v1.27.0 // indirect
5859
golang.org/x/crypto v0.28.0 // indirect
59-
golang.org/x/mod v0.21.0 // indirect
6060
golang.org/x/net v0.30.0 // indirect
6161
golang.org/x/sync v0.8.0 // indirect
6262
golang.org/x/sys v0.26.0 // indirect

publisher/pkg/impl/funcs_fs.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"strings"
99

1010
"github.com/PingCAP-QE/ee-apps/dl/pkg/oci"
11+
"golang.org/x/mod/semver"
1112
)
1213

1314
var reTagOsArchSuffix = regexp.MustCompile(`_(linux|darwin)_(amd64|arm64)$`)
@@ -208,6 +209,11 @@ func targetFsFullPaths(p *PublishInfo) []string {
208209

209210
// the <branch>/<commit> path: pingcap/<comp>/<branch>/<commit>/<entrypoint>
210211
ret = append(ret, filepath.Join("download/builds/pingcap", p.Name, strings.ReplaceAll(p.Version, "#", "/"), p.EntryPoint))
212+
// if the part before the '#' char in p.Version is semver git tag format, then we need only one path.
213+
if semver.IsValid(strings.Split(p.Version, "#")[0]) {
214+
return ret
215+
}
216+
211217
// the <branch>/<commit> path: pingcap/<comp>/<commit>/<entrypoint>
212218
ret = append(ret, filepath.Join("download/builds/pingcap", p.Name, filepath.Base(strings.ReplaceAll(p.Version, "#", "/")), p.EntryPoint))
213219

publisher/pkg/impl/funcs_fs_test.go

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,8 @@ func Test_targetFsFullPaths(t *testing.T) {
346346
EntryPoint: "bin/tidb-server",
347347
},
348348
want: []string{
349-
"pingcap/tidb/master/abc123def/bin/tidb-server",
350-
"pingcap/tidb/abc123def/bin/tidb-server",
349+
"download/builds/pingcap/tidb/master/abc123def/bin/tidb-server",
350+
"download/builds/pingcap/tidb/abc123def/bin/tidb-server",
351351
},
352352
},
353353
{
@@ -358,8 +358,8 @@ func Test_targetFsFullPaths(t *testing.T) {
358358
EntryPoint: "pd-server",
359359
},
360360
want: []string{
361-
"pingcap/pd/release-5.0/abc/pd-server",
362-
"pingcap/pd/abc/pd-server",
361+
"download/builds/pingcap/pd/release-5.0/abc/pd-server",
362+
"download/builds/pingcap/pd/abc/pd-server",
363363
},
364364
},
365365
{
@@ -370,8 +370,19 @@ func Test_targetFsFullPaths(t *testing.T) {
370370
EntryPoint: "opt/tiflash/bin/tiflash-server",
371371
},
372372
want: []string{
373-
"pingcap/tiflash/nightly/xyz789/opt/tiflash/bin/tiflash-server",
374-
"pingcap/tiflash/xyz789/opt/tiflash/bin/tiflash-server",
373+
"download/builds/pingcap/tiflash/nightly/xyz789/opt/tiflash/bin/tiflash-server",
374+
"download/builds/pingcap/tiflash/xyz789/opt/tiflash/bin/tiflash-server",
375+
},
376+
},
377+
{
378+
name: "tag",
379+
p: &PublishInfo{
380+
Name: "tiflash",
381+
Version: "v7.1.1#abcdef",
382+
EntryPoint: "opt/tiflash/bin/tiflash-server",
383+
},
384+
want: []string{
385+
"download/builds/pingcap/tiflash/v7.1.1/abcdef/opt/tiflash/bin/tiflash-server",
375386
},
376387
},
377388
}

publisher/pkg/impl/tiup_worker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ func (p *tiupWorker) handle(data *PublishRequest) cloudevents.Result {
157157
Int("tried", i+1).
158158
Int("max_retries", tiupUploadingMaxRetries).
159159
Err(err).
160-
Msgf("publish to mirror failed, i will retry after %s.")
160+
Msgf("publish to mirror failed, i will retry after %s.", tiupUploadingRetryDelay)
161161
time.Sleep(tiupUploadingRetryDelay)
162162
}
163163
}

publisher/pkg/impl/tiup_worker_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func Test_tiupWorker_notifyLark(t *testing.T) {
1515

1616
type fields struct {
1717
logger zerolog.Logger
18-
redisClient redis.Cmdable
18+
redisClient *redis.Client
1919
options struct {
2020
LarkWebhookURL string
2121
MirrorURL string

0 commit comments

Comments
 (0)