mirror of
https://github.com/hanzoai/forge.git
synced 2026-10-30 15:00:39 +00:00
No compat with old Gitea deployments, so the wire values that were held back
for it go too.
.gitea/* WorkflowDirs is now {.hanzo, .github}/workflows. Same for the
PR-template, ISSUE_TEMPLATE and repo-template lookups, which
each carried a .gitea variant. .github stays — GitHub compat
is worth having; Gitea compat is what we just decided not to
keep.
webhook type "gitea" -> "native", constant GITEA -> NATIVE, routes
/hooks/gitea/{new,id} -> /hooks/native/{new,id}, and the enum
in both swagger documents.
actions context gitea_runtime_token -> git_runtime_token,
gitea_default_actions_url -> git_default_actions_url.
models/migrations/* is untouched on purpose. A schema migration describes what
the database held AT THAT VERSION; v1_14/v162.go rewriting its own history to
say "native" would make it wrong about the thing it exists to migrate.
Three test fixtures needed aligning rather than renaming, all the same shape as
the bugs this cleanup keeps finding: WorkflowDirs expectations ended up with a
duplicated .hanzo entry, the repo-template test built its fixture under .gitea,
and five API tests still posted Type: "gitea" (422 now, correctly).
models, modules, services, routers green; integration compile gate green.
Co-authored-by: Hanzo Dev <[email protected]>
93 lines
3.6 KiB
Go
93 lines
3.6 KiB
Go
// Copyright 2026 Hanzo AI, Inc. All rights reserved.
|
|
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package integration
|
|
|
|
import (
|
|
"fmt"
|
|
"net/url"
|
|
"os"
|
|
"testing"
|
|
|
|
runnerv1 "github.com/hanzo-git/actions-proto-go/runner/v1"
|
|
actions_model "github.com/hanzoai/git/models/actions"
|
|
auth_model "github.com/hanzoai/git/models/auth"
|
|
"github.com/hanzoai/git/models/dbfs"
|
|
repo_model "github.com/hanzoai/git/models/repo"
|
|
"github.com/hanzoai/git/models/unittest"
|
|
user_model "github.com/hanzoai/git/models/user"
|
|
actions_module "github.com/hanzoai/git/modules/actions"
|
|
"github.com/hanzoai/git/modules/storage"
|
|
|
|
"connectrpc.com/connect"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
// Regression for https://gitea.com/gitea/runner/issues/950: a runner that
|
|
// finalizes a task with no log output sends UpdateLog{Rows:[], NoMore:true}.
|
|
// The previous short-circuit on len(Rows)==0 skipped TransferLogs, leaving
|
|
// an orphan dbfs_data row. Verify the row is now archived and removed.
|
|
func TestActionsLogFinalizeWithoutRows(t *testing.T) {
|
|
onGitRun(t, func(t *testing.T, _ *url.URL) {
|
|
user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
|
|
session := loginUser(t, user2.Name)
|
|
token := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeWriteRepository, auth_model.AccessTokenScopeWriteUser)
|
|
|
|
apiRepo := createActionsTestRepo(t, token, "actions-finalize-no-rows", false)
|
|
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: apiRepo.ID})
|
|
|
|
runner := newMockRunner()
|
|
runner.registerAsRepoRunner(t, user2.Name, repo.Name, "mock-runner", []string{"ubuntu-latest"}, false)
|
|
|
|
const wfTreePath = ".hanzo/workflows/finalize-no-rows.yml"
|
|
wfFileContent := fmt.Sprintf(`name: finalize-no-rows
|
|
on:
|
|
push:
|
|
paths:
|
|
- '%s'
|
|
jobs:
|
|
job1:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- run: noop
|
|
`, wfTreePath)
|
|
createWorkflowFile(t, token, user2.Name, repo.Name, wfTreePath, getWorkflowCreateFileOptions(user2, repo.DefaultBranch, "trigger", wfFileContent))
|
|
|
|
task := runner.fetchTask(t)
|
|
|
|
resp, err := runner.client.runnerServiceClient.UpdateLog(t.Context(), connect.NewRequest(&runnerv1.UpdateLogRequest{
|
|
TaskId: task.Id,
|
|
Index: 0,
|
|
Rows: nil,
|
|
NoMore: true,
|
|
}))
|
|
require.NoError(t, err)
|
|
assert.EqualValues(t, 0, resp.Msg.AckIndex)
|
|
|
|
freshTask := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionTask{ID: task.Id})
|
|
require.True(t, freshTask.LogInStorage, "log_in_storage must flip after empty NoMore=true")
|
|
|
|
_, err = storage.Actions.Stat(freshTask.LogFilename)
|
|
assert.NoError(t, err, "archived log must exist in storage")
|
|
|
|
_, err = dbfs.Open(t.Context(), actions_module.DBFSPrefix+freshTask.LogFilename)
|
|
assert.ErrorIs(t, err, os.ErrNotExist, "DBFS row must be cleaned up after TransferLogs")
|
|
|
|
// The runner re-sends its final UpdateLog when the response was lost.
|
|
// A sealed log must ack the re-send and still reject new appended rows.
|
|
t.Run("re-sent finalize is idempotent", func(t *testing.T) {
|
|
finalize := &runnerv1.UpdateLogRequest{TaskId: task.Id, Index: 0, Rows: nil, NoMore: true}
|
|
resp, err := runner.client.runnerServiceClient.UpdateLog(t.Context(), connect.NewRequest(finalize))
|
|
require.NoError(t, err)
|
|
assert.EqualValues(t, 0, resp.Msg.AckIndex)
|
|
|
|
_, err = runner.client.runnerServiceClient.UpdateLog(t.Context(), connect.NewRequest(&runnerv1.UpdateLogRequest{
|
|
TaskId: task.Id, Index: 0, Rows: []*runnerv1.LogRow{{Content: "late"}}, NoMore: true,
|
|
}))
|
|
require.Error(t, err, "appending rows past the seal must be rejected")
|
|
})
|
|
})
|
|
}
|