From 5a2f2cd741b7b141fec93e26f7edb0ece6474875 Mon Sep 17 00:00:00 2001 From: Robert Lin Date: Sat, 11 Jun 2022 12:14:02 -0700 Subject: [PATCH] cli: add 'gobenchdata action' to use gobenchdata action with custom Go versions (#62) --- Dockerfile | 5 +-- README.md | 39 ++++++++++++++++- action.go | 29 +++++++++++++ entrypoint.sh | 118 ++++++++++++++++++++++++++------------------------ go.mod | 8 +++- go.sum | 52 ++++++++++------------ io.go | 14 +++--- main.go | 61 +++++++++++++++----------- web/app.go | 4 +- 9 files changed, 205 insertions(+), 125 deletions(-) create mode 100644 action.go diff --git a/Dockerfile b/Dockerfile index 123f517..ec9f6f3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,4 @@ RUN go build -ldflags "-X main.Version=$(git describe --tags)" -o /bin/gobenchda RUN rm -rf /tmp/build # init entrypoint -WORKDIR /tmp/entrypoint -ADD entrypoint.sh /entrypoint.sh -RUN chmod +x /entrypoint.sh -ENTRYPOINT ["/entrypoint.sh"] +ENTRYPOINT ["/bin/gobenchdata", "action"] diff --git a/README.md b/README.md index d09e8c3..3227e34 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,14 @@ JSON to `gh-pages` and visualizing it with a generated web app or your own web a ### Setup +The default action, `uses: bobheadxi/gobenchdata@v1`, is distributed as a [Docker container action](https://docs.github.com/en/actions/creating-actions/creating-a-docker-container-action). +This means that the Go version benchmarks are run with are tied to the version of Go that ships with the `gobenchdata` action. +For greater flexibility, such as to use custom Go versions, see [custom setup](#custom-setup). + +Learn more about GitHub Actions in the [official documentation](https://github.com/features/actions). + +#### Docker container action + For example, in `.github/workflows/push.yml`, using [the new YAML syntax for workflows](https://help.github.com/en/articles/workflow-syntax-for-github-actions), a simple benchmark [run and publish workflow](#publishing) would look like: ```yml @@ -55,7 +63,36 @@ jobs: GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} ``` -Learn more about GitHub Actions in the [official documentation](https://github.com/features/actions). +#### Custom setup + +For greater flexibility and the ability to target custom Go versions, you can either: + +- directly use the [`entrypoint.sh`](entrypoint.sh) script, or some variant of it +- run `gobenchdata action`, which replicates the behaviour of the GitHub Action + +Using `gobenchdata action` to replicate the [Docker container action](#docker-container-action) would look like: + +```yml +name: gobenchdata publish +on: push +jobs: + publish: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: { go-version: "1.18" } + - name: gobenchdata publish + run: go run go.bobheadxi.dev/gobenchdata@v1 action + with: + PRUNE_COUNT: 30 + GO_TEST_FLAGS: -cpu 1,2 + PUBLISH: true + PUBLISH_BRANCH: gh-pages + env: + GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} +``` ### Configuration diff --git a/action.go b/action.go new file mode 100644 index 0000000..c73900e --- /dev/null +++ b/action.go @@ -0,0 +1,29 @@ +package main + +import ( + "context" + _ "embed" + "os" + "strings" + + "github.com/sourcegraph/run" +) + +//go:embed entrypoint.sh +var entrypointScript string + +// runEmbeddedAction executes an embedded version of entrypoint.sh +func runEmbeddedAction(ctx context.Context) error { + cmd := run.Cmd(ctx, "bash"). + Input(strings.NewReader(entrypointScript)). + StdOut() + + if executable, err := os.Executable(); err == nil { + cmd = cmd.Env(map[string]string{ + // point to self + "GOBENCHDATA": executable, + }) + } + + return cmd.Run().Stream(os.Stdout) +} diff --git a/entrypoint.sh b/entrypoint.sh index 159425f..be6f7d7 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,25 +2,27 @@ set -e # core configuration -INPUT_SUBDIRECTORY="${INPUT_SUBDIRECTORY:-"."}" -INPUT_PRUNE_COUNT="${INPUT_PRUNE_COUNT:-"0"}" -INPUT_BENCHMARKS_OUT="${INPUT_BENCHMARKS_OUT:-"benchmarks.json"}" -INPUT_GO_TEST_PKGS="${INPUT_GO_TEST_PKGS:-"./..."}" -INPUT_GO_BENCHMARKS="${INPUT_GO_BENCHMARKS:-"."}" -INPUT_GIT_COMMIT_MESSAGE="${INPUT_GIT_COMMIT_MESSAGE:-"add benchmark run for ${GITHUB_SHA}"}" +export GOBENCHDATA="${GOBENCHDATA:-"gobenchdata"}" +export INPUT_SUBDIRECTORY="${INPUT_SUBDIRECTORY:-"."}" +export INPUT_PRUNE_COUNT="${INPUT_PRUNE_COUNT:-"0"}" +export INPUT_BENCHMARKS_OUT="${INPUT_BENCHMARKS_OUT:-"benchmarks.json"}" +export INPUT_GO_TEST_PKGS="${INPUT_GO_TEST_PKGS:-"./..."}" +export INPUT_GO_BENCHMARKS="${INPUT_GO_BENCHMARKS:-"."}" +export INPUT_GIT_COMMIT_MESSAGE="${INPUT_GIT_COMMIT_MESSAGE:-"add benchmark run for ${GITHUB_SHA}"}" # publishing configuration -INPUT_PUBLISH_REPO="${INPUT_PUBLISH_REPO:-${GITHUB_REPOSITORY}}" -INPUT_PUBLISH_BRANCH="${INPUT_PUBLISH_BRANCH:-"gh-pages"}" +export INPUT_PUBLISH_REPO="${INPUT_PUBLISH_REPO:-${GITHUB_REPOSITORY}}" +export INPUT_PUBLISH_BRANCH="${INPUT_PUBLISH_BRANCH:-"gh-pages"}" # pull request checks -INPUT_CHECKS="${INPUT_CHECKS:-"false"}" -INPUT_CHECKS_CONFIG="${INPUT_CHECKS_CONFIG:-"gobenchdata-checks.yml"}" +export INPUT_CHECKS="${INPUT_CHECKS:-"false"}" +export INPUT_CHECKS_CONFIG="${INPUT_CHECKS_CONFIG:-"gobenchdata-checks.yml"}" # output build data echo '========================' -command -v gobenchdata -gobenchdata version +command -v ${GOBENCHDATA} +${GOBENCHDATA} version +echo "👨‍⚕️ Checking configuration..." env | grep 'INPUT_' echo "GITHUB_ACTOR=${GITHUB_ACTOR}" echo "GITHUB_WORKSPACE=${GITHUB_WORKSPACE}" @@ -31,8 +33,10 @@ echo '========================' # setup mkdir -p /tmp/{gobenchdata,build} -git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" -git config --global user.name "${GITHUB_ACTOR}" +if [[ "${SET_GIT_USER}" != "false" ]]; then + git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" + git config user.name "${GITHUB_ACTOR}" +fi # run benchmarks from configured directory echo @@ -44,58 +48,60 @@ go test \ -bench "${INPUT_GO_BENCHMARKS}" \ -benchmem \ ${INPUT_GO_TEST_FLAGS} \ - ${INPUT_GO_TEST_PKGS} \ - | gobenchdata --json "${RUN_OUTPUT}" -v "${GITHUB_SHA}" -t "ref=${GITHUB_REF}" + ${INPUT_GO_TEST_PKGS} | + ${GOBENCHDATA} --json "${RUN_OUTPUT}" -v "${GITHUB_SHA}" -t "ref=${GITHUB_REF}" cd "${GITHUB_WORKSPACE}" # fetch published data -echo -echo "📚 Checking out ${INPUT_PUBLISH_REPO}@${INPUT_PUBLISH_BRANCH}..." -cd /tmp/build -git clone https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${INPUT_PUBLISH_REPO}.git . -git checkout ${INPUT_PUBLISH_BRANCH} -echo - -if [[ "${INPUT_CHECKS}" == "true" ]]; then - - # check results against published - echo '🔎 Evaluating results against base runs...' - CHECKS_OUTPUT="/tmp/gobenchdata/checks-results.json" - gobenchdata checks eval "${INPUT_BENCHMARKS_OUT}" "${RUN_OUTPUT}" \ - --checks.config "${GITHUB_WORKSPACE}/${INPUT_CHECKS_CONFIG}" \ - --json ${CHECKS_OUTPUT} \ - --flat - RESULTS=$(cat ${CHECKS_OUTPUT}) - echo "::set-output name=checks-results::$RESULTS" - - # output results +if [[ "${INPUT_PUBLISH}" == "true" || "${INPUT_CHECKS}" == "true" ]]; then + echo + echo "📚 Checking out ${INPUT_PUBLISH_REPO}@${INPUT_PUBLISH_BRANCH}..." + cd /tmp/build + git clone https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${INPUT_PUBLISH_REPO}.git . + git checkout ${INPUT_PUBLISH_BRANCH} echo - echo '📝 Generating checks report...' - gobenchdata checks report ${CHECKS_OUTPUT} - -fi -if [[ "${INPUT_PUBLISH}" == "true" ]]; then + if [[ "${INPUT_CHECKS}" == "true" ]]; then - # merge results with published - echo '☝️ Updating results...' - if [[ -f "${INPUT_BENCHMARKS_OUT}" ]]; then - echo '📈 Existing report found - merging...' - gobenchdata merge "${RUN_OUTPUT}" "${INPUT_BENCHMARKS_OUT}" \ - --prune "${INPUT_PRUNE_COUNT}" \ - --json "${INPUT_BENCHMARKS_OUT}" \ + # check results against published + echo '🔎 Evaluating results against base runs...' + CHECKS_OUTPUT="/tmp/gobenchdata/checks-results.json" + ${GOBENCHDATA} checks eval "${INPUT_BENCHMARKS_OUT}" "${RUN_OUTPUT}" \ + --checks.config "${GITHUB_WORKSPACE}/${INPUT_CHECKS_CONFIG}" \ + --json ${CHECKS_OUTPUT} \ --flat - else - cp "${RUN_OUTPUT}" "${INPUT_BENCHMARKS_OUT}" + RESULTS=$(cat ${CHECKS_OUTPUT}) + echo "::set-output name=checks-results::$RESULTS" + + # output results + echo + echo '📝 Generating checks report...' + ${GOBENCHDATA} checks report ${CHECKS_OUTPUT} + fi - # publish results - echo - echo '📷 Committing and pushing new benchmark data...' - git add . - git commit -m "${INPUT_GIT_COMMIT_MESSAGE}" - git push -f origin ${INPUT_PUBLISH_BRANCH} + if [[ "${INPUT_PUBLISH}" == "true" ]]; then + + # merge results with published + echo '☝️ Updating results...' + if [[ -f "${INPUT_BENCHMARKS_OUT}" ]]; then + echo '📈 Existing report found - merging...' + ${GOBENCHDATA} merge "${RUN_OUTPUT}" "${INPUT_BENCHMARKS_OUT}" \ + --prune "${INPUT_PRUNE_COUNT}" \ + --json "${INPUT_BENCHMARKS_OUT}" \ + --flat + else + cp "${RUN_OUTPUT}" "${INPUT_BENCHMARKS_OUT}" + fi + + # publish results + echo + echo '📷 Committing and pushing new benchmark data...' + git add . + git commit -m "${INPUT_GIT_COMMIT_MESSAGE}" + git push -f origin ${INPUT_PUBLISH_BRANCH} + fi fi echo diff --git a/go.mod b/go.mod index 28911ff..aaaafa3 100644 --- a/go.mod +++ b/go.mod @@ -8,6 +8,7 @@ require ( github.com/antonmedv/expr v1.9.0 github.com/google/go-cmp v0.5.8 github.com/olekukonko/tablewriter v0.0.5 + github.com/sourcegraph/run v0.9.0 github.com/spf13/pflag v1.0.5 golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 golang.org/x/net v0.0.0-20220607020251-c690dde0001d @@ -15,11 +16,16 @@ require ( ) require ( + bitbucket.org/creachadair/shell v0.0.7 // indirect github.com/BurntSushi/toml v1.1.0 // indirect github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect github.com/bmatcuk/doublestar v1.3.4 // indirect + github.com/djherbis/buffer v1.2.0 // indirect + github.com/djherbis/nio/v3 v3.0.1 // indirect github.com/gizak/termui/v3 v3.1.0 // indirect + github.com/itchyny/gojq v0.12.7 // indirect + github.com/itchyny/timefmt-go v0.1.3 // indirect github.com/karrick/godirwalk v1.17.0 // indirect github.com/labstack/echo v3.3.10+incompatible // indirect github.com/labstack/gommon v0.3.1 // indirect @@ -28,11 +34,11 @@ require ( github.com/mattn/go-runewidth v0.0.13 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/nsf/termbox-go v1.1.1 // indirect - github.com/pkg/errors v0.9.1 // indirect github.com/rivo/uniseg v0.2.0 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasttemplate v1.2.1 // indirect golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect + golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d // indirect golang.org/x/text v0.3.7 // indirect golang.org/x/tools v0.1.11 // indirect diff --git a/go.sum b/go.sum index d40b266..aa75a6d 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,5 @@ -github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= +bitbucket.org/creachadair/shell v0.0.7 h1:Z96pB6DkSb7F3Y3BBnJeOZH2gazyMTWlvecSD4vDqfk= +bitbucket.org/creachadair/shell v0.0.7/go.mod h1:oqtXSSvSYr4624lnnabXHaBsYW6RD80caLi2b3hJk0U= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.1.0 h1:ksErzDEI1khOiGPgpwuI7x2ebx/uXQNw7xJpn9Eq1+I= github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= @@ -7,17 +8,14 @@ github.com/OneOfOne/struct2ts v1.0.6 h1:kLFEisG4K43k1thctN9BNZP4Y/RxRbO8tPyi3G5q github.com/OneOfOne/struct2ts v1.0.6/go.mod h1:GbIenlFXroS2wRhpYXHEq7y7HWsY3SFBIKxkqzbnAsU= github.com/UnnoTed/fileb0x v1.1.4 h1:IUgFzgBipF/ujNx9wZgkrKOF3oltUuXMSoaejrBws+A= github.com/UnnoTed/fileb0x v1.1.4/go.mod h1:X59xXT18tdNk/D6j+KZySratBsuKJauMtVuJ9cgOiZs= -github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc h1:cAKDfWh5VpdgMhJosfJnn5/FoN2SRZ4p7fJNX58YPaU= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZqLG4oE62mJzwPIB8+Tee4RNCL9ulrY= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 h1:s6gZFSlWYmbqAuRjVTiNNhvNRfY2Wxp9nhfyel4rklc= github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE= github.com/antonmedv/expr v1.9.0 h1:j4HI3NHEdgDnN9p6oI6Ndr0G5QryMY0FNxT4ONrFDGU= github.com/antonmedv/expr v1.9.0/go.mod h1:5qsM3oLGDND7sDmQGDXHkYfkjYMUX14qsgqmHhwGEk8= -github.com/bmatcuk/doublestar v1.1.1 h1:YroD6BJCZBYx06yYFEWvUuKVWQn3vLLQAVmDmvTSaiQ= github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w= github.com/bmatcuk/doublestar v1.3.4 h1:gPypJ5xD31uhX6Tf54sDPUOBXTqKH4c9aPY66CyQrS0= github.com/bmatcuk/doublestar v1.3.4/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9MEoZQC/PmE= @@ -27,37 +25,42 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/djherbis/buffer v1.1.0/go.mod h1:VwN8VdFkMY0DCALdY8o00d3IZ6Amz/UNVMWcSaJT44o= +github.com/djherbis/buffer v1.2.0 h1:PH5Dd2ss0C7CRRhQCZ2u7MssF+No9ide8Ye71nPHcrQ= +github.com/djherbis/buffer v1.2.0/go.mod h1:fjnebbZjCUpPinBRD+TDwXSOeNQ7fPQWLfGQqiAiUyE= +github.com/djherbis/nio/v3 v3.0.1 h1:6wxhnuppteMa6RHA4L81Dq7ThkZH8SwnDzXDYy95vB4= +github.com/djherbis/nio/v3 v3.0.1/go.mod h1:Ng4h80pbZFMla1yKzm61cF0tqqilXZYrogmWgZxOcmg= +github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg= github.com/gdamore/tcell v1.3.0/go.mod h1:Hjvr+Ofd+gLglo7RYKxxnzCBmev3BzsS67MebKS4zMM= github.com/gizak/termui/v3 v3.1.0 h1:ZZmVDgwHl7gR7elfKf1xc4IudXZ5qqfDh4wExk4Iajc= github.com/gizak/termui/v3 v3.1.0/go.mod h1:bXQEBkJpzxUAKf0+xq9MSWAvWZlE7c+aidmyFlkYTrY= -github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= +github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/karrick/godirwalk v1.7.8 h1:VfG72pyIxgtC7+3X9CMHI0AOl4LwyRAg98WAgsvffi8= +github.com/itchyny/gojq v0.12.7 h1:hYPTpeWfrJ1OT+2j6cvBScbhl0TkdwGM4bc66onUSOQ= +github.com/itchyny/gojq v0.12.7/go.mod h1:ZdvNHVlzPgUf8pgjnuDTmGfHA/21KoutQUJ3An/xNuw= +github.com/itchyny/timefmt-go v0.1.3 h1:7M3LGVDsqcd0VZH2U+x393obrzZisp7C0uEe921iRkU= +github.com/itchyny/timefmt-go v0.1.3/go.mod h1:0osSSCQSASBJMsIZnhAaF1C2fCBTJZXrnj37mG8/c+A= github.com/karrick/godirwalk v1.7.8/go.mod h1:2c9FRhkDxdIbgkOnCEvnSWs71Bhugbl46shStcFDJ34= github.com/karrick/godirwalk v1.17.0 h1:b4kY7nqDdioR/6qnbHQyDvmA17u5G1cZ6J+CZXwSWoI= github.com/karrick/godirwalk v1.17.0/go.mod h1:j4mkqPuvaLI8mp1DroR3P6ad7cyYd4c1qeJ3RV7ULlk= -github.com/labstack/echo v3.2.1+incompatible h1:J2M7YArHx4gi8p/3fDw8tX19SXhBCoRpviyAZSN3I88= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/labstack/echo v3.2.1+incompatible/go.mod h1:0INS7j/VjnFxD4E2wkz67b8cVwCLbBmJyDaka6Cmk1s= github.com/labstack/echo v3.3.10+incompatible h1:pGRcYk231ExFAyoAjAfD85kQzRJCRI8bbnE7CX5OEgg= github.com/labstack/echo v3.3.10+incompatible/go.mod h1:0INS7j/VjnFxD4E2wkz67b8cVwCLbBmJyDaka6Cmk1s= -github.com/labstack/gommon v0.2.7 h1:2qOPq/twXDrQ6ooBGrn3mrmVOC+biLlatwgIu8lbzRM= github.com/labstack/gommon v0.2.7/go.mod h1:/tj9csK2iPSBvn+3NLM9e52usepMtrd5ilFYA+wQNJ4= github.com/labstack/gommon v0.3.1 h1:OomWaJXm7xR6L1HmEtGyQf26TEn7V6X88mktX9kee9o= github.com/labstack/gommon v0.3.1/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM= github.com/lucasb-eyer/go-colorful v1.0.2/go.mod h1:0MS4r+7BZKSJ5mw4/S5MPN+qHFF1fYclkSPilDOKW0s= github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU= -github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE= -github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= @@ -68,20 +71,15 @@ github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= -github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4= github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= -github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d h1:x3S6kxmy49zXVVyhcnrFqxvNVCBPb2KZ9hV2RBdS840= github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d/go.mod h1:IuKpRQcYE1Tfu+oAQqaLisqDeXgjyyltCfsaoYN18NQ= github.com/nsf/termbox-go v1.1.1 h1:nksUPLCb73Q++DwbYUBEglYBRPZyoXJdrj5L+TkjyZY= github.com/nsf/termbox-go v1.1.1/go.mod h1:T0cTdVuOwf7pHQNtfhnEbzHbcNyCEcVU4YPpouCbVxo= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= -github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -89,7 +87,10 @@ github.com/rivo/tview v0.0.0-20200219210816-cd38d7432498/go.mod h1:6lkG1x+13OShE github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= +github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= github.com/sanity-io/litter v1.2.0/go.mod h1:JF6pZUFgu2Q0sBZ+HSV35P8TVPI1TTzEwyu9FXAw2W4= +github.com/sourcegraph/run v0.9.0 h1:mj4pwBqCB+5qEaTp+rhauh5ubYI8n/icOkeiLTCT9Xg= +github.com/sourcegraph/run v0.9.0/go.mod h1:j6Do38ccF+w/rSWgOuu4Ou/eOIDiU6pC87BZmq0DXDY= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -97,44 +98,39 @@ github.com/stretchr/testify v0.0.0-20161117074351-18a02ba4a312/go.mod h1:a8OnRci github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasttemplate v0.0.0-20170224212429-dcecefd839c4/go.mod h1:50wTf68f99/Zt14pr046Tgt3Lp2vLyFZKzbFXTOabXw= -github.com/valyala/fasttemplate v1.0.1 h1:tY9CJiPnMXf1ERmG2EyK7gNUd+c6RKGD0IfU8WdUSz8= -github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= github.com/valyala/fasttemplate v1.2.1 h1:TVEnxayobAdVkhQfrfes2IzOB6o+z4roRkPF52WA1u4= github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= golang.org/x/crypto v0.0.0-20180910181607-0e37d006457b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 h1:ObdrDkeb4kJdCP557AjRjq69pTHfNouLtWZG7j9rPN8= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM= golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug= golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20180921000356-2f5d2388922f/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220607020251-c690dde0001d h1:4SFsTMi4UahlKoloni7L4eYzhFRifURQLw+yv0QDCx8= golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20181019160139-8e24a49d80f8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d h1:Zu/JngovGLVi6t2J3nmAf3AoTDwuzw85YZ3b9o4yU7s= golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -143,13 +139,10 @@ golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190213135902-6bedcd10978a/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7 h1:EBZoQjiKKPaLbPrbpssUfuHtwM6KV/vb4U85g/cigFY= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.1.11 h1:loJ25fNOEhSXfHrpoGj91eCUThwdNX6u24rO1xnNteY= golang.org/x/tools v0.1.11/go.mod h1:SgwaegtQh8clINPpECJMqnxLv9I09HLqnW3RMqW0CA4= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= @@ -160,4 +153,5 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/io.go b/io.go index b4c989a..49d82ff 100644 --- a/io.go +++ b/io.go @@ -72,7 +72,7 @@ func output(results []bench.Run) { } fmt.Printf("successfully output results as json to '%s'\n", *jsonOut) } else { - println(string(b)) + fmt.Println(string(b)) } } @@ -126,9 +126,9 @@ func outputChecksReport(r *checks.Report) { // output results to stdout meta.Render() - println() + fmt.Println() results.Render() - println() + fmt.Println() } func load(files ...string) []bench.RunHistory { @@ -148,8 +148,10 @@ func load(files ...string) []bench.RunHistory { } func showHelp() { - println(helpText) - println("FLAGS:\n") + fmt.Println(helpText) + fmt.Println() + fmt.Println("FLAGS:") + fmt.Println() pflag.PrintDefaults() - println("\nsee https://go.bobheadxi.dev/gobenchdata for more documentation.") + fmt.Println("\nSee https://github.com/bobheadxi/gobenchdata for more documentation.") } diff --git a/main.go b/main.go index 91ea7dd..12d54ca 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( "bufio" + "context" "encoding/json" "errors" "fmt" @@ -54,9 +55,10 @@ COMMANDS: checks eval [base] [current] evaluate checks defined in './gobenchdata-checks.yml' checks report [report] print a simple report and exits with status 1 if a check failed + action executes the same behaviour as the Docker container action + version show gobenchdata version - help show help text -` + help show help text` func main() { pflag.Parse() @@ -67,10 +69,11 @@ func main() { // gobenchdata version case "version": if Version == "" { - println("gobenchdata version unknown") + fmt.Println("gobenchdata version unknown") } else { - println("gobenchdata " + Version) + fmt.Println("gobenchdata " + Version) } + os.Exit(0) // gobenchdata help case "help": @@ -81,7 +84,7 @@ func main() { case "merge": args := pflag.Args()[1:] if len(args) < 1 { - println("no merge targets provided") + fmt.Println("no merge targets provided") os.Exit(1) } merge(args...) @@ -100,7 +103,7 @@ func main() { switch webCmd := pflag.Args()[1]; webCmd { case "generate": if len(pflag.Args()) < 3 { - println("no output directory provided") + fmt.Println("no output directory provided") os.Exit(1) } @@ -109,21 +112,21 @@ func main() { if !*webConfigOnly { if err := web.GenerateApp(dir, *it); err != nil { - println(err.Error()) + fmt.Println(err.Error()) os.Exit(1) } - println("web application generated!") + fmt.Println("web application generated!") } // only override if we are generating config only if err := web.GenerateConfig(dir, *config, *webConfigOnly); err != nil { if errors.Is(err, os.ErrExist) { - println("found existing web app configuration") + fmt.Println("found existing web app configuration") return } - println(err.Error()) + fmt.Println(err.Error()) os.Exit(1) } - println("web application configuration generated!") + fmt.Println("web application configuration generated!") case "serve": port := "8080" @@ -135,7 +138,7 @@ func main() { fmt.Printf("serving './benchmarks.json' on '%s'\n", addr) go internal.OpenBrowser("http://" + addr) if err := web.ListenAndServe(addr, *config, *it); err != nil { - println(err.Error()) + fmt.Println(err.Error()) os.Exit(1) } default: @@ -152,18 +155,18 @@ func main() { switch checksCmd := pflag.Args()[1]; checksCmd { case "generate": if err := checks.GenerateConfig(*checksConfigPath); err != nil { - println(err.Error()) + fmt.Println(err.Error()) os.Exit(1) } case "eval": cfg, err := checks.LoadConfig(*checksConfigPath) if err != nil { - println(err.Error()) + fmt.Println(err.Error()) os.Exit(1) } args := pflag.Args()[2:] if len(args) != 2 { - println("two targets required") + fmt.Println("two targets required") os.Exit(1) } histories := load(args[0], args[1]) @@ -172,7 +175,7 @@ func main() { MustFindAll: false, }) if err != nil { - println(err.Error()) + fmt.Println(err.Error()) os.Exit(1) } @@ -187,12 +190,12 @@ func main() { b, err = json.MarshalIndent(results, "", " ") } if err != nil { - println(err.Error()) + fmt.Println(err.Error()) os.Exit(1) } if err := ioutil.WriteFile(*jsonOut, b, os.ModePerm); err != nil { - println(err.Error()) + fmt.Println(err.Error()) os.Exit(1) } fmt.Printf("report output written to %s\n", *jsonOut) @@ -200,12 +203,12 @@ func main() { case "report": if len(pflag.Args()) < 3 { - println("no report provided") + fmt.Println("no report provided") os.Exit(1) } results, err := checks.LoadReport(pflag.Args()[2]) if err != nil { - println(err.Error()) + fmt.Println(err.Error()) os.Exit(1) } outputChecksReport(results) @@ -220,6 +223,12 @@ func main() { os.Exit(1) } + case "action": + if err := runEmbeddedAction(context.Background()); err != nil { + fmt.Println(err.Error()) + os.Exit(1) + } + default: showHelp() os.Exit(1) @@ -230,17 +239,17 @@ func main() { // default behaviour fi, err := os.Stdin.Stat() if err != nil { - println(err.Error()) + fmt.Println(err.Error()) os.Exit(1) } else if fi.Mode()&os.ModeNamedPipe == 0 { - println("gobenchdata should be used with a pipe - see 'gobenchdata help'") + fmt.Println("gobenchdata should be used with a pipe - see 'gobenchdata help'") os.Exit(1) } parser := bench.NewParser(bufio.NewReader(os.Stdin)) suites, err := parser.Read() if err != nil { - println(err.Error()) + fmt.Println(err.Error()) os.Exit(1) } fmt.Printf("detected %d benchmark suites\n", len(suites)) @@ -254,17 +263,17 @@ func main() { }} if *appendOut { if *jsonOut == "" { - println("file output needs to be set (try '--json')") + fmt.Println("file output needs to be set (try '--json')") os.Exit(1) } b, err := ioutil.ReadFile(*jsonOut) if err != nil && !os.IsNotExist(err) { - println(err.Error()) + fmt.Println(err.Error()) os.Exit(1) } else if !os.IsNotExist(err) { var runs []bench.Run if err := json.Unmarshal(b, &runs); err != nil { - println(err.Error()) + fmt.Println(err.Error()) os.Exit(1) } results = append(results, runs...) diff --git a/web/app.go b/web/app.go index ba1cdb3..0f4d374 100644 --- a/web/app.go +++ b/web/app.go @@ -1,5 +1,5 @@ -// Code generated by fileb0x at "2022-04-27 00:15:24.888415 -0700 PDT m=+0.005834001" from config file "b0x.yml" DO NOT EDIT. -// modification hash(9df5026ba11a3a0b6d6920481084f6db.70962d6be0f73f63dc7a0bf10caeeb59) +// Code generated by fileb0x at "2022-06-11 11:38:02.391111 -0700 PDT m=+0.006352085" from config file "b0x.yml" DO NOT EDIT. +// modification hash(e2034d0c6da8cba1e8d0aa2121ec2895.70962d6be0f73f63dc7a0bf10caeeb59) package web