Skip to content

Commit a0f2dae

Browse files
committed
ci: Automating scheduling benchmarking testing for PRs
1 parent e24a934 commit a0f2dae

File tree

3 files changed

+107
-0
lines changed

3 files changed

+107
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: RunBenchTest
2+
description: 'Runs a given Benchmark Test'
3+
inputs:
4+
path:
5+
description: Path to the performance test
6+
default: ""
7+
runName:
8+
description: Name of the run, for the purpose of file naming and github comments
9+
default: ""
10+
githubToken:
11+
descriptuon: Github secret token to use for commenting on PR
12+
default: ""
13+
runs:
14+
using: "composite"
15+
steps:
16+
- name: Run Test
17+
id: test-run
18+
shell: bash
19+
run: |
20+
{
21+
cd ${{ inputs.path }}
22+
mkdir output
23+
go test -tags=test_performance -run=1 -bench=. -count=1 -cpuprofile output/cpu.out -memprofile output/mem.out > output/results.txt
24+
echo 'OUTPUT<<EOF'
25+
cat output/results.txt
26+
echo EOF
27+
} >> "$GITHUB_OUTPUT"
28+
- uses: actions/upload-artifact@v4
29+
id: artifact-upload
30+
with:
31+
name: ${{ inputs.runName }}
32+
path: ${{ inputs.path }}/output
33+
- uses: actions/github-script@v7
34+
env:
35+
RESULTS: ${{ steps.test-run.outputs.OUTPUT }}
36+
UPLOAD: ${{ steps.artifact-upload.outputs.artifact-url }}
37+
with:
38+
github-token: ${{ inputs.githubToken }}
39+
script: |
40+
github.rest.issues.createComment({
41+
issue_number: context.issue.number,
42+
owner: context.repo.owner,
43+
repo: context.repo.repo,
44+
body: `# :mag: ${{ inputs.runName }} :mag:\nResults of benchmarking testing in \`${{ inputs.path }}\`: \n\`\`\`${process.env.RESULTS}\n\`\`\`\n${process.env.UPLOAD}`
45+
})

.github/dependabot.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,11 @@ updates:
6161
action-deps:
6262
patterns:
6363
- '*'
64+
- package-ecosystem: github-actions
65+
directory: .github/actions/run-bench-test
66+
schedule:
67+
interval: weekly
68+
groups:
69+
action-deps:
70+
patterns:
71+
- '*'
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: "Scheduling Benchmarking"
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- edited
8+
- synchronize
9+
- reopened
10+
paths:
11+
- "**.go"
12+
branches:
13+
- main
14+
15+
jobs:
16+
before:
17+
name: Before PR
18+
runs-on: ubuntu-latest
19+
permissions:
20+
pull-requests: write
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
path: ["pkg/controllers/provisioning/scheduling"]
25+
steps:
26+
- uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
29+
ref: ${{ github.event.pull_request.base.sha }}
30+
- uses: ./.github/actions/run-bench-test
31+
with:
32+
path: ${{ matrix.path }}
33+
runName: before-${{ strategy.job-index }}
34+
githubToken: ${{ secrets.GITHUB_TOKEN }}
35+
after:
36+
name: After PR
37+
runs-on: ubuntu-latest
38+
permissions:
39+
pull-requests: write
40+
strategy:
41+
fail-fast: false
42+
matrix:
43+
path: ["pkg/controllers/provisioning/scheduling"]
44+
steps:
45+
- uses: actions/checkout@v4
46+
with:
47+
fetch-depth: 0
48+
ref: ${{ github.event.pull_request.head.sha }}
49+
- uses: ./.github/actions/run-bench-test
50+
with:
51+
path: ${{ matrix.path }}
52+
runName: after-${{ strategy.job-index }}
53+
githubToken: ${{ secrets.GITHUB_TOKEN }}
54+

0 commit comments

Comments
 (0)