-
Notifications
You must be signed in to change notification settings - Fork 8
147 lines (137 loc) · 5.01 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: CI
on:
pull_request:
branches: [ main ]
push:
branches: [ main ]
tags: [ v* ]
jobs:
ci:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '21'
cache: 'maven'
- name: Test
run: mvn --batch-mode --update-snapshots verify
- name: Prepare release notes
uses: release-drafter/release-drafter@v5
with:
config-name: release-drafter.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
benchmark:
needs: [ ci ]
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '21'
cache: 'maven'
- name: Run java benchmarks
id: benchmark_java
run: |
mvn package -DskipTests=true
java -Djmh.executor=VIRTUAL -jar bench/bench-java/target/benchmarks.jar -i 5 -wi 5 -f 1 -to 1100ms -r 1000ms -w 1000ms -rf json -rff jmh-result-java.json | tee out.txt
echo 'output<<EOF' >> $GITHUB_OUTPUT
cat out.txt >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
- name: Run kotlin benchmarks
id: benchmark_kotlin
run: |
java -jar bench/bench-kotlin/target/benchmarks.jar -i 5 -wi 5 -f 1 -to 1100ms -r 1000ms -w 1000ms -rf json -rff jmh-result-kotlin.json | tee out.txt
echo 'output<<EOF' >> $GITHUB_OUTPUT
cat out.txt >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
- name: Merge java and kotlin benchmark results
run: jq -s '.[0] + .[1]' jmh-result-java.json jmh-result-kotlin.json > jmh-result-all.json
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Check & store benchmark result
uses: benchmark-action/github-action-benchmark@v1
# Only store updated benchmark results on main branch
if: steps.extract_branch.outputs.branch == 'main'
with:
tool: 'jmh'
output-file-path: jmh-result-all.json
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true
# Show alert with commit comment on detecting possible performance regression
alert-threshold: '120%'
# Enable alert commit comment
comment-on-alert: true
fail-on-alert: true
alert-comment-cc-users: '@adamw'
# Store benchmark results in the docs folder of the main branch
gh-pages-branch: ${{ steps.extract_branch.outputs.branch }}
benchmark-data-dir-path: 'docs/bench'
skip-fetch-gh-pages: true
- name: Comment on PR with results
uses: actions/github-script@v7
env:
JAVA_OUTPUT: ${{ steps.benchmark_java.outputs.output }}
KOTLIN_OUTPUT: ${{ steps.benchmark_kotlin.outputs.output }}
with:
script: |
function extractContent(str) {
const regex = /^Benchmark([\s\S]*?)(?=^Benchmark result)/m;
const match = str.match(regex);
return match ? match[1].trim() : null;
}
// Only if there's a PR within which we run
if (context.issue.number) {
let javaResults = extractContent(`${process.env.JAVA_OUTPUT}`);
let kotlinResults = extractContent(`${process.env.KOTLIN_OUTPUT}`);
let comment = `<details><summary>Benchmark results</summary>
\`\`\`
Java:
${javaResults}
Kotlin:
${kotlinResults}
\`\`\`
</details>`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
}
publishReleaseNotes:
name: Publish release notes
needs: [ ci ]
runs-on: ubuntu-22.04
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v'))
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '21'
- name: Extract version from tag name
run: |
version=${GITHUB_REF/refs\/tags\/v/}
echo "VERSION=$version" >> $GITHUB_ENV
- name: Publish release notes
uses: release-drafter/release-drafter@v5
with:
config-name: release-drafter.yml
publish: true
name: "v${{ env.VERSION }}"
tag: "v${{ env.VERSION }}"
version: "v${{ env.VERSION }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}