-
Notifications
You must be signed in to change notification settings - Fork 109
133 lines (114 loc) · 4.76 KB
/
bottest.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
on:
push:
branches:
- jgilles/bottest3
workflow_dispatch:
inputs:
pr_number:
description: 'Pull Request Number'
required: false
default: ''
issue_comment:
types: [created]
name: Automated bot test
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
jobs:
autobottest:
name: run bot test (30 bots)
runs-on: bots-runner
permissions: write-all
# filter for a comment containing 'benchmarks please'
if: ${{ github.event_name != 'issue_comment' || (github.event.issue.pull_request && contains(github.event.comment.body, 'bots please')) }}
env:
PR_NUMBER: ${{ github.event.inputs.pr_number || github.event.issue.number || null }}
steps:
- name: Check membership
if: ${{ github.event_name == 'issue_comment' }}
env:
CONTRIB_ORG: clockworklabs
COMMENT_AUTHOR: ${{ github.event.comment.user.login }}
ORG_READ_TOKEN: ${{ secrets.ORG_READ_TOKEN }}
run: |
curl -OL https://github.com/cli/cli/releases/download/v2.37.0/gh_2.37.0_linux_amd64.deb && sudo dpkg -i gh_2.37.0_linux_amd64.deb
if [[ $(GH_TOKEN=$ORG_READ_TOKEN gh api --paginate /orgs/{owner}/members --jq 'any(.login == env.COMMENT_AUTHOR)') != true ]]; then
gh pr comment $PR_NUMBER -b "Sorry, you don't have permission to run bot tests."
exit 1
fi
- name: Checkout sources
uses: actions/checkout@v4
- name: Post initial comment
run: |
if [[ $PR_NUMBER ]]; then
comment_parent=issues/$PR_NUMBER
comment_update=issues/comments
else
comment_parent=commits/$GITHUB_SHA
comment_update=comments
fi
comment_body="Bot test in progress..."
comment_id=$(gh api "/repos/{owner}/{repo}/$comment_parent/comments" -f body="$comment_body" --jq .id)
echo "COMMENT_UPDATE_URL=/repos/{owner}/{repo}/$comment_update/$comment_id" >>$GITHUB_ENV
- name: find PR branch
if: ${{ env.PR_NUMBER }}
run: echo "PR_REF=$(gh pr view $PR_NUMBER --json headRefName --jq .headRefName)" >>"$GITHUB_ENV"
- name: Checkout sources
uses: actions/checkout@v4
with:
ref: ${{ env.PR_REF || github.ref }}
fetch-depth: 1
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
components: clippy
toolchain: stable
target: wasm32-unknown-unknown
override: true
- name: Build the bots
run: |
git apply .github/workflows/bottest_tracing_fix.patch
cargo build --release --bin spacetime
- name: Run bot test script
run: |
echo "We're on a bots runner, so expecting to find the BitCraftBots repo set up in the expected location"
echo "Let's hope the bots runner is up to date!!!"
SPACETIME_BIN="$PWD/target/release/spacetime"
cd ~/BitCraftBots
# using 'exec' allows the process to receive graceful termination signals (note: actions is bad)
exec python3 -m scripts.bottest "$SPACETIME_BIN"
- name: Archive results
run: |
RESULTS_NAME="pr-$PR_NUMBER-$GITHUB_SHA"
mkdir -p bottest-results
cp ~/BitCraftBots/results.zip bottest-results/$RESULTS_NAME.zip
- name: Upload bot test results to DO spaces
uses: clockworklabs/s3-upload-action@master
with:
aws_key_id: ${{ secrets.AWS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY}}
aws_bucket: "spacetimedb-private-bottest-results"
source_dir: bottest-results
endpoint: https://nyc3.digitaloceanspaces.com
destination_dir: bottests
- name: Post comment
run: |
RESULTS_NAME="pr-$PR_NUMBER-$GITHUB_SHA"
BODY="<details><summary>Bot test results</summary>
Test results are stored on DO Spaces [here](https://cloud.digitalocean.com/spaces/spacetimedb-private-bottest-results?path=bottests%2F). You'll need to log in
(we keep these secret).
The results of this test are named $RESULTS_NAME.zip.
</details>"
gh api "$COMMENT_UPDATE_URL" -X PATCH -f body="$BODY"
- name: Post failure comment
if: ${{ failure() && env.COMMENT_UPDATE_URL }}
run: |
BODY="Bot test failed. Please check [the workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details."
gh api "$COMMENT_UPDATE_URL" -X PATCH -f body="$BODY"
- name: Clean up
if: always()
run: |
rm -fr /stdb/*
rm -fr bottest-results/
rm -fr crates/bench/bottest/