forked from Josh-XT/AGiXT
-
Notifications
You must be signed in to change notification settings - Fork 0
164 lines (155 loc) · 6.02 KB
/
tests.yml
File metadata and controls
164 lines (155 loc) · 6.02 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
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
name: Run Tests
on:
workflow_call:
inputs:
notebook:
type: string
required: true
description: file to run (ending in .ipynb), can be directory to batch run (without trailing slash)
image:
type: string
required: true
port:
type: string
port-mapping:
type: string
additional-python-dependencies:
type: string
description: add whatever pip you need here
default: "openai requests agixtsdk qrcode==7.4.2"
database-type:
type: string
default: "postgresql"
description: "Database type to use"
report-name:
type: string
default: "test-reports"
description: "Name of the report"
secrets:
api-key:
description: Optional api-key available as os.getenv('API_KEY') in your notebook
DISCORD_WEBHOOK:
description: Optional discord webhook available as os.getenv('DISCORD_WEBHOOK') in your notebook
jobs:
run-tests:
runs-on: ubuntu-22.04
outputs:
digest: ${{ steps.dockerBuild.outputs.digest }}
services:
dbservice:
image: postgres:latest
ports:
- 5432
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
agixt:
image: ${{ inputs.image }}
ports:
- ${{ inputs.port-mapping || format('{0}:{1}', inputs.port, inputs.port) }}
options: >-
--health-cmd "curl -f http://localhost:${{ inputs.port }}"
--health-interval 10s
--health-timeout 60s
--health-retries 5
--health-start-period 2m
env:
DATABASE_TYPE: ${{ inputs.database-type }}
DATABASE_HOST: dbservice
DATABASE_USER: postgres
DATABASE_PASSWORD: postgres
DATABASE_PORT: 5432
DATABASE_NAME: postgres
LOG_LEVEL: INFO
AGIXT_API_KEY: just-a-test
AGIXT_URI: http://agixt:7437
WORKING_DIRECTORY: /agixt/WORKSPACE
TOKENIZERS_PARALLELISM: 'false'
UVICORN_WORKERS: 14
EZLOCALAI_API_URI: https://api.ezlocal.ai/v1/
EZLOCALAI_API_KEY: testing
EZLOCALAI_MAX_TOKENS: "32000"
TZ: America/New_York
steps:
- uses: actions/setup-python@v5.3.0
with:
python-version: '3.10'
- name: Checkout
uses: actions/checkout@v4.2.2
with:
fetch-depth: 1
- name: Install Python dependencies
run: pip3 install jupyter nbconvert[webpdf] ${{ inputs.additional-python-dependencies }}
- name: Update package lists and install jupyter output generation dependencies
run: |
sudo apt-get update
sudo apt-get install --fix-missing -y pandoc texlive-xetex texlive-fonts-recommended texlive-plain-generic curl ffmpeg
- name: Set notebook and artifact files
run: |
notebook="${{ inputs.notebook }}"
if ${{ endsWith( inputs.notebook, 'ipynb' ) }} ; then
echo "notebook-file=${notebook}" >> "$GITHUB_ENV"
echo "artifact-file=${notebook%.*}.pdf" >> "$GITHUB_ENV"
else
echo "notebook-file=${notebook}/*.ipynb" >> "$GITHUB_ENV"
echo "artifact-file=${notebook}/*.pdf" >> "$GITHUB_ENV"
fi
- name: Check AGiXT logs
run: docker logs ${{ job.services.agixt.id }} --follow &
- name: Execute notebook
id: execute_notebook
env:
API_KEY: ${{ secrets.api-key }}
run: |
echo "Executing notebook with strict error checking..."
# First try to execute and generate PDF
python3 -m nbconvert --execute --log-level INFO --to pdf ${{ env.notebook-file }}
STRICT_STATUS=$?
echo "strict_status=${STRICT_STATUS}" >> $GITHUB_ENV
- name: Rerun allowing errors if strict status is not 0
if: env.strict_status != '0'
run: |
echo "Executing notebook with error tolerance..."
python3 -m nbconvert --execute --allow-errors --log-level INFO --to pdf ${{ env.notebook-file }}
- name: Send Report to Discord
if: always()
run: |
# Set message based on stored test outcome
BRANCH_NAME=$(echo ${{ github.ref }} | awk -F'/' '{print $NF}')
if [ "${{ github.actor }}" == "Josh-XT" ]; then
DISCORD_NAME="<@381837595522367488>"
elif [ "${{ github.actor }}" == "AGiXT" ]; then
DISCORD_NAME="<@329145730725838858>"
elif [ "${{ github.actor }}" == "waiscodes" ]; then
DISCORD_NAME="<@670762167037067304>"
elif [ "${{ github.actor }}" == "birdup000" ]; then
DISCORD_NAME="<@856308374567256074>"
elif [ "${{ github.actor }}" == "Nick-XT" ]; then
DISCORD_NAME="<@381908912951001088>"
else
DISCORD_NAME="**${{ github.actor }}**"
fi
if [ "${{ env.strict_status }}" != "0" ]; then
MESSAGE="❌ **TEST FAILURE**: **${{ inputs.report-name }}** on repository **${{ github.repository }}** branch **$BRANCH_NAME** commit **${{ github.sha }}** by ${DISCORD_NAME} "
else
MESSAGE="✅ Test passed: **${{ inputs.report-name }}** on repository **${{ github.repository }}** branch **$BRANCH_NAME** commit **${{ github.sha }}** by **${{ github.actor }}**"
fi
FILE_TO_SEND="tests/report.mp4"
# If it doesn't exist, send the PDF
if [ ! -f $FILE_TO_SEND ]; then
FILE_TO_SEND="${{ env.artifact-file }}"
fi
echo "Sending Report: $FILE_TO_SEND"
curl -H "Content-Type:multipart/form-data" \
-F "file=@$FILE_TO_SEND" \
-F "content=$MESSAGE" \
"${{ secrets.DISCORD_WEBHOOK }}"
- uses: actions/upload-artifact@v4.4.3
if: always()
with:
name: ${{ inputs.report-name }}
path: ${{ env.artifact-file }}
- name: Exit with test status
if: env.strict_status != '0'
run: exit 1