github.com/web-platform-tests/wpt.fyi@v0.0.0-20240530210107-70cf978996f1/api/checks/summaries/completed.go (about)

     1  // Copyright 2018 The WPT Dashboard Project. All rights reserved.
     2  // Use of this source code is governed by a BSD-style license that can be
     3  // found in the LICENSE file.
     4  
     5  package summaries
     6  
     7  import (
     8  	"github.com/google/go-github/v47/github"
     9  	"github.com/web-platform-tests/wpt.fyi/shared"
    10  )
    11  
    12  // ResultsComparison is all the fields shared across summaries that
    13  // involve a result comparison.
    14  type ResultsComparison struct {
    15  	BaseRun       shared.TestRun
    16  	HeadRun       shared.TestRun
    17  	MasterDiffURL string
    18  	DiffURL       string // URL for the diff-view of the results
    19  	HostURL       string // Host environment URL, e.g. "https://wpt.fyi"
    20  }
    21  
    22  // Completed is the struct for completed.md.
    23  type Completed struct {
    24  	CheckState
    25  	ResultsComparison
    26  
    27  	Results BeforeAndAfter
    28  	More    int
    29  }
    30  
    31  // GetCheckState returns the info needed to update a check.
    32  func (c Completed) GetCheckState() CheckState {
    33  	return c.CheckState
    34  }
    35  
    36  // GetSummary executes the template for the data.
    37  func (c Completed) GetSummary() (string, error) {
    38  	return compile(&c, "completed.md")
    39  }
    40  
    41  // GetActions returns the actions that can be taken by the user.
    42  func (c Completed) GetActions() []*github.CheckRunAction {
    43  	return []*github.CheckRunAction{
    44  		RecomputeAction(),
    45  	}
    46  }