fix(ci): job relaunched are positioned at the end of the pipeline
Following https://github.com/zaquestion/lab/issues/471, another problem occurs in the same time.
The order is now correct in the ci view, but if I restart a failed job, the job is inserted at the end of the pipeline.
I'm not sure this is fixable.
There is code to replace old jobs with restarted ones, but in my testing gitlab now only includes the most recent jobs in the listing, so this no longer works.
It should be possible to do slightly better by making sure that all jobs from the same stage are grouped together, but as we don't know the expected order of the stages, it's possible that we then mess up that order (say, showing "deploy" jobs before "build").
But as far as I can see, a proper fix needs additional gitlab API (at the very least, an option to list all jobs in a pipeline, including those superseded by restarted jobs)
For reference here's the code that originally addressed this by picking the latest versions of jobs
https://github.com/zaquestion/lab/blob/master/cmd/ci_view.go#L604-L630
cc: @profclems this is probably an issue for y'all too