mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-05-12 22:10:25 +00:00
As described in [this comment](https://gitea.com/gitea/act_runner/issues/19#issuecomment-739221) one-job runners are not secure when running in host mode. We implemented a routine preventing runner tokens from receiving a second job in order to render a potentially compromised token useless. Also we implemented a routine that removes finished runners as soon as possible. Big thanks to [ChristopherHX](https://github.com/ChristopherHX) who did all the work for gitea! Rel: #9407 ## Checklist The [contributor guide](https://forgejo.org/docs/next/contributor/) contains information that will be helpful to first time contributors. There also are a few [conditions for merging Pull Requests in Forgejo repositories](https://codeberg.org/forgejo/governance/src/branch/main/PullRequestsAgreement.md). You are also welcome to join the [Forgejo development chatroom](https://matrix.to/#/#forgejo-development:matrix.org). ### Tests - I added test coverage for Go changes... - [ ] in their respective `*_test.go` for unit tests. - [x] in the `tests/integration` directory if it involves interactions with a live Forgejo server. - I added test coverage for JavaScript changes... - [ ] in `web_src/js/*.test.js` if it can be unit tested. - [ ] in `tests/e2e/*.test.e2e.js` if it requires interactions with a live Forgejo server (see also the [developer guide for JavaScript testing](https://codeberg.org/forgejo/forgejo/src/branch/forgejo/tests/e2e/README.md#end-to-end-tests)). ### Documentation - [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change. - [ ] I did not document these changes and I do not expect someone else to do it. ### Release notes - [ ] I do not want this change to show in the release notes. - [ ] I want the title to show in the release notes with a link to this pull request. - [ ] I want the content of the `release-notes/<pull request number>.md` to be be used for the release notes instead of the title. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9962 Reviewed-by: Andreas Ahlenstorf <aahlenst@noreply.codeberg.org> Reviewed-by: Mathieu Fenniak <mfenniak@noreply.codeberg.org> Co-authored-by: Manuel Ganter <manuel.ganter@think-ahead.tech> Co-committed-by: Manuel Ganter <manuel.ganter@think-ahead.tech>
85 lines
2.6 KiB
Go
85 lines
2.6 KiB
Go
// Copyright 2023 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package structs
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// ActionTask represents a ActionTask
|
|
type ActionTask struct {
|
|
ID int64 `json:"id"`
|
|
Name string `json:"name"`
|
|
HeadBranch string `json:"head_branch"`
|
|
HeadSHA string `json:"head_sha"`
|
|
RunNumber int64 `json:"run_number"`
|
|
Event string `json:"event"`
|
|
DisplayTitle string `json:"display_title"`
|
|
Status string `json:"status"`
|
|
WorkflowID string `json:"workflow_id"`
|
|
URL string `json:"url"`
|
|
// swagger:strfmt date-time
|
|
CreatedAt time.Time `json:"created_at"`
|
|
// swagger:strfmt date-time
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
// swagger:strfmt date-time
|
|
RunStartedAt time.Time `json:"run_started_at"`
|
|
}
|
|
|
|
// ActionTaskResponse returns a ActionTask
|
|
type ActionTaskResponse struct {
|
|
Entries []*ActionTask `json:"workflow_runs"`
|
|
TotalCount int64 `json:"total_count"`
|
|
}
|
|
|
|
type RunnerStatus int
|
|
|
|
const (
|
|
// RunnerStatusOffline signals that the runner is not connected to Forgejo.
|
|
RunnerStatusOffline RunnerStatus = iota
|
|
|
|
// RunnerStatusIdle means that the runner is connected to Forgejo and waiting for jobs to run.
|
|
RunnerStatusIdle
|
|
|
|
// RunnerStatusActive signifies that the runner is connected to Forgejo and running a job.
|
|
RunnerStatusActive
|
|
)
|
|
|
|
var statusName = map[RunnerStatus]string{
|
|
RunnerStatusOffline: "offline",
|
|
RunnerStatusIdle: "idle",
|
|
RunnerStatusActive: "active",
|
|
}
|
|
|
|
func (status RunnerStatus) String() string {
|
|
return statusName[status]
|
|
}
|
|
|
|
// ActionRunner represents a runner
|
|
// swagger:model
|
|
type ActionRunner struct {
|
|
// ID uniquely identifies this runner.
|
|
ID int64 `json:"id"`
|
|
// UUID uniquely identifies this runner.
|
|
UUID string `json:"uuid"`
|
|
// OwnerID is the identifier of the user or organization this runner belongs to. O if the runner is owned by a
|
|
// repository.
|
|
OwnerID int64 `json:"owner_id"`
|
|
// RepoID is the identifier of the repository this runner belongs to. 0 if the runner belongs to a user or
|
|
// organization.
|
|
RepoID int64 `json:"repo_id"`
|
|
// Name of the runner; not unique.
|
|
Name string `json:"name"`
|
|
// Status indicates whether this runner is offline, or active, for example.
|
|
// enum: ["offline", "idle", "active"]
|
|
Status string `json:"status"`
|
|
// Version is the self-reported version string of Forgejo Runner.
|
|
Version string `json:"version"`
|
|
// Labels is a list of labels attached to this runner.
|
|
Labels []string `json:"labels"`
|
|
// Description provides optional details about this runner.
|
|
Description string `json:"description"`
|
|
// Indicates if runner is ephemeral runner
|
|
Ephemeral bool `json:"ephemeral"`
|
|
}
|