-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (61 loc) · 2.16 KB
/
Copy pathtest.yml
File metadata and controls
64 lines (61 loc) · 2.16 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
name: Tests
on:
push:
branches: [working, master]
pull_request:
branches: [master]
jobs:
test-backend:
name: Backend Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- run: pip install -e ".[dev]"
working-directory: projects/stock-risk-scanner
- run: pytest -v --tb=short
working-directory: projects/stock-risk-scanner
test-dashboard:
name: Dashboard Tests
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- run: pip install -r requirements.txt
working-directory: dashboard
- run: |
pip install pytest pytest-json-report
echo 'API_URL = "http://localhost:8000"' > .streamlit/secrets.toml
python -m pytest tests/ -v --tb=short --json-report --json-report-file=test_results.json
working-directory: dashboard
- uses: actions/upload-artifact@v4
if: always()
with:
name: test-results
path: dashboard/test_results.json
- name: Update test_results.json via PR
if: github.ref == 'refs/heads/master' && success()
env:
GH_TOKEN: ${{ github.token }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout -B ci/test-results
git add dashboard/test_results.json
git diff --cached --quiet && echo "No changes" && exit 0
git commit -m "ci: update test_results.json"
git push -f origin ci/test-results
# Create or update PR
existing=$(gh pr list --head ci/test-results --state open --json number -q '.[0].number')
if [ -z "$existing" ]; then
gh pr create --title "ci: update test_results.json" \
--body "Auto-generated by CI. Updates test results for the Tests tab on Streamlit." \
--head ci/test-results --base master
fi