Merge pull request #34 from mongodb/python-readme #20
This file contains hidden or 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: Run Python Tests | |
| on: | |
| pull_request_target: | |
| branches: | |
| - development | |
| paths: | |
| - 'mflix/server/python-fastapi/**' | |
| push: | |
| branches: | |
| - development | |
| paths: | |
| - 'mflix/server/python-fastapi/**' | |
| jobs: | |
| test: | |
| name: Run Python Tests | |
| runs-on: ubuntu-latest | |
| # Require manual approval for fork PRs | |
| environment: testing | |
| defaults: | |
| run: | |
| working-directory: mflix/server/python-fastapi | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.13' | |
| cache: 'pip' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Run unit tests | |
| run: pytest -m unit --verbose --tb=short --junit-xml=test-results-unit.xml | |
| env: | |
| MONGO_URI: ${{ secrets.MFLIX_URI }} | |
| MONGO_DB: sample_mflix | |
| - name: Run integration tests | |
| run: pytest -m integration --verbose --tb=short --junit-xml=test-results-integration.xml || true | |
| env: | |
| MONGO_URI: ${{ secrets.MFLIX_URI }} | |
| MONGO_DB: sample_mflix | |
| - name: Upload test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: test-results | |
| path: | | |
| mflix/server/python-fastapi/test-results-unit.xml | |
| mflix/server/python-fastapi/test-results-integration.xml | |
| mflix/server/python-fastapi/htmlcov/ | |
| retention-days: 30 | |
| - name: Generate Test Summary | |
| if: always() | |
| working-directory: . | |
| run: | | |
| chmod +x .github/scripts/generate-test-summary-pytest.sh | |
| .github/scripts/generate-test-summary-pytest.sh \ | |
| mflix/server/python-fastapi/test-results-unit.xml \ | |
| mflix/server/python-fastapi/test-results-integration.xml |