mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-13 21:21:09 +00:00
c186cc4b8d
Fixes #38773 ## Background Artifacts became attempt-scoped in #37119, and the runner-facing artifact APIs filter strictly by the attempt of the running job. "Re-run failed jobs" creates a new attempt whose passed-through jobs never upload their artifacts again, so a re-run job that downloads one of them fails with "artifact not found". ## Fix The read paths (v3 and v4 list and download) now resolve artifacts across the running job's attempt plus the attempts it inherits from, and an inherited artifact is shadowed by a same-named one from a newer attempt. ## Note GitHub's documentation does not document these behaviors. The conclusions below are based on manual testing, so consistency with GitHub cannot be guaranteed. - In a "partial re-run", a job can download artifacts uploaded by an earlier attempt, every attempt keeps its own copy of a name, and a lookup by name resolves to the newest one. - A full "Re-run all jobs" never downloads artifacts from earlier attempts. --------- Co-authored-by: bircni <bircni@icloud.com>
28 lines
839 B
Go
28 lines
839 B
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package actions
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestKeepLatestAttemptArtifacts(t *testing.T) {
|
|
arts := []*ActionArtifact{
|
|
{ID: 1, RunAttemptID: 1, ArtifactName: "inherited"},
|
|
{ID: 2, RunAttemptID: 1, ArtifactName: "shadowed", ArtifactPath: "a.txt"},
|
|
{ID: 3, RunAttemptID: 1, ArtifactName: "shadowed", ArtifactPath: "b.txt"},
|
|
{ID: 4, RunAttemptID: 2, ArtifactName: "shadowed", ArtifactPath: "c.txt"},
|
|
{ID: 5, RunAttemptID: 2, ArtifactName: "own"},
|
|
}
|
|
|
|
// the whole "shadowed" group of attempt 1 is dropped, its multi-file rows must not mix with attempt 2
|
|
var ids []int64
|
|
for _, art := range keepLatestAttemptArtifacts(arts) {
|
|
ids = append(ids, art.ID)
|
|
}
|
|
assert.Equal(t, []int64{1, 4, 5}, ids)
|
|
}
|