forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 0
120 lines (113 loc) · 4.09 KB
/
bench_matrix.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
# Run all benchmarks when a comment containing "test performance please"
# comment is posted on a PR.
name: Benchmarks Matrix
on:
issue_comment:
types: [created]
workflow_dispatch:
inputs:
commit:
description: "Commit to benchmark."
required: true
type: string
repo:
description: "GitHub repository containing the commit to benchmark."
required: true
type: string
default: "mbovel/scala3" # TODO(mbovel): Change to scala/scala3
runs:
description: "Number of runs to perform."
required: true
type: number
default: 1
profile:
description: "Profile to run: 'merge' to run the benchmarks that are run on every PR merge (shorter), 'nightly' to run nightly benchmarks (longer), or 'all' to run both."
required: true
type: choice
options:
- merge
- nightly
- all
jobs:
generate_runs:
name: Generate run definitions
if: github.event_name == 'workflow_dispatch' || (github.event.issue.pull_request && contains(github.event.comment.body, 'test performance please'))
runs-on: ubuntu-latest
steps:
- id: generate_runs
uses: actions/github-script@v7
with:
script: |
function get_commits() {
if (context.eventName === 'issue_comment') {
const { data } = github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
});
const base = {
commit: data.base.sha,
repo: context.base.repo.full_name
};
const head = {
commit: data.head.sha,
repo: data.head.repo.full_name
};
return [base, head];
} else if (context.eventName === 'workflow_dispatch') {
return [{
commit: context.payload.inputs.commit,
repo: context.payload.inputs.repo
}];
} else {
throw new Error(`Unsupported event: ${context .eventName}`);
}
}
function get_runs() {
if (context.eventName === 'issue_comment') {
return [0];
} else if (context.eventName === 'workflow_dispatch') {
return Array.from({ length: context.payload.inputs.runs }, (_, i) => i);
} else {
throw new Error(`Unsupported event: ${context.eventName}`);
}
}
function get_profile() {
if (context.eventName === 'issue_comment') {
return context.payload.comment.body.includes('all') ? 'all' : 'merge';
} else if (context.eventName === 'workflow_dispatch') {
return context.payload.inputs.profile;
} else {
throw new Error(`Unsupported event: ${context.eventName}`);
}
}
const runs = [];
for (const run of get_runs()) {
for (const commit of get_commits()) {
const profile = get_profile();
const is_nightlys = profile === 'all' ? [false, true] : [profile === 'nightly'];
for (const is_nightly of is_nightlys) {
runs.push({
commit: commit.commit,
repo: commit.repo,
run: run,
is_nightly: is_nightly
});
}
}
}
core.setOutput('runs', JSON.stringify(runs));
outputs:
runs: ${{ steps.generate_runs.outputs.runs }}
run:
name: Run
needs: ['generate_runs']
strategy:
matrix:
run: ${{fromJson(needs.generate_runs.outputs.runs)}}
uses: ./.github/workflows/bench.yml
with:
commit: ${{ matrix.run.commit }}
repo: ${{ matrix.run.repo }}
run: ${{ matrix.run.run }}
is_nightly: ${{ matrix.run.is_nightly }}