🏊🏻♂️ Thread chat #204
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Frontend 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 }} | |
MENTOR_EMAIL: ${{ secrets.TEST_MENTOR_EMAIL }} | |
MENTEE_EMAIL: ${{ secrets.TEST_MENTEE_EMAIL }} | |
PARTNER_EMAIL: ${{ secrets.TEST_PARTNER_EMAIL }} | |
GUEST_EMAIL: ${{ secrets.TEST_GUEST_EMAIL }} | |
MENTOR_PASSWORD: ${{ secrets.TEST_MENTOR_PASSWORD }} | |
MENTEE_PASSWORD: ${{ secrets.TEST_MENTEE_PASSWORD }} | |
PARTNER_PASSWORD: ${{ secrets.TEST_PARTNER_PASSWORD }} | |
GUEST_PASSWORD: ${{ secrets.TEST_GUEST_PASSWORD }} | |
MENTEE_PROFILE_ID: ${{ secrets.TEST_MENTEE_PROFILE_ID }} | |
MENTOR_PROFILE_ID: ${{ secrets.TEST_MENTOR_PROFILE_ID }} | |
PARTNER_PROFILE_ID: ${{ secrets.TEST_PARTNER_PROFILE_ID }} | |
GUEST_PROFILE_ID: ${{ secrets.TEST_GUEST_PROFILE_ID }} | |
CYPRESS_ENV: ${{ secrets.CYPRESS_ENV }} | |
CYPRESS_BASE_URL: ${{ secrets.CYPRESS_BASE_URL }} | |
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 | |
docker build -t backend . | |
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" -p 8000:8000 backend | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Build and run Frontend | |
run: | | |
cd frontend | |
docker build -t frontend-app . | |
docker run --name frontend-app -d -e REACT_APP_FIREBASE_API_KEY="$FIREBASE_API_KEY" -p 3000:3000 frontend-app | |
- name: Wait for Frontend to be ready | |
run: | | |
retries=100 | |
until curl -sSf http://localhost:3000; do | |
((retries--)) || exit 1 | |
sleep 1 | |
done | |
- name: Create cypress.env.json | |
run: | | |
cd tests | |
rm cypress.env.json | |
touch cypress.env.json | |
echo "$CYPRESS_ENV" > cypress.env.json | |
- name: Run Cypress Tests | |
run: | | |
npm install | |
cd tests | |
CYPRESS_BASE_URL="$CYPRESS_BASE_URL" npx cypress run --headless |