mirror of
https://gitea.com/gitea/runner.git
synced 2026-11-17 21:33:43 +00:00
fix: stop pruning the cached action ref on refresh (#1312)
The action cache refresh fetched with `--prune` and the unqualified refspec `+<ref>:refs/runner/<hash>`. Git cannot map that ref back to a remote ref, so it deleted it on every other refresh. The first job after a branch or tag moved then failed with `cannot lock ref`, and a moved tag in a full clone could silently run its old commit. `--no-prune` fixes this and also overrides an inherited `fetch.prune`. Fixes: https://gitea.com/gitea/runner/issues/1311 Reviewed-on: https://gitea.com/gitea/runner/pulls/1312 Reviewed-by: Lunny Xiao <[email protected]> Reviewed-by: Zettat123 <[email protected]>
This commit is contained in:
1 parent
470969dc74
commit
42858c61df
7 files changed
+87
-5
No files matched your search
@@ -0,0 +1,48 @@
|
||||
// Copyright 2026 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
//go:build e2e
|
||||
|
||||
package e2e
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func testMovingActionRef(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := t.Context()
|
||||
|
||||
api, repo, _ := startIsolatedScenario(t, "action_ref.yml", "e2e-action-ref", runnerOptions{})
|
||||
const actionRepo = "e2e-moving-action"
|
||||
if err := api.CreateRepo(ctx, actionRepo); err != nil {
|
||||
t.Fatalf("create action repo: %v", err)
|
||||
}
|
||||
action, err := os.ReadFile("testdata/actions/moving.yml")
|
||||
if err != nil {
|
||||
t.Fatalf("read action fixture: %v", err)
|
||||
}
|
||||
if err := api.CreateFile(ctx, actionRepo, "action.yml", string(action), "add action"); err != nil {
|
||||
t.Fatalf("push action: %v", err)
|
||||
}
|
||||
branch, err := api.DefaultBranch(ctx, repo)
|
||||
if err != nil {
|
||||
t.Fatalf("get default branch: %v", err)
|
||||
}
|
||||
|
||||
var previousID int64
|
||||
for revision := range 3 {
|
||||
name := fmt.Sprintf("revision-%d", revision)
|
||||
if err := api.CreateFile(ctx, actionRepo, name, name, "add "+name); err != nil {
|
||||
t.Fatalf("move the action ref: %v", err)
|
||||
}
|
||||
if err := waitForDispatch(ctx, api, repo, "action_ref.yml", branch, map[string]string{"revision": name}); err != nil {
|
||||
t.Fatalf("dispatch workflow: %v", err)
|
||||
}
|
||||
wfRun := waitForRunAfter(t, api, repo, previousID)
|
||||
requireSuccess(t, api, repo, wfRun.ID)
|
||||
previousID = wfRun.ID
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user