@@ -14,7 +14,9 @@ import (
1414 "github.com/go-echarts/go-echarts/v2/components"
1515 "github.com/go-echarts/go-echarts/v2/opts"
1616 "github.com/go-echarts/go-echarts/v2/types"
17+ "github.com/joho/godotenv"
1718 "github.com/moby/buildkit-bench/util/candidates"
19+ "github.com/moby/buildkit-bench/util/github/gha"
1820 "github.com/moby/buildkit-bench/util/gotest"
1921 "github.com/moby/buildkit-bench/util/testutil"
2022 "github.com/montanaflynn/stats"
@@ -28,6 +30,8 @@ type genCmd struct {
2830 Config string `kong:"name='config',required,default='testconfig.yml',help='Test config file.'"`
2931 Output string `kong:"name='output',default='./bin/gen/benchmarks.html',help='File to write the HTML report to.'"`
3032 Candidates string `kong:"name='candidates',help='Candidates file.'"`
33+ GHAEvent string `kong:"name='gha-event',help='GitHub Actions payload JSON file.'"`
34+ Envs string `kong:"name='envs',help='Environment variables file.'"`
3135 ValidationMode string `kong:"name='validation-mode',enum='sloppy,strict',default='sloppy',help='Validation mode.'"`
3236}
3337
@@ -101,6 +105,25 @@ func (c *genCmd) writeHTML(benchmarks map[string]gotest.Benchmark) error {
101105 return err
102106 }
103107
108+ var envs map [string ]string
109+ if c .Envs != "" {
110+ envs , err = godotenv .Read (c .Envs )
111+ if err != nil {
112+ return err
113+ }
114+ }
115+
116+ if c .GHAEvent != "" {
117+ ghaEventName , ok := envs ["GITHUB_EVENT_NAME" ]
118+ if ! ok {
119+ return errors .New ("missing GITHUB_EVENT_NAME in envs" )
120+ }
121+ _ , err = gha .ParseEventFile (ghaEventName , c .GHAEvent )
122+ if err != nil {
123+ return err
124+ }
125+ }
126+
104127 var sortedRefs []candidates.Ref
105128 if c .Candidates != "" {
106129 cds , err := candidates .Load (c .Candidates )
0 commit comments