6464
6565 # step 4: run test
6666 - name : Run coverage
67- run : go test -race -shuffle=on -covermode=atomic -coverpkg=./... -coverprofile=coverage.out ./...
67+ run : go test -race -shuffle=on -count=1 - covermode=atomic -coverpkg=./... -coverprofile=coverage.out ./...
6868
6969 # step 5: upload coverage
7070 - name : Upload coverage to Codecov
@@ -93,16 +93,19 @@ jobs:
9393 - name : Install all Go dependencies
9494 run : go mod download
9595
96- # step 4: run benchmark
97- - name : Run benchmarks
98- run : go test -bench=. -benchmem ./... | tee benchmark.txt
99-
100- # step 5: download previous benchmark result from cache (if exists)
101- - name : Download previous benchmark data
102- uses : actions/cache@v4
96+ # step 4: restore previous benchmark history (if exists)
97+ - name : Restore benchmark history
98+ id : benchmark-cache
99+ uses : actions/cache/restore@v4
103100 with :
104101 path : ./cache
105- key : ${{ runner.os }}-benchmark
102+ key : ${{ runner.os }}-benchmark-${{ github.ref_name }}
103+ restore-keys : |
104+ ${{ runner.os }}-benchmark-
105+
106+ # step 5: run benchmark
107+ - name : Run benchmarks
108+ run : go test -run=^$ -bench=. -benchmem ./... | tee benchmark.txt
106109
107110 # step 6: upload benchmark
108111 - name : Upload benchmark results
@@ -116,3 +119,11 @@ jobs:
116119 external-data-json-path : ./cache/benchmark-data.json
117120 # Workflow will fail when an alert happens
118121 fail-on-alert : true
122+
123+ # step 7: persist updated benchmark history
124+ - name : Save benchmark history
125+ if : always()
126+ uses : actions/cache/save@v4
127+ with :
128+ path : ./cache
129+ key : ${{ runner.os }}-benchmark-${{ github.ref_name }}-${{ github.run_id }}
0 commit comments