|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + - '[0-9].[0-9]+' # matches to backport branches, e.g. 3.6 |
| 8 | + tags: [ 'v*' ] |
| 9 | + pull_request: |
| 10 | + branches: |
| 11 | + - master |
| 12 | + - '[0-9].[0-9]+' |
| 13 | + - 'update/pre-commit-autoupdate' |
| 14 | + schedule: |
| 15 | + - cron: '0 6 * * *' # Daily 6AM UTC build |
| 16 | + |
| 17 | + |
| 18 | +jobs: |
| 19 | + |
| 20 | + lint: |
| 21 | + name: Linter |
| 22 | + runs-on: ubuntu-latest |
| 23 | + timeout-minutes: 5 |
| 24 | + steps: |
| 25 | + - name: Checkout |
| 26 | + |
| 27 | + - name: Setup Python 3.9 |
| 28 | + uses: actions/setup-python@v2 |
| 29 | + with: |
| 30 | + python-version: 3.9 |
| 31 | + #---------------------------------------------- |
| 32 | + # ----- install & configure poetry ----- |
| 33 | + #---------------------------------------------- |
| 34 | + - name: Install Poetry |
| 35 | + uses: snok/install-poetry@v1 |
| 36 | + with: |
| 37 | + virtualenvs-create: true |
| 38 | + virtualenvs-in-project: true |
| 39 | + installer-parallel: true |
| 40 | + #---------------------------------------------- |
| 41 | + # load cached venv if cache exists |
| 42 | + #---------------------------------------------- |
| 43 | + - name: Load cached venv |
| 44 | + id: cached-poetry-dependencies |
| 45 | + uses: actions/cache@v2 |
| 46 | + with: |
| 47 | + path: .venv |
| 48 | + key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} |
| 49 | + #---------------------------------------------- |
| 50 | + # install dependencies if cache does not exist |
| 51 | + #---------------------------------------------- |
| 52 | + - name: Install dependencies |
| 53 | + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' |
| 54 | + run: poetry install --no-interaction --no-root |
| 55 | + #---------------------------------------------- |
| 56 | + # install your root project, if required |
| 57 | + #---------------------------------------------- |
| 58 | + - name: Install library |
| 59 | + run: poetry install --no-interaction |
| 60 | + #---------------------------------------------- |
| 61 | + # run test suite |
| 62 | + #---------------------------------------------- |
| 63 | + - name: Run linter |
| 64 | + run: | |
| 65 | + make lint |
| 66 | +# - name: Prepare twine checker |
| 67 | +# run: | |
| 68 | +# pip install -U twine wheel |
| 69 | +# python setup.py sdist bdist_wheel |
| 70 | +# - name: Run twine checker |
| 71 | +# run: | |
| 72 | +# twine check dist/* |
| 73 | + |
| 74 | + test-unix: |
| 75 | + name: Test Unix |
| 76 | + needs: lint |
| 77 | + strategy: |
| 78 | + matrix: |
| 79 | + os: [ubuntu-latest] |
| 80 | + pyver: [3.6, 3.7, 3.8, 3.9, pypy3] |
| 81 | + redismod: ["edge", "preview", "latest"] |
| 82 | + fail-fast: false |
| 83 | + services: |
| 84 | + redis: |
| 85 | + image: redislabs/redismod:{{ matrix.redismod }} |
| 86 | + ports: |
| 87 | + # Maps port 6379 on service container to the host |
| 88 | + - 6379:6379 |
| 89 | + # Set health checks to wait until redis has started |
| 90 | + options: >- |
| 91 | + --health-cmd "redis-cli ping" |
| 92 | + --health-interval 10s |
| 93 | + --health-timeout 5s |
| 94 | + --health-retries 5 |
| 95 | + --load-module "/usr/lib/redis/modules/redisearch.so" |
| 96 | + --load-module "/usr/lib/redis/modules/rejson.so" |
| 97 | + runs-on: ${{ matrix.os }} |
| 98 | + timeout-minutes: 15 |
| 99 | + env: |
| 100 | + OS: ${{ matrix.os }} |
| 101 | + INSTALL_DIR: ${{ github.workspace }}/redis |
| 102 | + steps: |
| 103 | + - name: Checkout |
| 104 | + |
| 105 | + - name: Setup Python ${{ matrix.pyver }} |
| 106 | + uses: actions/setup-python@v2 |
| 107 | + with: |
| 108 | + python-version: ${{ matrix.pyver }} |
| 109 | + #---------------------------------------------- |
| 110 | + # ----- install & configure poetry ----- |
| 111 | + #---------------------------------------------- |
| 112 | + - name: Install Poetry |
| 113 | + uses: snok/install-poetry@v1 |
| 114 | + with: |
| 115 | + virtualenvs-create: true |
| 116 | + virtualenvs-in-project: true |
| 117 | + installer-parallel: true |
| 118 | + #---------------------------------------------- |
| 119 | + # load cached venv if cache exists |
| 120 | + #---------------------------------------------- |
| 121 | + - name: Load cached venv |
| 122 | + id: cached-poetry-dependencies |
| 123 | + uses: actions/cache@v2 |
| 124 | + with: |
| 125 | + path: .venv |
| 126 | + key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} |
| 127 | + #---------------------------------------------- |
| 128 | + # install dependencies if cache does not exist |
| 129 | + #---------------------------------------------- |
| 130 | + - name: Install dependencies |
| 131 | + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' |
| 132 | + run: poetry install --no-interaction --no-root |
| 133 | + #---------------------------------------------- |
| 134 | + # install your root project, if required |
| 135 | + #---------------------------------------------- |
| 136 | + - name: Install library |
| 137 | + run: poetry install --no-interaction |
| 138 | + - name: Run unittests (redismod:${{ matrix.redismod }}, ${{ matrix.os }}) |
| 139 | + run: | |
| 140 | + make test |
| 141 | + poetry run coverage xml |
| 142 | + - name: Upload coverage |
| 143 | + |
| 144 | + with: |
| 145 | + file: ./coverage.xml |
| 146 | + flags: unit |
| 147 | + env_vars: OS |
| 148 | + fail_ci_if_error: false |
| 149 | + |
| 150 | + deploy: |
| 151 | + name: Deploy |
| 152 | + runs-on: ubuntu-latest |
| 153 | + needs: test-unix |
| 154 | + # Run only on pushing a tag |
| 155 | + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') |
| 156 | + steps: |
| 157 | + - name: Checkout |
| 158 | + |
| 159 | + - name: Setup Python 3.9 |
| 160 | + uses: actions/setup-python@v2 |
| 161 | + with: |
| 162 | + python-version: 3.9 |
| 163 | + - name: Install dependencies |
| 164 | + run: |
| 165 | + python -m pip install -U pip wheel twine |
| 166 | + - name: Make dists |
| 167 | + run: |
| 168 | + python setup.py sdist bdist_wheel |
| 169 | + - name: PyPI upload |
| 170 | + env: |
| 171 | + TWINE_USERNAME: __token__ |
| 172 | + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} |
| 173 | + run: | |
| 174 | + twine upload dist/* |
0 commit comments