|
| 1 | +--- |
| 2 | +name: CI |
| 3 | +on: |
| 4 | + - push |
| 5 | + - pull_request |
| 6 | +jobs: |
| 7 | + lint: |
| 8 | + name: Run linters |
| 9 | + runs-on: ubuntu-latest |
| 10 | + steps: |
| 11 | + - name: Checkout source code |
| 12 | + uses: actions/checkout@v2 |
| 13 | + - name: Set up Python 3.9 |
| 14 | + uses: actions/setup-python@v2 |
| 15 | + with: |
| 16 | + python-version: 3.9 |
| 17 | + - name: Install dependencies |
| 18 | + run: python -m pip install tox |
| 19 | + - name: Run tox |
| 20 | + run: tox -e pep8 |
| 21 | + test: |
| 22 | + name: Run unit tests |
| 23 | + runs-on: ubuntu-latest |
| 24 | + strategy: |
| 25 | + matrix: |
| 26 | + python: [3.6, 3.7, 3.8, 3.9] |
| 27 | + db: [postgres, mysql] |
| 28 | + services: |
| 29 | + postgres: |
| 30 | + image: postgres:latest |
| 31 | + env: |
| 32 | + POSTGRES_DB: patchwork |
| 33 | + POSTGRES_PASSWORD: patchwork |
| 34 | + POSTGRES_USER: patchwork |
| 35 | + ports: |
| 36 | + - 5432:5432 |
| 37 | + options: >- |
| 38 | + --health-cmd pg_isready |
| 39 | + --health-interval 10s |
| 40 | + --health-timeout 5s |
| 41 | + --health-retries 5 |
| 42 | + mysql: |
| 43 | + image: mysql:latest |
| 44 | + env: |
| 45 | + MYSQL_DATABASE: patchwork |
| 46 | + MYSQL_USER: patchwork |
| 47 | + MYSQL_PASSWORD: patchwork |
| 48 | + MYSQL_ROOT_PASSWORD: root |
| 49 | + ports: |
| 50 | + - 3306:3306 |
| 51 | + options: >- |
| 52 | + --health-cmd="mysqladmin ping" |
| 53 | + --health-interval 10s |
| 54 | + --health-timeout 5s |
| 55 | + --health-retries 5 |
| 56 | + steps: |
| 57 | + - name: Checkout source code |
| 58 | + uses: actions/checkout@v2 |
| 59 | + - name: Set up Python ${{ matrix.python }} |
| 60 | + uses: actions/setup-python@v2 |
| 61 | + with: |
| 62 | + python-version: ${{ matrix.python }} |
| 63 | + - name: Install Python dependencies |
| 64 | + run: python -m pip install tox tox-gh-actions codecov |
| 65 | + - name: Log database configuration (mysql) |
| 66 | + if: ${{ matrix.db == 'mysql' }} |
| 67 | + run: mysql -h 127.0.0.1 -e "SELECT VERSION(), CURRENT_USER();" -uroot -proot patchwork |
| 68 | + - name: Log database configuration (postgres) |
| 69 | + if: ${{ matrix.db == 'postgres' }} |
| 70 | + run: psql -h 127.0.0.1 -c "SELECT VERSION(), CURRENT_USER, current_database()" -U patchwork -d patchwork |
| 71 | + env: |
| 72 | + PGPASSWORD: patchwork |
| 73 | + - name: Modify database user permissions (mysql) |
| 74 | + if: ${{ matrix.db == 'mysql' }} |
| 75 | + run: mysql -h 127.0.0.1 -e "GRANT ALL ON \`test\\_patchwork%\`.* to 'patchwork'@'%';" -uroot -proot |
| 76 | + - name: Run unit tests (via tox) |
| 77 | + run: tox |
| 78 | + env: |
| 79 | + PW_TEST_DB_TYPE: "${{ matrix.db }}" |
| 80 | + PW_TEST_DB_USER: "patchwork" |
| 81 | + PW_TEST_DB_PASS: "patchwork" |
| 82 | + PW_TEST_DB_HOST: "127.0.0.1" |
| 83 | + docs: |
| 84 | + name: Build docs |
| 85 | + runs-on: ubuntu-latest |
| 86 | + steps: |
| 87 | + - name: Checkout source code |
| 88 | + uses: actions/checkout@v2 |
| 89 | + with: |
| 90 | + fetch-depth: 0 |
| 91 | + - name: Set up Python 3.9 |
| 92 | + uses: actions/setup-python@v2 |
| 93 | + with: |
| 94 | + python-version: 3.9 |
| 95 | + - name: Install dependencies |
| 96 | + run: python -m pip install tox |
| 97 | + - name: Build docs (via tox) |
| 98 | + run: tox -e docs |
| 99 | + - name: Archive build results |
| 100 | + uses: actions/upload-artifact@v2 |
| 101 | + with: |
| 102 | + name: html-docs-build |
| 103 | + path: docs/_build/html |
| 104 | + retention-days: 7 |
0 commit comments