|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: [push, pull_request] |
| 4 | + |
| 5 | +jobs: |
| 6 | + test: |
| 7 | + runs-on: ubuntu-latest |
| 8 | + |
| 9 | + services: |
| 10 | + postgres: |
| 11 | + image: postgres:alpine |
| 12 | + ports: |
| 13 | + - 5432:5432 |
| 14 | + env: |
| 15 | + POSTGRES_USER: fastapiusers |
| 16 | + POSTGRES_PASSWORD: fastapiuserspassword |
| 17 | + # Set health checks to wait until postgres has started |
| 18 | + options: >- |
| 19 | + --health-cmd pg_isready |
| 20 | + --health-interval 10s |
| 21 | + --health-timeout 5s |
| 22 | + --health-retries 5 |
| 23 | +
|
| 24 | + mariadb: |
| 25 | + image: mariadb |
| 26 | + ports: |
| 27 | + - 3306:3306 |
| 28 | + env: |
| 29 | + MARIADB_ROOT_PASSWORD: fastapiuserspassword |
| 30 | + MARIADB_DATABASE: fastapiusers |
| 31 | + MARIADB_USER: fastapiusers |
| 32 | + MARIADB_PASSWORD: fastapiuserspassword |
| 33 | + |
| 34 | + strategy: |
| 35 | + fail-fast: false |
| 36 | + matrix: |
| 37 | + python_version: [3.9, '3.10', '3.11', '3.12', '3.13'] |
| 38 | + database_url: |
| 39 | + [ |
| 40 | + "sqlite+aiosqlite:///./test-fastapiusers.db", |
| 41 | + "postgresql+asyncpg://fastapiusers:fastapiuserspassword@localhost:5432/fastapiusers", |
| 42 | + "mysql+aiomysql://root:fastapiuserspassword@localhost:3306/fastapiusers", |
| 43 | + ] |
| 44 | + |
| 45 | + steps: |
| 46 | + - uses: actions/checkout@v4 |
| 47 | + - name: Set up Python |
| 48 | + uses: actions/setup-python@v5 |
| 49 | + with: |
| 50 | + python-version: ${{ matrix.python_version }} |
| 51 | + - name: Install dependencies |
| 52 | + run: | |
| 53 | + python -m pip install --upgrade pip |
| 54 | + pip install hatch |
| 55 | + hatch env create |
| 56 | + - name: Lint and typecheck |
| 57 | + run: | |
| 58 | + hatch run lint-check |
| 59 | + - name: Test |
| 60 | + env: |
| 61 | + DATABASE_URL: ${{ matrix.database_url }} |
| 62 | + run: | |
| 63 | + hatch run test-cov-xml |
| 64 | + - uses: codecov/codecov-action@v5 |
| 65 | + with: |
| 66 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 67 | + fail_ci_if_error: true |
| 68 | + verbose: true |
| 69 | + - name: Build and install it on system host |
| 70 | + run: | |
| 71 | + hatch build |
| 72 | + pip install dist/fastapi_users_db_sqlalchemy-*.whl |
| 73 | + python test_build.py |
| 74 | +
|
| 75 | + release: |
| 76 | + runs-on: ubuntu-latest |
| 77 | + needs: test |
| 78 | + if: startsWith(github.ref, 'refs/tags/') |
| 79 | + |
| 80 | + steps: |
| 81 | + - uses: actions/checkout@v4 |
| 82 | + - name: Set up Python |
| 83 | + uses: actions/setup-python@v5 |
| 84 | + with: |
| 85 | + python-version: 3.9 |
| 86 | + - name: Install dependencies |
| 87 | + run: | |
| 88 | + python -m pip install --upgrade pip |
| 89 | + pip install hatch |
| 90 | + - name: Build and publish on PyPI |
| 91 | + env: |
| 92 | + HATCH_INDEX_USER: ${{ secrets.HATCH_INDEX_USER }} |
| 93 | + HATCH_INDEX_AUTH: ${{ secrets.HATCH_INDEX_AUTH }} |
| 94 | + run: | |
| 95 | + hatch build |
| 96 | + hatch publish |
| 97 | + - name: Create release |
| 98 | + uses: ncipollo/release-action@v1 |
| 99 | + with: |
| 100 | + draft: true |
| 101 | + body: ${{ github.event.head_commit.message }} |
| 102 | + artifacts: dist/*.whl,dist/*.tar.gz |
| 103 | + token: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments