mirror of
https://gitea.com/gitea/act_runner.git
synced 2026-10-28 19:06:02 +08:00
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>
55 lines
1.3 KiB
Go
55 lines
1.3 KiB
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
//go:build e2e
|
|
|
|
package e2e
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func testWorkflowDispatch(t *testing.T) {
|
|
t.Parallel()
|
|
ctx := t.Context()
|
|
|
|
api, repo := newScenario(t)
|
|
pushWorkflow(t, api, repo, "dispatch.yml")
|
|
|
|
branch, err := api.DefaultBranch(ctx, repo)
|
|
if err != nil {
|
|
t.Fatalf("get default branch: %v", err)
|
|
}
|
|
inputs := map[string]string{"subject": "dispatch-input-value"}
|
|
if err := waitForDispatch(ctx, api, repo, "dispatch.yml", branch, inputs); err != nil {
|
|
t.Fatalf("dispatch workflow: %v", err)
|
|
}
|
|
|
|
dispatched := waitForRun(t, api, repo)
|
|
if dispatched.Event != "workflow_dispatch" {
|
|
t.Fatalf("run event is %q, want workflow_dispatch", dispatched.Event)
|
|
}
|
|
requireSuccess(t, api, repo, dispatched.ID)
|
|
}
|
|
|
|
// Gitea indexes workflows asynchronously after the Contents API commit.
|
|
func waitForDispatch(ctx context.Context, api *GiteaAPI, repo, workflow, branch string, inputs map[string]string) error {
|
|
ctx, cancel := context.WithTimeout(ctx, time.Minute)
|
|
defer cancel()
|
|
|
|
var lastErr error
|
|
for {
|
|
lastErr = api.DispatchWorkflow(ctx, repo, workflow, branch, inputs)
|
|
if lastErr == nil {
|
|
return nil
|
|
}
|
|
select {
|
|
case <-ctx.Done():
|
|
return lastErr
|
|
case <-time.After(pollInterval):
|
|
}
|
|
}
|
|
}
|