Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
48fd5ff
list-conforma-*: add --scenario flag for acs-conforma-prod-like
tommartensen Nov 13, 2026
80a0887
add relacs serve command with tag page
tommartensen Nov 3, 2026
4b4a6ec
return error if no pipelinerun groups are found
tommartensen Nov 3, 2026
30b8498
add repository selector to relacs serve
tommartensen Nov 12, 2026
bf8544d
serve: adapt to the new ListConformaViolations signature
tommartensen Nov 13, 2026
948550f
serve: group conforma violations by component version with arch filter
tommartensen Nov 13, 2026
7a23917
serve: note that conforma violations are for the dev policy only
tommartensen Nov 13, 2026
d807efe
serve: render conforma violations for all repositories
tommartensen Nov 13, 2026
19e8373
serve: render the conforma policy note for all repositories
tommartensen Nov 13, 2026
180eb6e
serve: link the custom snapshot in the conforma policy note
tommartensen Nov 13, 2026
b29db1a
serve: reword the conforma policy note
tommartensen Nov 13, 2026
13093bd
serve: pass the conforma scenario explicitly
tommartensen Nov 13, 2026
459c758
conforma: carry URL and reason for skipped and in-progress runs
tommartensen Nov 13, 2026
6cb1f56
serve: add Conforma Release Preview widget and combined tag status
tommartensen Nov 13, 2026
02cd00f
serve: point the conforma policy note at the Release Preview widget
tommartensen Nov 13, 2026
c2a8193
serve: sort pipeline run groups into release milestones
tommartensen Nov 13, 2026
3afc517
serve: rename the pipeline milestones
tommartensen Nov 13, 2026
08dddaf
serve: drop the conforma policy note from the status box
tommartensen Nov 13, 2026
62c4f39
serve: display the component label as the pipeline run group name
tommartensen Nov 13, 2026
856c104
serve: add retest instructions modal to the pipeline milestones
tommartensen Nov 13, 2026
ca0d2b0
serve: right-align the pipeline milestone retest button
tommartensen Nov 13, 2026
dea5c05
serve: show running status for pipeline groups and widget
tommartensen Nov 13, 2026
71f05f0
serve: compute the pipeline running status before the error return
tommartensen Nov 13, 2026
98adbf9
serve: offer retest instructions per failed component group
tommartensen Nov 13, 2026
59fd9d7
serve: fix arch filter default and treat running conforma as waiting
tommartensen Nov 13, 2026
ac0d0e2
serve: show waiting badge on the Conforma Dev widget
tommartensen Nov 13, 2026
1695001
serve: copy button for the retest instructions
tommartensen Nov 13, 2026
e4dfc5d
serve: one retest comment per failed pipeline in the milestone modal
tommartensen Nov 13, 2026
66c153d
serve: more space between the suggested retest comments
tommartensen Nov 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions cmd/relacs/konflux/list_conforma_runs.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,19 @@ var listConformaRunsCmd = &cobra.Command{
Short: "List the conforma pipeline runs triggered by a given Git tag",
Long: `List the conforma pipeline run results for a specific Git tag.

Only conforma runs triggered directly on the tag's commit (via
pipelines-as-code) are considered; the conforma run for the custom
snapshot is not included.`,
RunE: common.RunCommand(runListConformaRuns),
By default (scenario acs-conforma-dev), only conforma runs triggered
directly on the tag's commit (via pipelines-as-code) are considered.
With --scenario acs-conforma-prod-like (only supported for the
stackrox repository), the conforma runs attached to the tag's custom
snapshot are listed instead.`,
RunE: common.RunCommand(runListConformaRuns),
}

func init() {
listConformaRunsCmd.Flags().String("org", config.GitHubOrganization, "GitHub organization (optional)")
listConformaRunsCmd.Flags().String("repo", config.MainGitHubRepository, "GitHub repository (optional)")
listConformaRunsCmd.Flags().String("tag", "", "Git tag (required)")
listConformaRunsCmd.Flags().String("scenario", konflux.ConformaScenarioDev, "Conforma scenario: "+konflux.ConformaScenarioDev+" or "+konflux.ConformaScenarioProdLike+" (the latter is only supported for the stackrox repository)")

//nolint:errcheck
listConformaRunsCmd.MarkFlagRequired("tag")
Expand All @@ -80,8 +83,9 @@ func runListConformaRuns(cmd *cobra.Command, args []string, c *client.Client) (a
org, _ := cmd.Flags().GetString("org")
repo, _ := cmd.Flags().GetString("repo")
tag, _ := cmd.Flags().GetString("tag")
scenario, _ := cmd.Flags().GetString("scenario")

entries, err := konflux.ListConformaRuns(ctx, c, org, repo, tag)
entries, err := konflux.ListConformaRuns(ctx, c, org, repo, tag, scenario)
if err != nil {
return nil, fmt.Errorf("failed to list conforma runs: %w", err)
}
Expand Down
42 changes: 27 additions & 15 deletions cmd/relacs/konflux/list_conforma_violations.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import (
)

type ConformaViolationsOutput struct {
Organization string `json:"organization" yaml:"organization"`
Repository string `json:"repository" yaml:"repository"`
Tag string `json:"tag" yaml:"tag"`
Violations konflux.Violations `json:"violations" yaml:"violations"`
SkippedRuns []string `json:"skippedRuns" yaml:"skippedRuns"`
InProgressRuns []string `json:"inProgressRuns" yaml:"inProgressRuns"`
Organization string `json:"organization" yaml:"organization"`
Repository string `json:"repository" yaml:"repository"`
Tag string `json:"tag" yaml:"tag"`
Violations konflux.Violations `json:"violations" yaml:"violations"`
SkippedRuns []konflux.ConformaRunInfo `json:"skippedRuns" yaml:"skippedRuns"`
InProgressRuns []konflux.ConformaRunInfo `json:"inProgressRuns" yaml:"inProgressRuns"`
}

func (c ConformaViolationsOutput) String() string {
Expand All @@ -34,13 +34,13 @@ func (c ConformaViolationsOutput) String() string {
if len(c.InProgressRuns) > 0 {
output += fmt.Sprintln("In-progress runs:")
for _, run := range c.InProgressRuns {
output += fmt.Sprintf(" - %s\n", run)
output += fmt.Sprintf(" - %s (%s)\n", run.Name, run.URL)
}
}
if len(c.SkippedRuns) > 0 {
output += fmt.Sprintln("Skipped runs (no report available):")
for _, run := range c.SkippedRuns {
output += fmt.Sprintf(" - %s\n", run)
output += fmt.Sprintf(" - %s: %s\n", run.Name, run.Reason)
}
}
return output
Expand All @@ -51,16 +51,19 @@ var listConformaViolationsCmd = &cobra.Command{
Short: "List the Conforma violations for a given Git tag",
Long: `Retrieve the Conforma violations reported by the conforma pipeline runs for a given Git tag.

Only conforma runs triggered directly on the tag's commit (via
pipelines-as-code) are considered; the conforma run for the custom
snapshot is not included.`,
RunE: common.RunCommand(runListConformaViolations),
By default (scenario acs-conforma-dev), only conforma runs triggered
directly on the tag's commit (via pipelines-as-code) are considered.
With --scenario acs-conforma-prod-like (only supported for the
stackrox repository), the violations of the conforma runs attached
to the tag's custom snapshot are listed instead.`,
RunE: common.RunCommand(runListConformaViolations),
}

