gitea/modules/structs/actions_capabilities.go
GitCaddy a3c1aa3011
Some checks failed
Build and Release / Lint (push) Failing after 2m0s
Build and Release / Unit Tests (push) Successful in 2m52s
Build and Release / Create Release (push) Has been skipped
Build and Release / Build Binaries (amd64, darwin) (push) Has been skipped
Build and Release / Build Binaries (amd64, linux) (push) Has been skipped
Build and Release / Build Binaries (amd64, windows) (push) Has been skipped
Build and Release / Build Binaries (arm64, darwin) (push) Has been skipped
Build and Release / Build Binaries (arm64, linux) (push) Has been skipped
Build and Release / Integration Tests (PostgreSQL) (push) Successful in 1m2s
feat: add bandwidth display to runner capabilities panel
- Add BandwidthInfo struct for bandwidth test results
- Display download speed and latency in runner edit page
- Show when the bandwidth test was last performed
- Add locale string for bandwidth label

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-11 07:45:39 +00:00

114 lines
4.4 KiB
Go

// Copyright 2026 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package structs
import "time"
// BandwidthInfo holds network bandwidth test results
type BandwidthInfo struct {
DownloadMbps float64 `json:"download_mbps"`
UploadMbps float64 `json:"upload_mbps,omitempty"`
Latency float64 `json:"latency_ms,omitempty"`
TestedAt time.Time `json:"tested_at"`
}
// DiskInfo holds disk space information for a runner
type DiskInfo struct {
Total uint64 `json:"total_bytes"`
Free uint64 `json:"free_bytes"`
Used uint64 `json:"used_bytes"`
UsedPercent float64 `json:"used_percent"`
}
// RunnerCapability represents the detailed capabilities of a runner
type RunnerCapability struct {
OS string `json:"os"`
Arch string `json:"arch"`
Docker bool `json:"docker"`
DockerCompose bool `json:"docker_compose"`
ContainerRuntime string `json:"container_runtime,omitempty"`
Shell []string `json:"shell,omitempty"`
Tools map[string][]string `json:"tools,omitempty"`
Features *CapabilityFeatures `json:"features,omitempty"`
Limitations []string `json:"limitations,omitempty"`
Disk *DiskInfo `json:"disk,omitempty"`
Bandwidth *BandwidthInfo `json:"bandwidth,omitempty"`
}
// CapabilityFeatures represents feature support flags
type CapabilityFeatures struct {
ArtifactsV4 bool `json:"artifacts_v4"`
Cache bool `json:"cache"`
Services bool `json:"services"`
CompositeActions bool `json:"composite_actions"`
}
// ActionSupport represents version support for an action
type ActionSupport struct {
Versions []string `json:"versions"`
Notes string `json:"notes,omitempty"`
}
// PlatformInfo represents Gitea platform capabilities
type PlatformInfo struct {
Type string `json:"type"`
Version string `json:"version"`
ActionsVersion string `json:"actions_version,omitempty"`
DefaultActionsURL string `json:"default_actions_url"`
SupportedActions map[string]ActionSupport `json:"supported_actions,omitempty"`
UnsupportedFeatures []string `json:"unsupported_features,omitempty"`
}
// WorkflowHints provides hints for AI workflow generation
type WorkflowHints struct {
PreferredCheckout string `json:"preferred_checkout,omitempty"`
ArtifactUploadAlternative string `json:"artifact_upload_alternative,omitempty"`
SecretAccess string `json:"secret_access,omitempty"`
}
// RunnerWithCapabilities represents a runner with its capabilities for API response
type RunnerWithCapabilities struct {
ID int64 `json:"id"`
Name string `json:"name"`
Status string `json:"status"`
Labels []string `json:"labels"`
Capabilities *RunnerCapability `json:"capabilities,omitempty"`
}
// ActionsCapabilitiesResponse is the response for the capabilities endpoint
type ActionsCapabilitiesResponse struct {
Runners []*RunnerWithCapabilities `json:"runners"`
Platform *PlatformInfo `json:"platform"`
WorkflowHints *WorkflowHints `json:"workflow_hints,omitempty"`
}
// WorkflowValidationRequest is the request for workflow validation
type WorkflowValidationRequest struct {
Content string `json:"content" binding:"Required"`
}
// WorkflowValidationWarning represents a validation warning
type WorkflowValidationWarning struct {
Line int `json:"line,omitempty"`
Action string `json:"action,omitempty"`
Severity string `json:"severity"`
Message string `json:"message"`
Suggestion string `json:"suggestion,omitempty"`
}
// RunnerMatch represents job-to-runner matching result
type RunnerMatch struct {
Job string `json:"job"`
RunsOn []string `json:"runs_on"`
MatchedRunners []string `json:"matched_runners,omitempty"`
CapabilitiesMet bool `json:"capabilities_met"`
}
// WorkflowValidationResponse is the response for workflow validation
type WorkflowValidationResponse struct {
Valid bool `json:"valid"`
Warnings []*WorkflowValidationWarning `json:"warnings,omitempty"`
RunnerMatch []*RunnerMatch `json:"runner_match,omitempty"`
}