mirror of
https://gitea.com/gitea/runner.git
synced 2026-08-24 04:47:45 +00:00
8260e2def2
Adds a real-Gitea compatibility suite against stable and nightly to catch runner and API drift before release. The suite shares one Gitea and regular runner, using repository runners only for cache v1/v2 and ephemeral behavior. It covers registration, payload and log encoding, secrets, variables, services, artifacts, outputs, matrices, cache, dispatch, live logs, cancellation, and ephemeral teardown. CI runs both images in parallel. Warm local timings: | Image | Before | After | | --- | ---: | ---: | | `gitea/gitea:latest` | ~70s | 26.54s | | `gitea/gitea:main-nightly` | ~54s | 22.53s | The former serial matrix took about 2 minutes. Parallel suite execution is now bounded by the slower ~26.5-second variant. Shared Renovate matcher: https://gitea.com/gitea/renovate-config/pulls/552 --------- Co-authored-by: silverwind <me@silverwind.io> Reviewed-on: https://gitea.com/gitea/runner/pulls/1180 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Reviewed-by: silverwind <2021+silverwind@noreply.gitea.com> Co-authored-by: bircni <bircni@icloud.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, 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, 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, "dispatch.yml", branch, inputs)
|
|
if lastErr == nil {
|
|
return nil
|
|
}
|
|
select {
|
|
case <-ctx.Done():
|
|
return lastErr
|
|
case <-time.After(pollInterval):
|
|
}
|
|
}
|
|
}
|