func init() {
listConformaViolationsCmd.Flags().String("org", config.GitHubOrganization, "GitHub organization (optional)")
listConformaViolationsCmd.Flags().String("repo", config.MainGitHubRepository, "GitHub repository (optional)")
listConformaViolationsCmd.Flags().String("tag", "", "Git tag (required)")
listConformaViolationsCmd.Flags().String("scenario", konflux.ConformaScenarioDev, "Conforma scenario: "+konflux.ConformaScenarioDev+" or "+konflux.ConformaScenarioProdLike+" (the latter is only supported for the stackrox repository)")

//nolint:errcheck
listConformaViolationsCmd.MarkFlagRequired("tag")
Expand All @@ -72,8 +75,9 @@ func runListConformaViolations(cmd *cobra.Command, args []string, c *client.Clie
org, _ := cmd.Flags().GetString("org")
repo, _ := cmd.Flags().GetString("repo")
tag, _ := cmd.Flags().GetString("tag")
scenario, _ := cmd.Flags().GetString("scenario")

result, err := konflux.ListConformaViolations(ctx, c, org, repo, tag)
result, err := konflux.ListConformaViolations(ctx, c, org, repo, tag, scenario)
if err != nil {
return nil, fmt.Errorf("failed to list conforma violations: %w", err)
}
Expand All @@ -90,14 +94,22 @@ func runListConformaViolations(cmd *cobra.Command, args []string, c *client.Clie
// The result is partial: still render the output, but exit non-zero.
var reasons []string
if len(result.SkippedRuns) > 0 {
reasons = append(reasons, fmt.Sprintf("no conforma report available for %d run(s): %s", len(result.SkippedRuns), strings.Join(result.SkippedRuns, ", ")))
reasons = append(reasons, fmt.Sprintf("no conforma report available for %d run(s): %s", len(result.SkippedRuns), runNames(result.SkippedRuns)))
}
if len(result.InProgressRuns) > 0 {
reasons = append(reasons, fmt.Sprintf("%d conforma run(s) still in progress: %s", len(result.InProgressRuns), strings.Join(result.InProgressRuns, ", ")))
reasons = append(reasons, fmt.Sprintf("%d conforma run(s) still in progress: %s", len(result.InProgressRuns), runNames(result.InProgressRuns)))
}
return output, &common.PartialResultError{
Err: fmt.Errorf("%s", strings.Join(reasons, "; ")),
}
}
return output, nil
}

func runNames(runs []konflux.ConformaRunInfo) string {
names := make([]string, len(runs))
for i, run := range runs {
names[i] = run.Name
}
return strings.Join(names, ", ")
}
2 changes: 2 additions & 0 deletions cmd/relacs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/spf13/cobra"
"github.com/stackrox/relacs/cmd/relacs/github"
"github.com/stackrox/relacs/cmd/relacs/konflux"
"github.com/stackrox/relacs/cmd/relacs/serve"
"github.com/stackrox/relacs/cmd/relacs/version"
"github.com/stackrox/relacs/pkg/versioncheck"
)
Expand Down Expand Up @@ -46,6 +47,7 @@ func main() {
rootCmd.AddCommand(version.VersionCmd)
rootCmd.AddCommand(github.GitHubCmd)
rootCmd.AddCommand(konflux.KonfluxCmd)
rootCmd.AddCommand(serve.ServeCmd)

// Execute root command
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
Expand Down
95 changes: 95 additions & 0 deletions cmd/relacs/serve/cmd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package serve

import (
"context"
"embed"
"fmt"
"html/template"
"io/fs"
"log"
"net"
"net/http"
"time"

"github.com/spf13/cobra"
"github.com/stackrox/relacs/pkg/client"
)

//go:embed templates/*
var templateFS embed.FS

var (
homeTmpl *template.Template
tagTmpl *template.Template
)

var port string

var ServeCmd = &cobra.Command{
Use: "serve",
Short: "Start a local web server showing release information",
Long: `Starts a local HTTP server that serves release information as web pages`,
RunE: runServe,
}

func init() {
ServeCmd.Flags().StringVar(&port, "port", "8080", "Port to listen on")
}

func parsePageTemplate(files ...string) (*template.Template, error) {
return template.ParseFS(templateFS, files...)
}

func runServe(cmd *cobra.Command, args []string) error {
var err error
homeTmpl, err = parsePageTemplate("templates/base.html", "templates/home.html")
if err != nil {
return fmt.Errorf("failed to parse home template: %w", err)
}
tagTmpl, err = parsePageTemplate("templates/base.html", "templates/tag.html")
if err != nil {
return fmt.Errorf("failed to parse tag template: %w", err)
}

c, err := client.NewClient()
if err != nil {
return fmt.Errorf("failed to create client: %w", err)
}

staticFS, err := fs.Sub(templateFS, "templates/static")
if err != nil {
return fmt.Errorf("failed to create static file system: %w", err)
}

mux := http.NewServeMux()
mux.Handle("GET /static/", http.StripPrefix("/static/", http.FileServer(http.FS(staticFS))))
mux.HandleFunc("GET /{$}", handleHome())
mux.HandleFunc("GET /tag", handleTag(c))

addr := net.JoinHostPort("localhost", port)
server := &http.Server{
Addr: addr,
Handler: mux,
ReadHeaderTimeout: 10 * time.Second,
}

ctx := cmd.Context()
shutdownDone := make(chan struct{})
go func() {
defer close(shutdownDone)
<-ctx.Done()
shutdownCtx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
if err := server.Shutdown(shutdownCtx); err != nil {
log.Printf("Server shutdown error: %v", err)
}
}()

log.Printf("Server listening on http://%s", addr)
err = server.ListenAndServe()
if err == http.ErrServerClosed {
<-shutdownDone
return nil
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
return err
}
48 changes: 48 additions & 0 deletions cmd/relacs/serve/handlers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package serve

import (
"bytes"
"html/template"
"log"
"net/http"

"github.com/stackrox/relacs/pkg/client"
"github.com/stackrox/relacs/pkg/config"
"github.com/stackrox/relacs/pkg/serve"
)

func renderTemplate(w http.ResponseWriter, tmpl *template.Template, data any) {
var buf bytes.Buffer
// Start rendering from the outermost template; it pulls in child-defined blocks.
if err := tmpl.ExecuteTemplate(&buf, "base.html", data); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
_, err := buf.WriteTo(w)
if err != nil {
log.Printf("Failed to write template to response: %v", err)
}
}

func handleHome() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
renderTemplate(w, homeTmpl, nil)
}
}

