-
Notifications
You must be signed in to change notification settings - Fork 3
70 lines (64 loc) · 3.55 KB
/
pytest-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
name: Backend Tests
on:
pull_request:
branches:
- dev
jobs:
build-and-test:
runs-on: ubuntu-latest
env:
MONGO_USER: ${{ secrets.MONGO_USER }}
MONGO_PASSWORD: ${{ secrets.MONGO_PASSWORD }}
MONGO_HOST: ${{ secrets.MONGO_HOST }}
MONGO_DB: ${{ secrets.MONGO_DB }}
FIREBASE_SERVICE_KEY: ${{ secrets.FIREBASE_SERVICE_KEY }}
FIREBASE_API_KEY: ${{ secrets.FIREBASE_API_KEY }}
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
IMGUR_KEY: ${{ secrets.IMGUR_KEY }}
SENDGRID_API_KEY: ${{ secrets.SENDGRID_API_KEY }}
SENDER_EMAIL: ${{ secrets.SENDER_EMAIL }}
TWILIO_ACCOUNT_SID: ${{ secrets.TWILIO_ACCOUNT_SID }}
TWILIO_AUTH_TOKEN: ${{ secrets.TWILIO_AUTH_TOKEN }}
TWILIO_PHONE: ${{ secrets.TWILIO_PHONE }}
FLASK_APP: ${{ secrets.FLASK_APP }}
BASE_URL: ${{ secrets.BASE_URL }}
TEST_MENTOR_EMAIL: ${{ secrets.TEST_MENTOR_EMAIL }}
TEST_MENTOR_PASSWORD: ${{ secrets.TEST_MENTOR_PASSWORD }}
TEST_MENTOR_PHONE_NUMBER: ${{ secrets.TEST_MENTOR_PHONE_NUMBER }}
TEST_MENTEE_EMAIL: ${{ secrets.TEST_MENTEE_EMAIL }}
TEST_MENTEE_PASSWORD: ${{ secrets.TEST_MENTEE_PASSWORD }}
TEST_MENTEE_PHONE_NUMBER: ${{ secrets.TEST_MENTEE_PHONE_NUMBER }}
TEST_PARTNER_EMAIL: ${{ secrets.TEST_PARTNER_EMAIL }}
TEST_PARTNER_PASSWORD: ${{ secrets.TEST_PARTNER_PASSWORD }}
TEST_GUEST_EMAIL: ${{ secrets.TEST_GUEST_EMAIL }}
TEST_GUEST_PASSWORD: ${{ secrets.TEST_GUEST_PASSWORD }}
TEST_ADMIN_EMAIL: ${{ secrets.TEST_ADMIN_EMAIL }}
TEST_ADMIN_PASSWORD: ${{ secrets.TEST_ADMIN_PASSWORD }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Build and run Backend
run: |
cd backend
touch firebase_service_key.json
echo "$FIREBASE_SERVICE_KEY" > firebase_service_key.json
cp firebase_service_key.json ./tests
ls
cat firebase_service_key.json
docker build -t backend .
docker images
docker run --name backend -d -e SENDGRID_API_KEY="$SENDGRID_API_KEY" -e SENDER_EMAIL="$SENDER_EMAIL" -e TWILIO_ACCOUNT_SID="$TWILIO_ACCOUNT_SID" -e TWILIO_AUTH_TOKEN="$TWILIO_AUTH_TOKEN" -e TWILIO_PHONE="$TWILIO_PHONE" -e FLASK_APP="$FLASK_APP" -e IMGUR_KEY="$IMGUR_KEY" -e FIREBASE_API_KEY="$FIREBASE_API_KEY" -e MONGO_USER="$MONGO_USER" -e MONGO_PASSWORD="$MONGO_PASSWORD" -e MONGO_HOST="$MONGO_HOST" -e MONGO_DB="$MONGO_DB" -e GOOGLE_APPLICATION_CREDENTIALS="$GOOGLE_APPLICATION_CREDENTIALS" -e BASE_URL="$BASE_URL" -e TEST_MENTOR_EMAIL="$TEST_MENTOR_EMAIL" -e TEST_MENTOR_PASSWORD="$TEST_MENTOR_PASSWORD" -e TEST_MENTOR_PHONE_NUMBER="$TEST_MENTOR_PHONE_NUMBER" -e TEST_MENTEE_EMAIL="$TEST_MENTEE_EMAIL" -e TEST_MENTEE_PASSWORD="$TEST_MENTEE_PASSWORD" -e TEST_MENTEE_PHONE_NUMBER="$TEST_MENTEE_PHONE_NUMBER" -e TEST_PARTNER_EMAIL=$TEST_PARTNER_EMAIL -e TEST_PARTNER_PASSWORD=$TEST_PARTNER_PASSWORD -e TEST_GUEST_EMAIL="$TEST_GUEST_EMAIL" -e TEST_GUEST_PASSWORD="$TEST_GUEST_PASSWORD" -e TEST_ADMIN_EMAIL="$TEST_ADMIN_EMAIL" -e TEST_ADMIN_PASSWORD="$TEST_ADMIN_PASSWORD" -p 8000:8000 backend
- name: Install pytest
run: |
docker exec backend /bin/bash -c "pip install -U pytest"
- name: Check if Flask server is up
run: |
retries=100
until curl -sSf http://localhost:8000/api/translation; do
((retries--)) || exit 1
sleep 1
done
- name: Run Tests
run: |
docker ps
docker exec backend /bin/bash -c "cd tests && pytest"