|
| 1 | +# This workflow will install Python dependencies, run tests and lint with a single version of Python |
| 2 | +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python |
| 3 | + |
| 4 | +name: Backend CI |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: [ "develop", "main" ] |
| 9 | + pull_request: |
| 10 | + branches: [ "develop" ] |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: read |
| 14 | + |
| 15 | +jobs: |
| 16 | + lint: |
| 17 | + name: Lint Python Code (PEP8) |
| 18 | + runs-on: ubuntu-latest |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Checkout repository |
| 22 | + uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - name: Set up Python |
| 25 | + uses: actions/setup-python@v4 |
| 26 | + with: |
| 27 | + python-version: "3.10" |
| 28 | + |
| 29 | + - name: Install dependencies |
| 30 | + run: | |
| 31 | + cd server |
| 32 | + python -m pip install --upgrade pip |
| 33 | + pip install flake8 black |
| 34 | + - name: Run flake8 (Linting) |
| 35 | + run: | |
| 36 | + cd server |
| 37 | + flake8 src/ tests/ |
| 38 | + - name: Run Black (Formatting Check) |
| 39 | + run: | |
| 40 | + cd server |
| 41 | + black --check --diff src/ tests/ |
| 42 | + test: |
| 43 | + name: Run Backend Tests |
| 44 | + runs-on: ubuntu-latest |
| 45 | + needs: lint # Ensures linting passes before running tests |
| 46 | + |
| 47 | + steps: |
| 48 | + - name: Checkout repository |
| 49 | + uses: actions/checkout@v3 |
| 50 | + |
| 51 | + - name: Set up Python |
| 52 | + uses: actions/setup-python@v4 |
| 53 | + with: |
| 54 | + python-version: "3.10" |
| 55 | + |
| 56 | + - name: Install dependencies |
| 57 | + run: | |
| 58 | + cd server |
| 59 | + python -m pip install --upgrade pip |
| 60 | + pip install -r requirements.txt |
| 61 | + |
| 62 | + - name: Create .env file in CI |
| 63 | + run: | |
| 64 | + cd server |
| 65 | + touch .env |
| 66 | + echo "SUPABASE_URL=${{ secrets.SUPABASE_URL }}" >> .env |
| 67 | + echo "SUPABASE_URL=${{ secrets.SUPABASE_KEY }}" >> .env |
| 68 | + echo "GOOGLE_MAPS_API_KEY=${{ secrets.GOOGLE_MAPS_API_KEY }}" >> .env |
| 69 | + |
| 70 | + - name: Run Tests |
| 71 | + run: | |
| 72 | + cd server |
| 73 | + pytest tests/ --ignore=tests/test_database_connection.py |
0 commit comments