refacotr: update readme.md #2
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: CI | |
| on: | |
| push: | |
| branches: [main, master, develop] | |
| pull_request: | |
| branches: [main, master, develop] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| services: | |
| mongodb: | |
| image: mongo:7 | |
| ports: | |
| - 27017:27017 | |
| options: >- | |
| --health-cmd "mongosh --eval 'db.adminCommand(\"ping\")'" | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.9" | |
| - name: Cache pip packages | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip- | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Set up environment variables | |
| run: | | |
| echo "MONGO_HOST=localhost" >> $GITHUB_ENV | |
| echo "MONGO_PORT=27017" >> $GITHUB_ENV | |
| echo "MONGO_DB=test_db" >> $GITHUB_ENV | |
| echo "MONGO_USER=" >> $GITHUB_ENV | |
| echo "MONGO_PASSWORD=" >> $GITHUB_ENV | |
| echo "MONGO_AUTH_DB=admin" >> $GITHUB_ENV | |
| echo "JWT_SECRET=test_secret_key_for_ci" >> $GITHUB_ENV | |
| echo "MONGO_URI=mongodb://localhost:27017" >> $GITHUB_ENV | |
| - name: Run tests | |
| run: | | |
| pytest tests/ -v --tb=short | |
| - name: Generate coverage report | |
| run: | | |
| pip install pytest-cov | |
| pytest tests/ --cov=app --cov-report=xml --cov-report=html --cov-report=term | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v3 | |
| with: | |
| file: ./coverage.xml | |
| flags: unittests | |
| name: codecov-umbrella | |
| fail_ci_if_error: false |