Spaces:
Sleeping
Sleeping
Sanjeeth
commited on
Create test-workflow.yml
Browse files
.github/workflows/test-workflow.yml
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Run Tests on Push
|
2 |
+
|
3 |
+
on:
|
4 |
+
push:
|
5 |
+
branches:
|
6 |
+
- main # Change this to the branch you want to trigger testing
|
7 |
+
|
8 |
+
jobs:
|
9 |
+
run-tests:
|
10 |
+
runs-on: ubuntu-latest
|
11 |
+
|
12 |
+
steps:
|
13 |
+
- name: Checkout code
|
14 |
+
uses: actions/checkout@v3
|
15 |
+
|
16 |
+
# Step 2: Set up Python
|
17 |
+
- name: Set up Python
|
18 |
+
uses: actions/setup-python@v4
|
19 |
+
with:
|
20 |
+
python-version: '3.11.4'
|
21 |
+
|
22 |
+
- name: Install dependencies
|
23 |
+
run: |
|
24 |
+
python -m pip install --upgrade pip
|
25 |
+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
26 |
+
|
27 |
+
- name: Run unittest
|
28 |
+
run: |
|
29 |
+
python -m unittest discover -s . -p 'test_app.py'
|
30 |
+
|
31 |
+
- name: Send Discord Notification
|
32 |
+
if: failure()
|
33 |
+
run: |
|
34 |
+
curl -H "Content-Type: application/json" \
|
35 |
+
-d "{\"username\": \"GitHub Bot\", \"content\": \"❌ **Test failure in repository: ${{ github.repository }}** on branch **${{ github.ref_name }}**. [Check logs](${{
|
36 |
+
github.event.compare }})\"}" \
|
37 |
+
${{ secrets.DISCORD_WEBHOOK_URL }}
|