func handleTag(c *client.Client) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
tag := r.URL.Query().Get("tag")
if tag == "" {
http.Error(w, "Missing required query parameter: tag", http.StatusBadRequest)
return
}
repo := r.URL.Query().Get("repo")
if repo == "" {
repo = config.MainGitHubRepository
}

data := serve.FetchTagData(r.Context(), c, repo, tag)
renderTemplate(w, tagTmpl, data)
}
}
17 changes: 17 additions & 0 deletions cmd/relacs/serve/templates/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>relacs{{block "title" .}}{{end}}</title>
<link rel="stylesheet" href="/static/style.css">
</head>
<body>
<nav>
<a href="/">relacs</a>
</nav>
<div class="container">
{{block "content" .}}{{end}}
</div>
</body>
</html>
35 changes: 35 additions & 0 deletions cmd/relacs/serve/templates/home.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{{template "base.html" .}}

{{define "title"}} - Home{{end}}

{{define "content"}}
<h1 style="margin-bottom: 1rem;">Tags</h1>

<div class="card">
<h2>Tag</h2>
<p style="margin-bottom: 1rem; color: var(--color-text-secondary);">
View pipeline status, artifacts, and Conforma results for a specific tag.
</p>
<form method="GET" action="/tag">
<div class="form-row">
<div class="form-group">
<label for="repo">Repository</label>
<select id="repo" name="repo">
<option value="collector">collector</option>
<option value="fact">fact</option>
<option value="scanner">scanner</option>
<option value="stackrox" selected>stackrox</option>
</select>
</div>
<div class="form-group" style="flex: 1;">
<label for="tag">Tag</label>
<input type="text" id="tag" name="tag" placeholder="5.0.0-rc.1" required>
</div>
<div class="form-group">
<label>&nbsp;</label>
<button type="submit">Go</button>
</div>
</div>
</form>
</div>
{{end}}
Loading
Loading