Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
25 changes: 15 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,15 @@ jobs:
name: Download results
uses: actions/download-artifact@v4
with:
path: /tmp/buildkit-bench
path: /tmp/buildkit-bench-result
pattern: bench-results-*
merge-multiple: true
-
name: Download candidates
uses: actions/download-artifact@v4
with:
name: candidates
path: /tmp/buildkit-bench
path: /tmp/buildkit-bench-result
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand All @@ -272,6 +272,15 @@ jobs:
-
name: Checkout
uses: actions/checkout@v4
-
name: Create metadata files
run: |
cp ./testconfig.yml /tmp/buildkit-bench-result/
echo "$(date +'%Y%m%d-%H%M%S')" > /tmp/buildkit-bench-result/name.txt
env|sort > /tmp/buildkit-bench-result/env.txt
if [ -f "$GITHUB_EVENT_PATH" ]; then
cp $GITHUB_EVENT_PATH /tmp/buildkit-bench-result/gha-event.json
fi
-
name: Generate HTML report
uses: docker/bake-action@v5
Expand All @@ -281,18 +290,14 @@ jobs:
provenance: false
set: |
*.cache-from=type=registry,ref=${{ env.BUILDKIT_CACHE_REPO }}:tests-base
*.contexts.tests-results=cwd:///tmp/buildkit-bench
*.contexts.tests-results=cwd:///tmp/buildkit-bench-result
*.output=./bin/report
env:
BAKE_ALLOW_REMOTE_FS_ACCESS: 1
-
name: Include additional files to report directory
name: Include results to report
run: |
cp -r /tmp/buildkit-bench/* ./testconfig.yml ./bin/report/
env|sort > ./bin/report/env.txt
if [ -f "$GITHUB_EVENT_PATH" ]; then
cp $GITHUB_EVENT_PATH ./bin/report/gha-event.json
fi
cp -r /tmp/buildkit-bench-result/* ./bin/report/
-
name: Upload report
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -324,7 +329,7 @@ jobs:
-
name: Move reports
run: |
reportDir=$(date +'%Y%m%d-%H%M%S')
reportDir=$(cat /tmp/buildkit-bench-report/name.txt)
mkdir -p ./website/public/result/$reportDir
mv /tmp/buildkit-bench-report/* ./website/public/result/$reportDir/
if [ -d ./bin/gh-pages/result ]; then
Expand Down
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,21 @@ ARG GEN_VALIDATION_MODE
RUN --mount=type=bind,target=. <<EOT
set -e
args="gen --output /tmp/benchmarks.html"
if [ -f /tests-results/name.txt ]; then
args="$args --name $(cat /tests-results/name.txt)"
fi
if [ -f /tests-results/candidates.json ]; then
args="$args --candidates /tests-results/candidates.json"
fi
if [ -f /tests-results/testconfig.yml ]; then
args="$args --config /tests-results/testconfig.yml"
fi
if [ -f /tests-results/gha-event.json ]; then
args="$args --gha-event /tests-results/gha-event.json"
fi
if [ -f /tests-results/env.txt ]; then
args="$args --envs /tests-results/env.txt"
fi
if [ -n "$GEN_VALIDATION_MODE" ]; then
args="$args --validation-mode $GEN_VALIDATION_MODE"
fi
Expand Down
24 changes: 24 additions & 0 deletions cmd/gotestmetrics/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import (
"github.com/go-echarts/go-echarts/v2/components"
"github.com/go-echarts/go-echarts/v2/opts"
"github.com/go-echarts/go-echarts/v2/types"
"github.com/joho/godotenv"
"github.com/moby/buildkit-bench/util/candidates"
"github.com/moby/buildkit-bench/util/github/gha"
"github.com/moby/buildkit-bench/util/gotest"
"github.com/moby/buildkit-bench/util/testutil"
"github.com/montanaflynn/stats"
Expand All @@ -25,9 +27,12 @@ import (
type genCmd struct {
Files []string `kong:"arg='',name='files',required,help='Benchmark results files generated by parse command.'"`

Name string `kong:"name='name',help='Name of the report.'"`
Config string `kong:"name='config',required,default='testconfig.yml',help='Test config file.'"`
Output string `kong:"name='output',default='./bin/gen/benchmarks.html',help='File to write the HTML report to.'"`
Candidates string `kong:"name='candidates',help='Candidates file.'"`
GHAEvent string `kong:"name='gha-event',help='GitHub Actions payload JSON file.'"`
Envs string `kong:"name='envs',help='Environment variables file.'"`
ValidationMode string `kong:"name='validation-mode',enum='sloppy,strict',default='sloppy',help='Validation mode.'"`
}

Expand Down Expand Up @@ -101,6 +106,25 @@ func (c *genCmd) writeHTML(benchmarks map[string]gotest.Benchmark) error {
return err
}

var envs map[string]string
if c.Envs != "" {
envs, err = godotenv.Read(c.Envs)
if err != nil {
return err
}
}

if c.GHAEvent != "" {
ghaEventName, ok := envs["GITHUB_EVENT_NAME"]
if !ok {
return errors.New("missing GITHUB_EVENT_NAME in envs")
}
_, err = gha.ParseEventFile(ghaEventName, c.GHAEvent)
if err != nil {
return err
}
}

var sortedRefs []candidates.Ref
if c.Candidates != "" {
cds, err := candidates.Load(c.Candidates)
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ require (
github.com/containerd/continuity v0.4.3
github.com/go-echarts/go-echarts/v2 v2.4.1
github.com/gofrs/flock v0.12.1
github.com/google/go-github/v65 v65.0.0
github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6
github.com/joho/godotenv v1.5.1
github.com/moby/buildkit v0.15.2
github.com/montanaflynn/stats v0.7.1
github.com/opencontainers/image-spec v1.1.0
Expand Down Expand Up @@ -38,6 +40,7 @@ require (
github.com/gogo/googleapis v1.4.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/in-toto/in-toto-golang v0.5.0 // indirect
Expand Down
7 changes: 7 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,15 @@ github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4er
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-github/v65 v65.0.0 h1:pQ7BmO3DZivvFk92geC0jB0q2m3gyn8vnYPgV7GSLhQ=
github.com/google/go-github/v65 v65.0.0/go.mod h1:DvrqWo5hvsdhJvHd4WyVF9ttANN3BniqjP8uTFMNb60=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 h1:k7nVchz72niMH6YLQNvHSdIE7iqsQxK1P41mySCvssg=
github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw=
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
Expand All @@ -83,6 +88,8 @@ github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUq
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
github.com/in-toto/in-toto-golang v0.5.0 h1:hb8bgwr0M2hGdDsLjkJ3ZqJ8JFLL/tgYdAxF/XEFBbY=
github.com/in-toto/in-toto-golang v0.5.0/go.mod h1:/Rq0IZHLV7Ku5gielPT4wPHJfH1GdHMCq8+WPxw8/BE=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
Expand Down
23 changes: 23 additions & 0 deletions util/github/gha/event.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package gha

import (
"os"

"github.com/google/go-github/v65/github"
)

func ParseEventFile(name string, fp string) (interface{}, error) {
dt, err := os.ReadFile(fp)
if err != nil {
return nil, err
}
return ParseEvent(name, dt)
}

func ParseEvent(name string, dt []byte) (interface{}, error) {
event, err := github.ParseWebHook(name, dt)
if err != nil {
return nil, err
}
return event, nil
}
Loading