Skip to content

Commit 9682f71

Browse files
authored
Merge pull request #127 from isucon/post-ci-result-on-bench
Post ci result on bench
2 parents 1ff80f4 + 41f1946 commit 9682f71

File tree

4 files changed

+29
-5
lines changed

4 files changed

+29
-5
lines changed

.github/workflows/full.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Full Test
2-
on: [push]
2+
on: [pull_request]
33
jobs:
44
test:
55
strategy:
@@ -34,6 +34,12 @@ jobs:
3434
- name: setup tools
3535
run: |
3636
sudo apt-get update && sudo apt-get install -y mysql-client-8.0 sqlite3
37+
gh version && exit 0
38+
cd /tmp
39+
curl -sLO https://github.com/cli/cli/releases/download/v2.13.0/gh_2.13.0_linux_amd64.tar.gz
40+
tar xf gh_2.13.0_linux_amd64.tar.gz
41+
sudo install gh_2.13.0_linux_amd64/bin/gh /usr/local/bin
42+
gh version
3743
3844
- name: "build initial data"
3945
working-directory: ./data
@@ -51,7 +57,10 @@ jobs:
5157
- name: "run bench(default)"
5258
working-directory: ./bench
5359
run: |
54-
make ci
60+
make ci-with-comment
61+
env:
62+
GITHUB_REF_NAME: ${{ github.ref_name }}
63+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5564

5665
# 2coreのself hosted runnerに限りがあるので一時コメントアウト
5766
# - name: "前ベンチが完全にタイムアウトするまで少しだけ待つ"

bench/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
bench
1+
./bench
22
benchmarker*.json

bench/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ prepare: bench
1111
./bench -duration 5s
1212

1313
ci: bench
14-
./bench -target-addr 127.0.0.1:3000 -target-url http://t.isucon.dev
14+
rm -f ci.log
15+
./bench -target-addr 127.0.0.1:3000 -target-url http://t.isucon.dev | tee ci.log
16+
17+
ci-with-comment: ci
18+
gh issue comment --body-file ci.log $$(echo $$GITHUB_REF_NAME | sed -e 's/\/merge//')
1519

1620
ci-loadtype-light: bench
1721
./bench -target-addr 127.0.0.1:3000 -target-url http://t.isucon.dev -load-type light

bench/cmd/bench/main.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"math/rand"
88
"os"
9+
"sort"
910
"time"
1011

1112
"github.com/isucon/isucandar"
@@ -104,7 +105,17 @@ func main() {
104105
scenario.PrintScenarioCount()
105106
score, addition, deduction := SumScore(result)
106107
bench.ContestantLogger.Printf("SCORE: %d (+%d %d)", score, addition, -deduction)
107-
bench.ContestantLogger.Printf("RESULT: %#v", AllTagBreakdown(result))
108+
br := AllTagBreakdown(result)
109+
tags := make([]string, 0, len(br))
110+
for tag, score := range br {
111+
tags = append(tags, fmt.Sprintf("%s: %d", tag, score))
112+
}
113+
sort.Slice(tags, func(i, j int) bool {
114+
return tags[i] < tags[j]
115+
})
116+
for _, tag := range tags {
117+
fmt.Println(tag)
118+
}
108119
bench.AdminLogger.Printf("%s", pp.Sprint(AllTagBreakdown(result)))
109120

110121
// 0点以下(fail)ならエラーで終了

0 commit comments

Comments
 (0)