-
Notifications
You must be signed in to change notification settings - Fork 186
73 lines (65 loc) · 2.25 KB
/
Copy pathnightly-benchmarks.yml
File metadata and controls
73 lines (65 loc) · 2.25 KB
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
name: Nightly contract benchmarks
on:
schedule:
- cron: "0 2 * * *"
workflow_dispatch:
permissions:
contents: read
issues: write
jobs:
bench:
name: Vault operation benchmarks
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache Cargo registry
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-nightly-bench-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-nightly-bench-
- name: Run benchmarks and compare to baseline
id: bench
run: bash contracts/vault/scripts/benchmark.sh
- name: Publish job summary
if: always()
run: |
if [ -f benchmark-report.md ]; then
cat benchmark-report.md >> "$GITHUB_STEP_SUMMARY"
else
echo "Benchmark report was not produced." >> "$GITHUB_STEP_SUMMARY"
fi
- name: Post report to GitHub Issues
if: always() && hash gh 2>/dev/null
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [ ! -f benchmark-report.md ]; then
echo "No report to post"
exit 0
fi
TITLE="Nightly contract benchmarks $(date -u +%Y-%m-%d)"
BODY_FILE="$(mktemp)"
{
echo "Automated report from \`.github/workflows/nightly-benchmarks.yml\`."
echo
echo "Workflow: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
echo "Commit: \`${GITHUB_SHA}\`"
echo
cat benchmark-report.md
} > "$BODY_FILE"
ISSUE_NUMBER="$(gh issue list --label nightly-benchmark --state open --limit 1 --json number --jq '.[0].number // empty')"
if [ -n "$ISSUE_NUMBER" ]; then
gh issue comment "$ISSUE_NUMBER" --body-file "$BODY_FILE"
else
gh issue create --title "$TITLE" --label "nightly-benchmark" --body-file "$BODY_FILE" || \
gh issue create --title "$TITLE" --body-file "$BODY_FILE"
fi