-
Notifications
You must be signed in to change notification settings - Fork 2
97 lines (80 loc) · 2.73 KB
/
Copy pathtests.yaml
File metadata and controls
97 lines (80 loc) · 2.73 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
name: Unit Tests
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
test:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: ["macos-latest", "ubuntu-latest"]
python-version: ["3.12", "3.11"]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: setup.py
- name: Install dependencies
run: |
python -m pip install -U pip setuptools wheel
pip install -r requirements.txt
pip install -r requirements_dev.txt
pip install -e .
pip list
- name: Authenticate with GCP
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCLOUD_SERVICE_KEY }}
- name: Set up Google Cloud SDK
uses: google-github-actions/setup-gcloud@v2
with:
project_id: breathing-data
- name: Download from GCS
run: |
gsutil cp gs://oxygen-o2/data/model.onnx ./models/
- name: Run tests & coverage
run: |
coverage run -m pytest tests/
coverage report -m -i
- name: Run Performance tests
run: |
rm -rf reports/locust_results
mkdir reports/locust_results
uvicorn --reload --port 8000 src.plant_leaves.api:app &
UVICORN_PID=$!
# Wait for uvicorn to start by checking the port
sleep 10
locust -f tests/performancetests/locustfile.py --headless --users 10 --spawn-rate 1 --run-time 10s --host=http://localhost:8000 --csv=reports/locust_results/
echo "Stopping uvicorn..."
kill $UVICORN_PID
- name: Upload Test Artifacts
uses: actions/upload-artifact@v4
with:
name: Test-Artifacts-${{ matrix.operating-system }}-${{ matrix.python-version }}
path: reports/
build:
needs: test
if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.base_ref == 'main') }}
runs-on: ubuntu-latest
steps:
- name: Debug secrets
run: |
echo "GCLOUD_SERVICE_KEY: ${{ secrets.GCLOUD_SERVICE_KEY }}" | wc -c
- name: Checkout code
uses: actions/checkout@v4
- name: Auth with GCP
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCLOUD_SERVICE_KEY }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
- name: Submit build
run: gcloud builds submit --config configs/cloud/cloudbuild.yaml --project breathing-data