Sort later, so it is sorted in restarts too

This commit is contained in:
Laszlo Fogas 2019-06-16 15:27:40 +02:00
parent a37866179f
commit a22747f5c3
4 changed files with 10 additions and 9 deletions

View file

@ -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.

View file

@ -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] }

View file

@ -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),

View file

@ -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))