ctf #2781
Workflow file for this run
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: Unit Tests | |
on: | |
pull_request: | |
branches: [dev, main] | |
jobs: | |
event_file: | |
name: Event File | |
runs-on: ubuntu-latest | |
steps: | |
- name: Upload | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Event File | |
path: ${{ github.event_path }} | |
backend: | |
name: Backend CI Testing | |
runs-on: ubuntu-latest | |
permissions: | |
checks: write | |
pull-requests: write | |
steps: | |
- name: Checking out repository | |
uses: actions/checkout@v3 | |
- name: Set up Python (latest) | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10.5" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r backend/requirements.txt | |
- name: Set up docker compose | |
run: | | |
mkdir env | |
echo "MONGODB_USERNAME=github-ci" >> env/backend.env | |
echo "MONGODB_PASSWORD=github-ci" >> env/backend.env | |
echo "MONGODB_SERVICE_HOSTNAME=mongodb" >> env/backend.env | |
echo "MONGO_INITDB_ROOT_USERNAME=github-ci" >> env/mongodb.env | |
echo "MONGO_INITDB_ROOT_PASSWORD=github-ci" >> env/mongodb.env | |
echo "VITE_BACKEND_API_BASE_URL=http://localhost:8000/" >> env/frontend.env | |
docker compose run ci-backend | |
- name: Run mypy checks | |
run: cd backend && python -m mypy . && cd .. | |
- name: Test algorithm with pytest | |
run: | | |
cd backend | |
pip install pytest-cov | |
python -m pytest --junitxml=junit/be-test-results.xml --cov=. --cov-report=xml --cov-report=html | |
- uses: actions/upload-artifact@v3 # upload test results | |
if: always() | |
with: | |
name: be-test-results | |
path: backend/junit/be-test-results.xml # Path to test results | |
frontend: | |
name: Frontend CI Testing | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checking out repository | |
uses: actions/checkout@v3 | |
- name: Set up Python (latest) | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.x" | |
- name: Run frontend tests | |
run: | | |
cd frontend | |
npm ci | |
npm run test | |
- uses: actions/upload-artifact@v3 | |
if: always() | |
with: | |
name: fe-test-results | |
path: frontend/junit/fe-test-results.xml | |
- name: Test the frontend successfully builds | |
run: | | |
mkdir env | |
echo "MONGODB_USERNAME=github-ci" >> env/backend.env | |
echo "MONGODB_PASSWORD=github-ci" >> env/backend.env | |
echo "MONGODB_SERVICE_HOSTNAME=mongodb" >> env/backend.env | |
echo "MONGO_INITDB_ROOT_USERNAME=github-ci" >> env/mongodb.env | |
echo "MONGO_INITDB_ROOT_PASSWORD=github-ci" >> env/mongodb.env | |
echo "VITE_BACKEND_API_BASE_URL=http://localhost:8000/" >> env/frontend.env | |
docker compose up -d frontend-prod |