|
| 1 | +name: Python package |
| 2 | + |
| 3 | +on: [push] |
| 4 | + |
| 5 | +jobs: |
| 6 | + postgres: |
| 7 | + runs-on: ubuntu-latest |
| 8 | + strategy: |
| 9 | + matrix: |
| 10 | + python-version: [3.7, 3.8, 3.9] |
| 11 | + postgres-version: [9.6, 10, 11, 12, 13] |
| 12 | + |
| 13 | + # Service containers to run with `container-job` |
| 14 | + services: |
| 15 | + # Label used to access the service container |
| 16 | + postgres: |
| 17 | + # Docker Hub image |
| 18 | + image: postgres:${{ matrix.postgres-version }} |
| 19 | + # Provide the password for postgres |
| 20 | + env: |
| 21 | + POSTGRES_PASSWORD: postgres |
| 22 | + # Set health checks to wait until postgres has started |
| 23 | + options: >- |
| 24 | + --health-cmd pg_isready |
| 25 | + --health-interval 10s |
| 26 | + --health-timeout 5s |
| 27 | + --health-retries 5 |
| 28 | + ports: |
| 29 | + - 5432:5432 |
| 30 | + |
| 31 | + steps: |
| 32 | + - uses: actions/checkout@v2 |
| 33 | + - name: Set up Python ${{ matrix.python-version }} |
| 34 | + uses: actions/setup-python@v2 |
| 35 | + with: |
| 36 | + python-version: ${{ matrix.python-version }} |
| 37 | + - name: Install dependencies |
| 38 | + run: | |
| 39 | + python -m pip install --upgrade pip |
| 40 | + pip install -r requirements.txt |
| 41 | + pip install -r tests/test-requirements.txt |
| 42 | + - name: Setup postgres |
| 43 | + run: | |
| 44 | + export PGPASSWORD=postgres |
| 45 | + psql -h localhost -c 'CREATE DATABASE piccolo;' -U postgres |
| 46 | + psql -h localhost -c "CREATE USER piccolo PASSWORD 'piccolo';" -U postgres |
| 47 | + psql -h localhost -c "GRANT ALL PRIVILEGES ON DATABASE piccolo TO piccolo;" -U postgres |
| 48 | + psql -h localhost -c "CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";" -d piccolo -U postgres |
| 49 | +
|
| 50 | + - name: Test with pytest, Postgres |
| 51 | + run: cd tests && ./test-postgres.sh |
| 52 | + env: |
| 53 | + PG_HOST: localhost |
| 54 | + PG_DATABASE: piccolo |
| 55 | + PG_PASSWORD: postgres |
| 56 | + |
| 57 | + sqlite: |
| 58 | + runs-on: ubuntu-latest |
| 59 | + strategy: |
| 60 | + matrix: |
| 61 | + python-version: [3.7, 3.8, 3.9] |
| 62 | + |
| 63 | + steps: |
| 64 | + - uses: actions/checkout@v2 |
| 65 | + - name: Set up Python ${{ matrix.python-version }} |
| 66 | + uses: actions/setup-python@v2 |
| 67 | + with: |
| 68 | + python-version: ${{ matrix.python-version }} |
| 69 | + - name: Install dependencies |
| 70 | + run: | |
| 71 | + python -m pip install --upgrade pip |
| 72 | + pip install -r requirements.txt |
| 73 | + pip install -r tests/test-requirements.txt |
| 74 | + - name: Test with pytest, SQLite |
| 75 | + run: cd tests && ./test-sqlite.sh |
0 commit comments