forked from mrc-ide/malariasimulation
-
Notifications
You must be signed in to change notification settings - Fork 1
111 lines (100 loc) · 3.59 KB
/
touchstone.yaml
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
name: Continuous benchmarking
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true
on:
issue_comment:
types: ['created', 'edited']
env:
# Annoyingly, GHA doesn't support workflow-level conditions.
# Use a env variables to avoid repeating this throughout each job.
RUN_WORKFLOW: >-
${{
github.event.issue.pull_request &&
startsWith(github.event.comment.body, '/benchmark') && (
github.event.comment.author_association == 'OWNER' ||
github.event.comment.author_association == 'MEMBER' ||
github.event.comment.author_association == 'COLLABORATOR'
)
}}
jobs:
prepare:
if: {{ env.RUN_WORKFLOW == "true" }}
runs-on: ubuntu-latest
steps:
- name: Set commit status as in progress
uses: actions/github-script@v7
with:
script: |
var pr = (await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
})).data;
var head_sha = pr.head.sha;
var url = "https://github.com/${{github.repository}}/actions/runs/${{ github.run_id }}";
github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: head_sha,
state: "pending",
target_url: url,
description: 'Benchmarking in progress...',
context: 'touchstone'
});
build:
if: {{ env.RUN_WORKFLOW == "true" }}
permissions: read-all
runs-on: ubuntu-22.04
env:
RSPM: "https://packagemanager.posit.co/cran/__linux__/jammy/2024-05-15"
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: lorenzwalthert/touchstone/actions/receive@main
comment:
needs: build
if: {{ always() && env.RUN_WORKFLOW == "true" }}
runs-on: ubuntu-latest
steps:
- name: Download benchmarking results
if: needs.build.result == 'success'
# Version number must match the one used by touchstone when uploading
uses: actions/download-artifact@v2
with:
name: pr
- name: 'Comment on PR'
if: needs.build.result == 'success'
uses: actions/github-script@v7
with:
script: |
var fs = require('fs');
var body = fs.readFileSync('./info.txt').toString();
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: body
});
- name: Update commit status
uses: actions/github-script@v7
with:
script: |
var pr = (await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
})).data;
var head_sha = pr.head.sha;
var url = "https://github.com/${{github.repository}}/actions/runs/${{ github.run_id }}";
// TODO: take comment step into account
var result = "${{ needs.build.result }}";
github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: head_sha,
state: result,
target_url: url,
description: result == "success" ? 'Benchmarking succeeded!' : 'Benchmarking failed!',
context: 'touchstone'
});