1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-12-24 10:07:21 +02:00

make backend step dag generation deterministic (#3037)

the the generation for backend steps if a dag is used deterministic.

this also fix where the test randomly fail like in:
- https://ci.woodpecker-ci.org/repos/3780/pipeline/11057/30
- https://ci.woodpecker-ci.org/repos/3780/pipeline/11076/25
This commit is contained in:
6543 2023-12-27 11:38:33 +01:00 committed by GitHub
parent 05f26bab00
commit 840fca198e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 6 deletions

View File

@ -16,6 +16,7 @@ package compiler
import (
"fmt"
"sort"
backend_types "go.woodpecker-ci.org/woodpecker/v2/pipeline/backend/types"
)
@ -130,14 +131,25 @@ func convertDAGToStages(steps map[string]*dagCompilerStep, prefix string) ([]*ba
Alias: fmt.Sprintf("%s_stage_%d", prefix, len(stages)),
}
var stepsToAdd []*dagCompilerStep
for name, step := range steps {
if allDependenciesSatisfied(step, addedSteps) {
stage.Steps = append(stage.Steps, step.step)
stepsToAdd = append(stepsToAdd, step)
addedNodesThisLevel[name] = struct{}{}
delete(steps, name)
}
}
// as steps are from a map that has no deterministic order,
// we sort the steps by original config position to make the order similar between pipelines
sort.Slice(stepsToAdd, func(i, j int) bool {
return stepsToAdd[i].position < stepsToAdd[j].position
})
for i := range stepsToAdd {
stage.Steps = append(stage.Steps, stepsToAdd[i].step)
}
for name := range addedNodesThisLevel {
addedSteps[name] = struct{}{}
}

6
web/components.d.ts vendored
View File

@ -30,16 +30,11 @@ declare module 'vue' {
GeneralTab: typeof import('./src/components/repo/settings/GeneralTab.vue')['default']
Header: typeof import('./src/components/layout/scaffold/Header.vue')['default']
IBiCheckCircleFill: typeof import('~icons/bi/check-circle-fill')['default']
IBiCircle: typeof import('~icons/bi/circle')['default']
IBiExclamationTriangle: typeof import('~icons/bi/exclamation-triangle')['default']
IBiExclamationTriangleFill: typeof import('~icons/bi/exclamation-triangle-fill')['default']
IBiPlayCircleFill: typeof import('~icons/bi/play-circle-fill')['default']
IBiSlashCircleFill: typeof import('~icons/bi/slash-circle-fill')['default']
IBiStopCircleFill: typeof import('~icons/bi/stop-circle-fill')['default']
IBiXCircleFill: typeof import('~icons/bi/x-circle-fill')['default']
IBxBxPowerOff: typeof import('~icons/bx/bx-power-off')['default']
ICarbonCloseOutline: typeof import('~icons/carbon/close-outline')['default']
ICarbonInProgress: typeof import('~icons/carbon/in-progress')['default']
IClarityDeployLine: typeof import('~icons/clarity/deploy-line')['default']
IClaritySettingsSolid: typeof import('~icons/clarity/settings-solid')['default']
Icon: typeof import('./src/components/atomic/Icon.vue')['default']
@ -73,6 +68,7 @@ declare module 'vue' {
IMdiRadioboxIndeterminateVariant: typeof import('~icons/mdi/radiobox-indeterminate-variant')['default']
IMdiSourceBranch: typeof import('~icons/mdi/source-branch')['default']
IMdisourceCommit: typeof import('~icons/mdi/source-commit')['default']
IMdiSourceMerge: typeof import('~icons/mdi/source-merge')['default']
IMdiSourcePull: typeof import('~icons/mdi/source-pull')['default']
IMdiStop: typeof import('~icons/mdi/stop')['default']
IMdiSync: typeof import('~icons/mdi/sync')['default']