generated from opensafely-core/repo-template
-
Notifications
You must be signed in to change notification settings - Fork 3
73 lines (62 loc) · 2.15 KB
/
generative-tests.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
---
name: Long-running generative tests
on:
workflow_dispatch:
schedule:
- cron: "26 0 * * *"
jobs:
gentests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: opensafely-core/setup-action@v1
with:
install-just: true
python-version: "3.11"
- name: Set up dev environment
run: just devenv
# To work around memory leak issues in our database containers we run the
# tests in multiple smaller batches, recreating the containers between
# each batch
- name: Run `just test tests/generative/test_query_model.py::test_query_model` in batches
run: |
set -euo pipefail
start_time=$(date +%s)
export \
GENTEST_EXAMPLES=150 \
GENTEST_RANDOMIZE=t \
GENTEST_MAX_DEPTH=25
# We get a maximum of 6 hours runtime with Github Actions so breaking
# the loop after 4 hours feels like a reasonably balance of getting a
# decent amount of generative testing done while leaving plenty of
# headroom.
end_time=$((start_time + 4 * 3600))
i=1
while true; do
echo
echo "==> Running test batch $i with $GENTEST_EXAMPLES examples"
echo
# Do the actual testing
set +e
just test tests/generative/test_query_model.py::test_query_model
rc=$?
set -e
# 6 == dead database error, continue to remove db containers and start new batch
if [[ $rc -ne 0 && $rc -ne 6 ]]; then
exit $rc
fi
if [[ $(date +%s) -ge $end_time ]]; then
break
fi
just remove-database-containers
((i++))
done
- name: "Notify Slack on Failure"
if: failure() && github.ref_name == 'main'
uses: zuplo/github-action-slack-notify-build@cf8e7e66a21d76a8125ea9648979c30920195552 # v2
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
with:
channel_id: C069YDR4NCA
status: "Generative Test Failure"
color: danger