From a22747f5c360e8bc0b148f7b7565ed197e6dfb15 Mon Sep 17 00:00:00 2001 From: Laszlo Fogas Date: Sun, 16 Jun 2019 15:27:40 +0200 Subject: [PATCH] Sort later, so it is sorted in restarts too --- remote/remote.go | 6 ++++++ server/configFetcher.go | 9 --------- server/hook.go | 1 + server/procBuilder.go | 3 +++ 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/remote/remote.go b/remote/remote.go index 7804cd97b..22563cf47 100644 --- a/remote/remote.go +++ b/remote/remote.go @@ -79,6 +79,12 @@ type FileMeta struct { Data []byte } +type ByName []*FileMeta + +func (a ByName) Len() int { return len(a) } +func (a ByName) Less(i, j int) bool { return a[i].Name < a[j].Name } +func (a ByName) Swap(i, j int) { a[i], a[j] = a[j], a[i] } + // Refresher refreshes an oauth token and expiration for the given user. It // returns true if the token was refreshed, false if the token was not refreshed, // and error if it failed to refersh. diff --git a/server/configFetcher.go b/server/configFetcher.go index 2bd98e158..08b215074 100644 --- a/server/configFetcher.go +++ b/server/configFetcher.go @@ -5,8 +5,6 @@ import ( "github.com/laszlocph/drone-oss-08/model" "github.com/laszlocph/drone-oss-08/remote" - - "sort" ) type configFetcher struct { @@ -33,15 +31,8 @@ func (cf *configFetcher) Fetch() ([]*remote.FileMeta, error) { return nil, direrr } - sort.Sort(byName(dir)) return dir, nil } } return []*remote.FileMeta{}, nil } - -type byName []*remote.FileMeta - -func (a byName) Len() int { return len(a) } -func (a byName) Less(i, j int) bool { return a[i].Name < a[j].Name } -func (a byName) Swap(i, j int) { a[i], a[j] = a[j], a[i] } diff --git a/server/hook.go b/server/hook.go index 833408e94..2f0de4785 100644 --- a/server/hook.go +++ b/server/hook.go @@ -321,6 +321,7 @@ func queueBuild(build *model.Build, repo *model.Repo, buildItems []*buildItem) { task.Labels["platform"] = item.Platform task.Labels["repo"] = repo.FullName task.Dependencies = taskIds(item.DependsOn, buildItems) + task.DepStatus = make(map[string]bool) task.Data, _ = json.Marshal(rpc.Pipeline{ ID: fmt.Sprint(item.Proc.ID), diff --git a/server/procBuilder.go b/server/procBuilder.go index 230656dd6..391bf9f7b 100644 --- a/server/procBuilder.go +++ b/server/procBuilder.go @@ -18,6 +18,7 @@ import ( "fmt" "math/rand" "net/url" + "sort" "strings" "github.com/drone/envsubst" @@ -55,6 +56,8 @@ type buildItem struct { func (b *procBuilder) Build() ([]*buildItem, error) { var items []*buildItem + sort.Sort(remote.ByName(b.Yamls)) + for j, y := range b.Yamls { // matrix axes axes, err := matrix.ParseString(string(y.Data))