fix: ensure database cleanup by dropping all tables after tests #14
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: Test, Build, and Push Docker Image to GHCR | |
on: | |
push: | |
branches: | |
- main | |
env: | |
REGISTRY: ghcr.io | |
REPOSITORY: ${{ github.repository }} | |
TAG: latest | |
jobs: | |
test-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
pip install pytest | |
- name: Run unit tests | |
run: | | |
pytest --maxfail=1 --disable-warnings || exit 1 | |
- name: Log in to GitHub Container Registry | |
if: success() | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ secrets.SCX_GITHUB_USERNAME }} | |
password: ${{ secrets.SCX_GITHUB_TOKEN }} | |
- name: Build and push Docker image | |
if: success() # Run this step only if tests pass | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
push: true | |
tags: | | |
ghcr.io/scholarx-assesment/class-schedule-service:latest |