-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🧒🏻 Docker, pytest and cypress setups #819
Merged
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
91d88fe
test: Add initial structure for the frontend and backend tests, updat…
HamzaAnis f24763c
Added more test cases and loading url from .env
HamzaAnis 3b3bd94
test: remove unwanted test
HamzaAnis 8b9ebd7
Fixed formatting issues
HamzaAnis e8f4812
Fixed formatting issues for backend
HamzaAnis 03121b8
Fixed formatting issues for test_mentor_auth.py
HamzaAnis ca21201
Merge branch 'dev' into tests/structure
HamzaAnis b37ef8d
tests: added more backend and frontend test
HamzaAnis add73c0
Merge branch 'dev' into tests/structure
HamzaAnis 971797a
tests: added more tests and github actions for the tests
HamzaAnis c769d02
Merge branch 'dev' into tests/structure
HamzaAnis e999b1d
test cases done 👏
HamzaAnis c2331e0
chore: fixed formatting of backend
HamzaAnis cc52192
Updated the action to be trigerred on PR for dev
HamzaAnis 8ef6ab7
test: added admin tests
HamzaAnis 818d2a0
Merge branch 'dev' into tests/structure
HamzaAnis e04e5a6
Added test cases for the admin
HamzaAnis 10788d8
Update cypress-tests.yml
HamzaAnis c342877
Update pytest-tests.yml
HamzaAnis c4ccbc0
Update pytest-tests.yml
HamzaAnis 376ce5b
frontend action change
HamzaAnis dc2c4de
testing action
HamzaAnis 25a6a08
fixed test cases and updated push branch
HamzaAnis 10b845e
Debugging the actions
HamzaAnis d36d760
Running backend tests in the same action
HamzaAnis 69fac33
Removed on push
HamzaAnis 964395e
Updating actions
HamzaAnis f1fec7e
New action
HamzaAnis b0dbf61
Removed files that are in .gitignore
HamzaAnis 2d576ee
Adding package.json
HamzaAnis 76fa0d3
Reading the env variables
HamzaAnis 13a08ef
Reordering the action
HamzaAnis 868d822
Cleaning up and formatting
HamzaAnis 52cbe0d
Asserting response
HamzaAnis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
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 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
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: 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" |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
* | ||
!api | ||
!manage.py | ||
!requirements.txt | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ LABEL maintainer "Kelley Chau <[email protected]>" | |
|
||
COPY requirements.txt requirements.txt | ||
RUN apt-get update -y && \ | ||
apt-get install -y python-pip python-dev | ||
apt-get install -y python3-dev python3-pkg-resources python3-setuptools python3-wheel python3-pip | ||
|
||
RUN pip install -r requirements.txt | ||
|
||
|
@@ -13,4 +13,5 @@ WORKDIR /app | |
|
||
ENTRYPOINT [ "python" ] | ||
|
||
CMD [ "manage.py", "runprod" ] | ||
CMD [ "manage.py", "runserver" ] | ||
# CMD [ "manage.py", "runprod" ] |
Binary file not shown.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @HamzaAnis please remove this file There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is removed in this PR. It was present on the other branches. |
Binary file not shown.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@HamzaAnis please remove this file