diff --git a/.cspell-words.txt b/.cspell-words.txt index bfc0acd..10b6324 100644 --- a/.cspell-words.txt +++ b/.cspell-words.txt @@ -223,3 +223,5 @@ sdkmetric stdr metricdata nilerr +cibackfill +embedsrcs diff --git a/cmd/github-metrics/main.go b/cmd/github-metrics/main.go index bc48237..31c5655 100644 --- a/cmd/github-metrics/main.go +++ b/cmd/github-metrics/main.go @@ -36,6 +36,7 @@ import ( "go.opentelemetry.io/otel/metric" "github.com/tbhb-dev/github-metrics/internal/receiver" + "github.com/tbhb-dev/github-metrics/internal/reconcile" "github.com/tbhb-dev/github-metrics/internal/recorder" "github.com/tbhb-dev/github-metrics/internal/store" "github.com/tbhb-dev/github-metrics/internal/telemetry" @@ -83,12 +84,18 @@ func main() { } } +//nolint:funlen // Startup owns service shutdown ordering. func run(ctx context.Context, addr string, log *slog.Logger) error { cfg, err := reconcilerConfig(os.Getenv) if err != nil { return err } + backfillCfg, err := ciBackfillConfig(os.Getenv) + if err != nil { + return err + } + file := os.Getenv("WEBHOOK_SECRET_FILE") if file == "" { return errNoSecretFile @@ -131,7 +138,7 @@ func run(ctx context.Context, addr string, log *slog.Logger) error { endpoint := os.Getenv("OTEL_EXPORTER_OTLP_ENDPOINT") - consumer, loop, err := newConsumers(ctx, endpoint, cfg, meter, repo, log) + consumer, loop, client, err := newConsumers(ctx, endpoint, cfg, meter, repo, log) if err != nil { shutdownCtx, cancel := context.WithTimeout(context.WithoutCancel(ctx), shutdownTimeout) defer cancel() @@ -155,6 +162,18 @@ func run(ctx context.Context, addr string, log *slog.Logger) error { log.InfoContext(ctx, "listening", "addr", addr) + backfillDone := make(chan struct{}) + + if client != nil && backfillCfg.Days > 0 { + go func() { + defer close(backfillDone) + + reconcile.BackfillCI(ctx, client, repo, log, backfillCfg, time.Now()) + }() + } else { + close(backfillDone) + } + select { case err = <-serveErr: // Shut down the worker and reconciler before closing their store. @@ -166,6 +185,8 @@ func run(ctx context.Context, addr string, log *slog.Logger) error { shutdownCtx, cancel := context.WithTimeout(context.WithoutCancel(ctx), shutdownTimeout) defer cancel() + <-backfillDone + return errors.Join( err, srv.Shutdown(shutdownCtx), <-workerErr, <-reconcileErr, shutdownTelemetry(shutdownCtx), repo.Close(), ) diff --git a/cmd/github-metrics/main_test.go b/cmd/github-metrics/main_test.go index adfa5b1..b3483a7 100644 --- a/cmd/github-metrics/main_test.go +++ b/cmd/github-metrics/main_test.go @@ -271,3 +271,23 @@ func TestReconcilerConfigComplete(t *testing.T) { } } } + +func TestCIBackfillConfig(t *testing.T) { + t.Parallel() + + for _, value := range []string{ + "", "o/r:7", "o/r:1", "o/r:8", "o/r:0", "o/r:-1", + "o/r:day", "o/r", "o:7", "o/r/extra:7", "o/..:7", "o/r:7\n", + } { + cfg, err := ciBackfillConfig(func(string) string { return value }) + valid := value == "" || value == "o/r:7" || value == "o/r:1" + + if valid { + if err != nil || (value != "" && (cfg.Repository != "o/r" || cfg.Days < 1 || cfg.Days > 7)) { + t.Fatalf("config = %+v, error = %v", cfg, err) + } + } else if err == nil || err.Error() != "GITHUB_CI_BACKFILL must name a repository and days from 1 to 7" { + t.Fatalf("expected redacted variable error, got %v", err) + } + } +} diff --git a/cmd/github-metrics/reconciler.go b/cmd/github-metrics/reconciler.go index 20f66bf..06f7bbd 100644 --- a/cmd/github-metrics/reconciler.go +++ b/cmd/github-metrics/reconciler.go @@ -12,6 +12,7 @@ import ( "net/http" "net/url" "os" + "regexp" "strconv" "strings" "time" @@ -40,6 +41,7 @@ var ( errInvalidAppID = errors.New(appIDEnv + " must be a positive integer") errInvalidInstallationID = errors.New(installationIDEnv + " must be a positive integer") errInvalidBaseURL = errors.New(apiURLEnv + " must be a valid HTTPS API base URL") + errInvalidCIBackfill = errors.New("GITHUB_CI_BACKFILL must name a repository and days from 1 to 7") errReadAppKey = errors.New("read " + appKeyFileEnv) ) @@ -93,14 +95,36 @@ func reconcilerConfig(env func(string) string) (reconcileConfig, error) { }, nil } +// ciBackfillConfig validates the trigger even when reconciliation is disabled. +func ciBackfillConfig(env func(string) string) (reconcile.CIConfig, error) { + const name = "GITHUB_CI_BACKFILL" + + var cfg reconcile.CIConfig + + value := env(name) + if value == "" { + return cfg, nil + } + + match := regexp.MustCompile(`^([A-Za-z0-9]+(?:-[A-Za-z0-9]+)*/[A-Za-z0-9_.-]+):([1-7])$`).FindStringSubmatch(value) + if match == nil || strings.HasSuffix(match[1], "/.") || strings.HasSuffix(match[1], "/..") { + return cfg, errInvalidCIBackfill + } + + cfg.Repository = match[1] + cfg.Days = int(match[2][0] - '0') + + return cfg, nil +} + //nolint:ireturn // The worker accepts either recorder through its interface. func newConsumers( ctx context.Context, endpoint string, cfg reconcileConfig, meter metric.Meter, repo *store.Bolt, log *slog.Logger, -) (worker.Recorder, *reconcile.Loop, error) { +) (worker.Recorder, *reconcile.Loop, *ghclient.Client, error) { // cspell:ignore contextcheck consumer, err := newRecorder(endpoint, meter, repo, log) //nolint:contextcheck // Recorder setup seeds its counters. if err != nil { - return nil, nil, err + return nil, nil, nil, err } log.InfoContext(ctx, "recorder mode", "configured", endpoint != "") @@ -109,26 +133,26 @@ func newConsumers( if !configured || cfg.keyFile == "" { log.InfoContext(ctx, "reconciler disabled") - return consumer, nil, nil + return consumer, nil, nil, nil } - loop, err := newReconciler(cfg, meter, record, repo, log) + loop, client, err := newReconciler(cfg, meter, record, repo, log) - return consumer, loop, err + return consumer, loop, client, err } func newReconciler( cfg reconcileConfig, meter metric.Meter, record *recorder.Recorder, repo reconcile.Watermarks, log *slog.Logger, -) (*reconcile.Loop, error) { +) (*reconcile.Loop, *ghclient.Client, error) { // Relative request paths must resolve inside the API base path. base, err := url.Parse(strings.TrimRight(cfg.apiURL, "/") + "/") if err != nil || base.Scheme != "https" { - return nil, errInvalidBaseURL + return nil, nil, errInvalidBaseURL } key, err := os.ReadFile(cfg.keyFile) if err != nil { - return nil, errReadAppKey + return nil, nil, errReadAppKey } source, err := appauth.New(appauth.Config{ @@ -136,14 +160,14 @@ func newReconciler( AppID: cfg.appID, InstallationID: cfg.installationID, }) if err != nil { - return nil, fmt.Errorf("create installation token source: %w", err) + return nil, nil, fmt.Errorf("create installation token source: %w", err) } tags := ghclient.NewETags() client, err := ghclient.New(base.String(), http.DefaultClient, budget.New(), source, tags) if err != nil { - return nil, errInvalidBaseURL + return nil, nil, errInvalidBaseURL } lister := reconcile.NewLister(client, tags, base) @@ -153,10 +177,10 @@ func newReconciler( loop, err := reconcile.NewLoop(pass, meter, log, nil) if err != nil { - return nil, fmt.Errorf("create reconciler loop: %w", err) + return nil, nil, fmt.Errorf("create reconciler loop: %w", err) } - return loop, nil + return loop, client, nil } func startReconciler(ctx context.Context, loop *reconcile.Loop, stop context.CancelFunc) <-chan error { diff --git a/deploy/compose.yaml b/deploy/compose.yaml index 4b87519..3b96e7a 100644 --- a/deploy/compose.yaml +++ b/deploy/compose.yaml @@ -57,6 +57,7 @@ services: STORE_FILE: /var/lib/github-metrics/store.db GITHUB_APP_ID: ${GITHUB_APP_ID:-} GITHUB_INSTALLATION_ID: ${GITHUB_INSTALLATION_ID:-} + GITHUB_CI_BACKFILL: ${GITHUB_CI_BACKFILL:-} GITHUB_API_URL: ${GITHUB_API_URL:-} GITHUB_APP_KEY_FILE: ${GITHUB_APP_ID:+/run/secrets/github_app_key} WEBHOOK_SECRET_FILE: /run/secrets/webhook_secret diff --git a/docs/architecture/11-risks-and-technical-debt.md b/docs/architecture/11-risks-and-technical-debt.md index f08ebfb..430ed92 100644 --- a/docs/architecture/11-risks-and-technical-debt.md +++ b/docs/architecture/11-risks-and-technical-debt.md @@ -21,6 +21,8 @@ | The operator never retires the previous webhook secret or never rotates the App key | An old credential keeps working | Gates of the threat-model follow-up, plan step 6 | New, deferred to step 6 | | Backend access and retention for private-repository names and logins | Wider exposure than the operator intends | The operator confirms it in the threat-model follow-up | Unverified | +Tech debt: CI history backfill caps run and job pages without a resume cursor. A crash after a durable claim can lose a log. Backfilled claims also suppress later live timing metrics. The one-off Loki pass accepts these limits. + ## Plan Step 1 finished. Steps 2, 3, and 5 to 8 remain open work. Today `main` has the receiver, the request budget, and the GitHub client, which are parts of steps 3 and 5. diff --git a/internal/reconcile/BUILD.bazel b/internal/reconcile/BUILD.bazel index 8170f58..85512c9 100644 --- a/internal/reconcile/BUILD.bazel +++ b/internal/reconcile/BUILD.bazel @@ -9,6 +9,7 @@ repo_files() go_library( name = "reconcile", srcs = [ + "cibackfill.go", "events.go", "list.go", "loop.go", @@ -28,11 +29,14 @@ go_library( go_test( name = "reconcile_test", srcs = [ + "cibackfill_test.go", "events_test.go", "list_test.go", "loop_test.go", "run_test.go", ], + data = glob(["testdata/**"]), + embedsrcs = ["testdata/ci_jobs.json"], visibility = ["//:__pkg__"], deps = [ ":reconcile", diff --git a/internal/reconcile/cibackfill.go b/internal/reconcile/cibackfill.go new file mode 100644 index 0000000..fc6100e --- /dev/null +++ b/internal/reconcile/cibackfill.go @@ -0,0 +1,236 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright Tony Burns + +package reconcile + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "log/slog" + "net/url" + "strconv" + "time" + + "github.com/tbhb-dev/github-metrics/internal/budget" + "github.com/tbhb-dev/github-metrics/internal/ghclient" + "github.com/tbhb-dev/github-metrics/internal/recorder" +) + +const ( + completed = "completed" + runPageLimit = 30 + jobPageLimit = 3 +) + +// CIConfig selects one repository and a window of up to seven days. +type CIConfig struct { + Repository string + Days int +} + +// Ledger shares the live recorder's durable job claims. +type Ledger interface { + ClaimMilestone(key string) (bool, error) +} + +type ciPass struct { + client *ghclient.Client + ledger Ledger + log *slog.Logger + start, end time.Time + repository, defaultBranch string + runs, logged, pages, skipped int +} + +// BackfillCI logs exactly one terminal summary, including on cancellation or a claim error. +func BackfillCI( + ctx context.Context, client *ghclient.Client, ledger Ledger, log *slog.Logger, cfg CIConfig, now time.Time, +) { + state := ciPass{ + client: client, ledger: ledger, log: log, repository: cfg.Repository, + defaultBranch: "", start: now.Add(-time.Duration(cfg.Days) * 24 * time.Hour), end: now, + runs: 0, logged: 0, skipped: 0, pages: 0, + } + + log.InfoContext(ctx, "ci backfill started", "repository", cfg.Repository, "days", cfg.Days) + + err := state.walk(ctx, "/repos/"+cfg.Repository+"/actions/runs?per_page=100&created="+ + url.QueryEscape(">="+state.start.Format(time.RFC3339)), runPageLimit, state.recordRuns) + if err == nil { + err = ctx.Err() + } + + fields := []any{ + "repository", cfg.Repository, "runs", state.runs, "jobs_logged", state.logged, + "jobs_skipped", state.skipped, "pages", state.pages, "duration", time.Since(now), + } + + if err != nil { + status := 0 + + if response, ok := errors.AsType[*ghclient.StatusError](err); ok { + status = response.Status + } + + // Error text from dependencies may contain operator configuration; keep only status. + log.ErrorContext(ctx, "ci backfill failed", append(fields, "status", status, "errors", 1)...) + + return + } + + log.InfoContext(ctx, "ci backfill finished", fields...) +} + +func (p *ciPass) walk(ctx context.Context, target string, limit int, visit func(context.Context, []byte) error) error { + for range limit { + response, err := p.client.Get(ctx, budget.Backfill, target) + + p.pages++ + + if err != nil { + return fmt.Errorf("read CI history: %w", err) + } + + if response.NotModified() { + return nil + } + + err = visit(ctx, response.Body) + if err != nil { + return err + } + + if response.Next == "" { + return nil + } + + target = response.Next + } + + return nil +} + +func (p *ciPass) recordRuns(ctx context.Context, body []byte) error { + var page struct { + Runs []struct { + Status string `json:"status"` + Event string `json:"event"` + ID int64 `json:"id"` + } `json:"workflow_runs"` //nolint:tagliatelle // GitHub field name. + } + + err := json.Unmarshal(body, &page) + if err != nil { + return fmt.Errorf("decode runs: %w", err) + } + + for _, run := range page.Runs { + p.runs++ + + if run.Status != completed { + continue + } + + if p.defaultBranch == "" { + response, readErr := p.client.Get(ctx, budget.Backfill, "/repos/"+p.repository) + + p.pages++ + + if readErr != nil { + return fmt.Errorf("read repository: %w", readErr) + } + + var repo struct { + DefaultBranch string `json:"default_branch"` //nolint:tagliatelle // GitHub field name. + } + + err = json.Unmarshal(response.Body, &repo) + if err != nil { + return fmt.Errorf("decode repository: %w", err) + } + + p.defaultBranch = repo.DefaultBranch + } + + err = p.walk(ctx, "/repos/"+p.repository+"/actions/runs/"+strconv.FormatInt(run.ID, 10)+ + "/jobs?per_page=100&filter=all", jobPageLimit, func(ctx context.Context, body []byte) error { + return p.recordJobs(ctx, body, run.Event) + }) + if err != nil { + return err + } + } + + return nil +} + +//nolint:gocognit,cyclop // Keep filtering, claiming and logging in order. +func (p *ciPass) recordJobs(ctx context.Context, body []byte, event string) error { + var page struct { + Jobs []recorder.WorkflowJob `json:"jobs"` + } + + err := json.Unmarshal(body, &page) + if err != nil { + return fmt.Errorf("decode jobs: %w", err) + } + + for _, job := range page.Jobs { + if ctx.Err() != nil { + return fmt.Errorf("cancel backfill: %w", ctx.Err()) + } + + end, parseErr := time.Parse(time.RFC3339, job.CompletedAt) + + if parseErr != nil || end.IsZero() || end.Before(p.start) || end.After(p.end) { + p.skipped++ + + continue + } + + claimed, claimErr := p.ledger.ClaimMilestone(strconv.FormatInt(job.ID, 10) + "\x00ci_job") + if claimErr != nil { + return fmt.Errorf("claim CI job: %w", claimErr) + } + + if !claimed { + p.skipped++ + + continue + } + + record := slog.NewRecord(end, slog.LevelInfo, "ci job finished", 0) + runner := "none" + + if len(job.Labels) > 0 { + runner = job.Labels[0] + } + + record.Add("repository", p.repository, "workflow", job.WorkflowName, "job", job.Name, + "conclusion", job.Conclusion, "event_class", recorder.JobEventClass(job.HeadBranch, p.defaultBranch), + "runner", runner, "head_branch", job.HeadBranch, "head_sha", job.HeadSHA, + "run_id", job.RunID, "job_id", job.ID, "event", event, "source", "backfill") + + for _, duration := range []struct{ name, start, end string }{ + {"queue_seconds", job.CreatedAt, job.StartedAt}, {"run_seconds", job.StartedAt, job.CompletedAt}, + } { + start, startErr := time.Parse(time.RFC3339, duration.start) + finish, endErr := time.Parse(time.RFC3339, duration.end) + + if startErr == nil && endErr == nil && !start.IsZero() && !finish.IsZero() && !finish.Before(start) { + record.Add(duration.name, finish.Sub(start).Seconds()) + } + } + + err = p.log.Handler().Handle(ctx, record) + if err != nil { + return fmt.Errorf("log CI job: %w", err) + } + + p.logged++ + } + + return nil +} diff --git a/internal/reconcile/cibackfill_test.go b/internal/reconcile/cibackfill_test.go new file mode 100644 index 0000000..f53f2eb --- /dev/null +++ b/internal/reconcile/cibackfill_test.go @@ -0,0 +1,210 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright Tony Burns + +package reconcile_test + +import ( + "bytes" + "context" + "encoding/json" + "errors" + "fmt" + "log/slog" + "net/http" + "net/http/httptest" + "strings" + "sync/atomic" + "testing" + "time" + + _ "embed" + + "github.com/tbhb-dev/github-metrics/internal/budget" + "github.com/tbhb-dev/github-metrics/internal/ghclient" + ci "github.com/tbhb-dev/github-metrics/internal/reconcile" +) + +type ledger struct { + claims map[string]bool + err error +} + +func (l ledger) ClaimMilestone(key string) (bool, error) { + if l.err != nil { + return false, l.err + } + + previous := l.claims[key] + l.claims[key] = true + + return !previous, nil +} + +//go:embed testdata/ci_jobs.json +var jobs string + +const ( + capMode = "cap" + forbiddenMode = "forbidden" + runs = `{"workflow_runs":[{"id":1,"status":"completed","event":"schedule"},{"id":2,"status":"in_progress"}]}` +) + +func TestCIBackfill(t *testing.T) { + t.Parallel() + + for _, mode := range []string{"success", forbiddenMode, "decode_error", "claim_error", "cancelled", capMode} { + t.Run(mode, func(t *testing.T) { + t.Parallel() + + var ( + logs bytes.Buffer + calls atomic.Int32 + ) + + server := httptest.NewTLSServer(history(t, mode, &calls)) + + defer server.Close() + + client, err := ghclient.New(server.URL, server.Client(), budget.New(), fakeTokens{}, ghclient.NewETags()) + if err != nil { + t.Fatal(err) + } + + claims := ledger{claims: map[string]bool{"2\x00ci_job": true}, err: nil} + + if mode == "claim_error" { + claims.err = errors.ErrUnsupported + } + + ctx, cancel := context.WithCancel(t.Context()) + defer cancel() + + if mode == "cancelled" { + cancel() + } + + ci.BackfillCI(ctx, client, claims, slog.New(slog.NewJSONHandler(&logs, nil)), + ci.CIConfig{Repository: listedRepo, Days: 7}, time.Date(2000, time.January, 1, 1, 0, 0, 0, time.UTC)) + checkLogs(t, mode, calls.Load(), claims, logs.String()) + }) + } +} + +//nolint:gocognit,cyclop // The fake server covers pagination and failure responses. +func history(t *testing.T, mode string, calls *atomic.Int32) http.HandlerFunc { + t.Helper() + + return func(resp http.ResponseWriter, req *http.Request) { + calls.Add(1) + + if mode == forbiddenMode { + resp.WriteHeader(http.StatusForbidden) + + return + } + + body := runs + + switch { + case strings.HasSuffix(req.URL.Path, "/jobs"): + body = jobs + + if req.URL.Query().Get("page") == "" && req.URL.Query().Get("filter") != "all" { + t.Error("missing all attempts filter") + } + + if req.URL.Query().Get("page") == "" { + resp.Header().Set("Link", "; rel="next"`) + } + + case strings.HasSuffix(req.URL.Path, "/actions/runs"): + if req.URL.Query().Get("page") == "" && + req.URL.Query().Get("created") != ">=1999-12-25T01:00:00Z" && + mode != capMode { + t.Errorf("created = %s", req.URL.Query().Get("created")) + } + + if req.URL.Query().Get("page") != "" || mode == capMode { + body = `{"workflow_runs":[]}` + } + + if req.URL.Query().Get("page") == "" || mode == capMode { + resp.Header().Set("Link", "; rel="next"`) + } + + default: + body = `{"default_branch":"main"}` + } + + if mode == "decode_error" { + body = "{" + } + + write(t, resp, body) + } +} + +//nolint:gocognit,cyclop // Each case checks its terminal summary and job records. +func checkLogs(t *testing.T, mode string, calls int32, claims ledger, logs string) { + t.Helper() + + entries := map[string][]map[string]any{} + + for line := range strings.SplitSeq(strings.TrimSpace(logs), "\n") { + var entry map[string]any + + err := json.Unmarshal([]byte(line), &entry) + if err != nil { + t.Fatal(err) + } + + message := fmt.Sprint(entry["msg"]) + + entries[message] = append(entries[message], entry) + } + + finished, failed := entries["ci backfill finished"], entries["ci backfill failed"] + + if len(entries["ci backfill started"]) != 1 || len(finished)+len(failed) != 1 { + t.Fatalf("terminal logs: %s", logs) + } + + if mode != "success" && mode != capMode { + if len(failed) != 1 || len(entries["ci job finished"]) != 0 { + t.Fatalf("want failure without job logs: %s", logs) + } + + if mode == forbiddenMode && (failed[0]["status"] != float64(403) || calls != 1) { + t.Fatalf("403 evidence: %s", logs) + } + + return + } + + if mode == capMode { + if calls != 30 || finished[0]["pages"] != float64(30) { + t.Fatalf("cap: calls=%d logs=%s", calls, logs) + } + + return + } + + logged := entries["ci job finished"] + + if len(logged) != 1 || !claims.claims["1\x00ci_job"] || len(claims.claims) != 2 { + t.Fatalf("claims or duplicates: %s %v", logs, claims.claims) + } + + for key, want := range map[string]any{ + "time": "2000-01-01T00:02:00Z", "event": "schedule", "event_class": "push", + "source": "backfill", "runner": "linux", "queue_seconds": float64(60), "run_seconds": float64(60), + } { + if logged[0][key] != want { + t.Errorf("%s = %v, want %v", key, logged[0][key], want) + } + } + + if finished[0]["pages"] != float64(5) || finished[0]["jobs_skipped"] != float64(9) { + t.Fatalf("summary: %s", logs) + } +} diff --git a/internal/reconcile/testdata/ci_jobs.json b/internal/reconcile/testdata/ci_jobs.json new file mode 100644 index 0000000..2ce52f0 --- /dev/null +++ b/internal/reconcile/testdata/ci_jobs.json @@ -0,0 +1,7 @@ +{"jobs":[ +{"id":1,"run_id":1,"status":"completed","workflow_name":"CI","name":"test","conclusion":"success","head_branch":"main", +"head_sha":"abc","labels":["linux"],"created_at":"2000-01-01T00:00:00Z","started_at":"2000-01-01T00:01:00Z","completed_at":"2000-01-01T00:02:00Z"}, +{"id":2,"status":"completed","completed_at":"2000-01-01T00:02:00Z"}, +{"id":3,"status":"completed","completed_at":"1999-12-01T00:00:00Z"}, +{"id":4,"status":"completed"}, +{"id":5,"status":"completed","completed_at":"2000-01-02T00:00:00Z"}]} diff --git a/internal/recorder/recorder.go b/internal/recorder/recorder.go index 9fcfade..b8cc2bd 100644 --- a/internal/recorder/recorder.go +++ b/internal/recorder/recorder.go @@ -110,6 +110,12 @@ type workflowJob struct { RunID int64 `json:"run_id"` //nolint:tagliatelle // GitHub uses this field name. } +// WorkflowJob is the shared GitHub job payload. +type WorkflowJob = workflowJob + +// JobEventClass uses the live recorder's branch classification. +func JobEventClass(branch, defaultBranch string) string { return jobEventClass(branch, defaultBranch) } + type pullRequest struct { Body string `json:"body"` NodeID string `json:"node_id"` //nolint:tagliatelle // GitHub uses this field name.