Files
act_runner/e2e/action_ref_test.go
silverwind 42858c61df 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 <xiaolunwen@gmail.com>
Reviewed-by: Zettat123 <39446+zettat123@noreply.gitea.com>
2026-10-14 13:15:01 +00:00

49 lines
1.3 KiB
Go

// 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
}
}