|
| 1 | +name: tests |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: [master] |
| 5 | + pull_request: |
| 6 | + branches: [master] |
| 7 | +jobs: |
| 8 | + tests: |
| 9 | + runs-on: ${{ matrix.os }} |
| 10 | + strategy: |
| 11 | + fail-fast: false |
| 12 | + matrix: |
| 13 | + python-version: ["3.9", "3.10", "3.11", "3.12"] |
| 14 | + os: [ubuntu-latest, macOS-latest, windows-latest] |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: Checkout |
| 18 | + uses: actions/checkout@v2 |
| 19 | + |
| 20 | + - name: Set up Python ${{ matrix.python-version }} |
| 21 | + uses: actions/setup-python@v2 |
| 22 | + with: |
| 23 | + python-version: ${{ matrix.python-version }} |
| 24 | + |
| 25 | + - name: Set up PostgreSQL on Linux |
| 26 | + if: startsWith(runner.os, 'linux') |
| 27 | + run: | |
| 28 | + sudo systemctl start postgresql.service |
| 29 | + pg_isready |
| 30 | + sudo -u postgres psql --command="ALTER USER postgres WITH PASSWORD '123456'" --command="\du" |
| 31 | +
|
| 32 | + - name: Setup PostgreSQL on macOS |
| 33 | + if: startsWith(runner.os, 'macos') |
| 34 | + run: | |
| 35 | + brew services start postgresql |
| 36 | + echo "Check PostgreSQL service is running" |
| 37 | + i=10 |
| 38 | + COMMAND='pg_isready' |
| 39 | + while [ $i -gt 0 ]; do |
| 40 | + echo "Check PostgreSQL service status" |
| 41 | + eval $COMMAND && break |
| 42 | + ((i--)) |
| 43 | + if [ $i == 0 ]; then |
| 44 | + echo "PostgreSQL service not ready, all attempts exhausted" |
| 45 | + exit 1 |
| 46 | + fi |
| 47 | + echo "PostgreSQL service not ready, wait 10 more sec, attempts left: $i" |
| 48 | + sleep 10 |
| 49 | + done |
| 50 | + psql --command="CREATE USER postgres PASSWORD '123456'" --command="\du" postgres |
| 51 | +
|
| 52 | + - name: Start PostgreSQL on Windows |
| 53 | + if: startsWith(runner.os, 'windows') |
| 54 | + run: | |
| 55 | + $pgService = Get-Service -Name postgresql* |
| 56 | + Set-Service -InputObject $pgService -Status running -StartupType automatic |
| 57 | + Start-Process -FilePath "$env:PGBIN\pg_isready" -Wait -PassThru |
| 58 | + & $env:PGBIN\psql --command="ALTER USER postgres WITH PASSWORD '123456'" --command="\du" |
| 59 | +
|
| 60 | + - name: Upgrade install tools |
| 61 | + run: python -m pip install --upgrade setuptools wheel |
| 62 | + |
| 63 | + - name: Install dependencies |
| 64 | + run: | |
| 65 | + pip install -r requirements.txt |
| 66 | +
|
| 67 | + - name: Run tests |
| 68 | + run: | |
| 69 | + python -m unittest discover -s tests -t tests |
| 70 | +
|
| 71 | + coveralls: |
| 72 | + runs-on: ubuntu-latest |
| 73 | + steps: |
| 74 | + - name: Checkout |
| 75 | + uses: actions/checkout@v2 |
| 76 | + |
| 77 | + - name: Set up Python |
| 78 | + uses: actions/setup-python@v2 |
| 79 | + with: |
| 80 | + python-version: 3.9 |
| 81 | + |
| 82 | + - name: Install dependencies |
| 83 | + run: | |
| 84 | + pip install -r requirements.txt |
| 85 | + pip install coveralls |
| 86 | + pip install coverage |
| 87 | +
|
| 88 | + - name: Set up PostgreSQL on Linux |
| 89 | + if: startsWith(runner.os, 'linux') |
| 90 | + run: | |
| 91 | + sudo systemctl start postgresql.service |
| 92 | + pg_isready |
| 93 | + sudo -u postgres psql --command="ALTER USER postgres WITH PASSWORD '123456'" --command="\du" |
| 94 | +
|
| 95 | + - name: Run tests |
| 96 | + run: coverage run -m unittest discover -s tests -t tests |
| 97 | + |
| 98 | + - name: Upload coverage data to coveralls.io |
| 99 | + run: coveralls --service=github |
| 100 | + env: |
| 101 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 102 | + |
| 103 | + release: |
| 104 | + name: Release |
| 105 | + runs-on: ubuntu-latest |
| 106 | + needs: [ tests, coveralls ] |
| 107 | + steps: |
| 108 | + - name: Checkout |
| 109 | + uses: actions/checkout@v2 |
| 110 | + with: |
| 111 | + fetch-depth: 0 |
| 112 | + |
| 113 | + - name: Setup Node.js |
| 114 | + uses: actions/setup-node@v1 |
| 115 | + with: |
| 116 | + node-version: '20' |
| 117 | + |
| 118 | + - name: Setup |
| 119 | + run: npm install -g semantic-release @semantic-release/github @semantic-release/changelog @semantic-release/commit-analyzer @semantic-release/git @semantic-release/release-notes-generator semantic-release-pypi |
| 120 | + |
| 121 | + - name: Set up python |
| 122 | + uses: actions/setup-python@v2 |
| 123 | + with: |
| 124 | + python-version: 3.9 |
| 125 | + |
| 126 | + - name: Install setuptools |
| 127 | + run: python -m pip install --upgrade setuptools wheel twine |
| 128 | + |
| 129 | + - name: Release |
| 130 | + env: |
| 131 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 132 | + PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} |
| 133 | + run: npx semantic-release |
0 commit comments