@@ -71,49 +71,47 @@ context) properties. Like this:
7171### Minimal setup
7272
7373``` yaml
74- name : Minimal setup
74+ nname : Example for minimal setup
7575on :
76+ # NOTE! Do NOT add any other "on", because this workflow has permission to write to the repo!
7677 push :
7778 branches :
7879 - master
7980
81+ permissions :
82+ # permission to update benchmark contents in gh-pages branch
83+ contents : " write"
84+
8085jobs :
8186 benchmark :
82- name : Performance regression check
87+ name : Run benchmark and save results
8388 runs-on : ubuntu-latest
8489 steps :
8590 - uses : actions/checkout@v6
8691 - uses : actions/setup-go@v6
8792 with :
8893 go-version : " stable"
89- # Run benchmark with `go test -bench` and stores the output to a file
90- - name : Run benchmark
91- run : go test -bench 'BenchmarkFib' | tee output.txt
92- # Download previous benchmark result from cache
93- - name : Download previous benchmark data
94- uses : actions/cache/restore@v5
95- with :
96- fail-on-cache-miss : true
97- path : ./cache/benchmark-data.json
98- key : ${{ runner.os }}-benchmark
99- - name : Compare results
94+ - name : Run benchmark and stores the output to a file
95+ run : cd examples/go && go test -bench 'BenchmarkFib' | tee output.txt
96+ - name : Get JSON for benchmark
10097 uses : benchmark-action/github-action-benchmark@v1
10198 with :
10299 # What benchmark tool the output.txt came from
103100 tool : ' go'
104- # Extract benchmark result from here
101+ # Where the output from the benchmark tool is stored
105102 output-file-path : output.txt
106- # Where the previous data file is stored
103+ # Updates this file
107104 external-data-json-path : ./cache/benchmark-data.json
108105 # Workflow will fail when an alert happens
109106 fail-on-alert : true
110- # Upload the updated cache file for the next job by actions/cache
111- - name : Save benchmark JSON
107+ # Writes to gh-pages-branch
108+ auto-push : " true"
109+ - name : Save JSON in cache
112110 uses : actions/cache/save@v5
113111 with :
114112 path : ./cache/benchmark-data.json
115- # Include OS in key so that we don't compare benchmarks across different OSes
116- key : ${{ runner.os }}-benchmark
113+ # Save with commit hash to avoid "cache already exists"
114+ key : " ${{ github.sha }}-${{ runner.os }}-go- benchmark"
117115` ` `
118116
119117By default, this action marks the result as performance regression when it is worse than the previous
@@ -140,8 +138,8 @@ be seen [here][minimal-workflow-example].
140138 github-token: ${{ secrets.GITHUB_TOKEN }}
141139 # Enable alert commit comment
142140 comment-on-alert: true
143- # Mention @rhysd in the commit comment, not mandatory but highly recommended to ensure the comment is seen
144- alert-comment-cc-users: '@rhysd '
141+ # Mention @ktrz in the commit comment, not mandatory but highly recommended to ensure the comment is seen
142+ alert-comment-cc-users: '@ktrz '
145143` ` `
146144
147145` secrets.GITHUB_TOKEN` is [a GitHub API token automatically generated for each workflow run][help-github-token].
@@ -151,7 +149,7 @@ performance regression.
151149Now, in addition to making workflow fail, the step leaves a commit comment when it detects performance
152150regression [like this][alert-comment-example]. Though `alert-comment-cc-users` input is not mandatory for
153151this, I recommend to set it to make sure you notice the comment via GitHub notification. Please note
154- that this value must be quoted like `'@rhysd '` because [`@` is an indicator in YAML syntax](https://yaml.org/spec/1.2/spec.html#id2772075).
152+ that this value must be quoted like `'@ktrz '` because [`@` is an indicator in YAML syntax](https://yaml.org/spec/1.2/spec.html#id2772075).
155153
156154A live workflow example is [here](.github/workflows/commit-comment.yml). And the results of the workflow
157155can be seen [here][commit-comment-workflow-example].
0 commit comments