Skip to content

Commit f6efb4a

Browse files
committed
chore: add slack messaging capability to the self-test.sh script
See docs/self-test/roberta/README.md for details
1 parent 42382ab commit f6efb4a

File tree

4 files changed

+92
-1
lines changed

4 files changed

+92
-1
lines changed

deploy/self-test/roberta/1gpu/once.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,26 @@ spec:
5555
# value: "-V"
5656
- name: VARIANTS
5757
value: roberta-1gpu
58+
- name: SLACK_TEAMID
59+
valueFrom:
60+
secretKeyRef:
61+
name: codeflare-self-test-slack
62+
key: TEAMID
63+
- name: SLACK_CHANNELID
64+
valueFrom:
65+
secretKeyRef:
66+
name: codeflare-self-test-slack
67+
key: CHANNELID
68+
- name: SLACK_TOKEN
69+
valueFrom:
70+
secretKeyRef:
71+
name: codeflare-self-test-slack
72+
key: TOKEN
73+
- name: SLACK_USERNAME
74+
valueFrom:
75+
secretKeyRef:
76+
name: codeflare-self-test-slack
77+
key: USERNAME
5878
- name: ML_CODEFLARE_ROBERTA_GITHUB_USER
5979
valueFrom:
6080
secretKeyRef:

deploy/self-test/roberta/1gpu/periodic.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,26 @@ spec:
5959
# value: "-V"
6060
- name: VARIANTS
6161
value: roberta-1gpu
62+
- name: SLACK_TEAMID
63+
valueFrom:
64+
secretKeyRef:
65+
name: codeflare-self-test-slack
66+
key: TEAMID
67+
- name: SLACK_CHANNELID
68+
valueFrom:
69+
secretKeyRef:
70+
name: codeflare-self-test-slack
71+
key: CHANNELID
72+
- name: SLACK_TOKEN
73+
valueFrom:
74+
secretKeyRef:
75+
name: codeflare-self-test-slack
76+
key: TOKEN
77+
- name: SLACK_USERNAME
78+
valueFrom:
79+
secretKeyRef:
80+
name: codeflare-self-test-slack
81+
key: USERNAME
6282
- name: ML_CODEFLARE_ROBERTA_GITHUB_USER
6383
valueFrom:
6484
secretKeyRef:

deploy/self-test/self-test.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,38 @@ else
1717
fi
1818
echo "Using these variants: $variants"
1919

20+
function cleanup {
21+
STATUS=$?
22+
23+
TEAMID=$SLACK_TEAMID
24+
CHANNELID=$SLACK_CHANNELID
25+
TOKEN=$SLACK_TOKEN
26+
USERNAME=${SLACK_USERNAME-"Self-test Bot"}
27+
28+
if [ -n "$TEAMID" ] && [ -n "$CHANNELID" ] && [ -n "$TOKEN" ]; then
29+
if [ "$STATUS" = "0" ]; then
30+
ICON=":green_heart:"
31+
TEXT="$(date)\nSuccessful run\nVariants: $variants"
32+
else
33+
ICON=":red-siren:"
34+
TEXT="$(date)\nFailed run\nVariants: $variants"
35+
# TODO, add tee'd logs of failing run
36+
fi
37+
38+
39+
curl -X POST \
40+
--data-urlencode "payload={\"channel\": \"#$CHANNEL\", \"username\": \"$USERNAME\", \"text\": \"$TEXT\", \"icon_emoji\": \"$ICON\"}" \
41+
https://hooks.slack.com/services/$TEAMID/$CHANNELID/$TOKEN
42+
fi
43+
}
44+
45+
trap "cleanup" EXIT
46+
2047
for variant in $variants; do
2148
# for profile in ./tests/kind/profiles/*; do
2249
for profile in $variant/keep-it-simple; do
2350
echo "================== $profile =================="
51+
# TODO tee logs so that we can send them to slack
2452
./tests/kind/run.sh -i $profile
2553
done
2654
done

docs/self-test/roberta/README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,34 @@ export GITHUB_TOKEN=mygithubtoken
3434
```
3535

3636
```shell
37-
kubectl create secret github \
37+
kubectl create secret generic github \
3838
--from-literal=GITHUB_USER=$(echo -n $GITHUB_USER | base64) \
3939
--from-literal=GITHUB_TOKEN=$(echo -n $GITHUB_TOKEN | base64)
4040
```
4141

42+
## Create a `slack` secret, if desired
43+
44+
If you wish to post to a Slack channel, create a Kubernetes secret named `codeflare-self-test-slack` with the following data fields:
45+
46+
```shell
47+
export SLACK_TEAMID=myteamid
48+
```
49+
50+
```shell
51+
export SLACK_CHANNELID=mychannelid
52+
```
53+
54+
```shell
55+
export SLACK_TOKEN=mytoken
56+
```
57+
58+
```shell
59+
kubectl create secret generic codeflare-self-test-slack \
60+
--from-literal=TEAMID=$(echo -n SLACK_TEAMID | base64) \
61+
--from-literal=CHANNELID=$(echo -n SLACK_CHANNELID | base64) \
62+
--from-literal=TOKEN=$(echo -n SLACK_TOKEN | base64)
63+
```
64+
4265
### Deploy the automation
4366

4467
```shell

0 commit comments

Comments
 (0)