File: tests.yml

package info (click to toggle)
php-nrk-predis 2.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,068 kB
  • sloc: php: 59,586; xml: 42; makefile: 5
file content (183 lines) | stat: -rw-r--r-- 6,466 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
name: Tests

on:
  push:
    branches:
      - main
      - v2.**
  pull_request:

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:

  predis:
    name: PHP ${{ matrix.php }} (Redis ${{ matrix.redis }})
    runs-on: ubuntu-latest

    strategy:
      fail-fast: false
      matrix:
        php:
          - '7.2'
          - '8.0'
          - '8.3'
          - '8.4'
        redis:
          - '4.0'
          - '6.2'
          - '7.2'
          - '7.4'
          - '8.0'

    steps:

      - name: Resolve container name
        run: |
          # Mapping of original redis versions to client test containers
          declare -A redis_clients_version_mapping=(
            ["8.0"]="8.0-RC2-pre"
            ["7.4"]="7.4.2"
            ["7.2"]="7.2.7"
            ["6.2"]="6.2.17"
          )

          # Mapping of redis version to stack version
          declare -A redis_stack_version_mapping=(
            ["7.4"]="rs-7.4.0-v3"
            ["7.2"]="rs-7.2.0-v15"
            ["6.2"]="rs-6.2.6-v19"
          )

          if [[ -v redis_clients_version_mapping[${{ matrix.redis }}] ]]; then
            echo "REDIS_IMAGE_NAME=redislabs/client-libs-test:${redis_clients_version_mapping[${{ matrix.redis }}]}" >> $GITHUB_ENV
            echo "REDIS_STACK_IMAGE_NAME=redislabs/client-libs-test:${redis_stack_version_mapping[${{ matrix.redis }}]}" >> $GITHUB_ENV
            echo "DOCKER_SERVICE=redis-clients" >> $GITHUB_ENV

            redis_major_version=$(echo "${{ matrix.redis }}" | grep -oP '^\d+')

            # Some configuration options available since Redis > 7
            if (( redis_major_version < 7 )); then
              echo "REDIS_EXTRA_ARGS="--tls-auth-clients optional --save ''"" >> $GITHUB_ENV
            else
              # Since 8.0 modules are bundled with core
              echo "REDIS_STACK_SERVER_PORT=6379" >> $GITHUB_ENV
            fi

          else
            echo "REDIS_IMAGE_NAME=redis:${{ matrix.redis }}" >> $GITHUB_ENV
            echo "DOCKER_SERVICE=redis-official" >> $GITHUB_ENV
          fi

      - name: Checkout repository
        uses: actions/checkout@v3

      - name: Start Redis standalone image
        uses: hoverkraft-tech/compose-action@v2.0.1
        with:
          compose-file: .github/docker-compose.yml
          services: ${{ env.DOCKER_SERVICE }}

      - name: Start Redis stack image
        id: stack_infra
        uses: hoverkraft-tech/compose-action@v2.0.1
        if: ${{ matrix.redis >= '6.2' && matrix.redis < '8.0' }}
        with:
          compose-file: .github/docker-compose.yml
          services: redis-stack

      - name: Start Redis cluster image
        id: cluster_infra
        uses: hoverkraft-tech/compose-action@v2.0.1
        if: ${{ matrix.redis > '4.0' }}
        with:
          compose-file: .github/docker-compose.yml
          services: redis-cluster

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php }}
          extensions: relay
          coverage: ${{ (matrix.php == '8.4' && matrix.redis == '7.4') && 'xdebug' || 'none' }}

      - name: Install Composer dependencies
        uses: ramsey/composer-install@v2
        with:
          dependency-versions: highest
          composer-options: ${{ matrix.php == '8.0' && '--ignore-platform-reqs' || '' }}

      - name: Run tests
        if: ${{ matrix.php != '8.4' || matrix.redis != '7.4' }}
        run: vendor/bin/phpunit

      - name: Run tests with coverage
        if: ${{ matrix.php == '8.4' && matrix.redis == '7.4' }}
        run: vendor/bin/phpunit --coverage-php build/cov/coverage-predis.cov --coverage-filter ./src

      - name: Run tests using Relay
        if: ${{ matrix.php != '8.4' && matrix.redis >= '6.2' }}
        run: vendor/bin/phpunit -c phpunit.relay.xml

      - name: Run tests using Relay with coverage
        if: ${{ matrix.php == '8.4' && matrix.redis == '7.4' }}
        run: vendor/bin/phpunit -c phpunit.relay.xml --coverage-php build/cov/coverage-relay.cov --coverage-filter ./src

      - name: Run stack tests
        if: ${{ (matrix.php != '8.4' || matrix.redis != '7.4') && matrix.redis >= '6.2' }}
        run: vendor/bin/phpunit --group realm-stack

      - name: Run stack tests with coverage
        if: ${{ matrix.php == '8.4' && matrix.redis == '7.4' && steps.stack_infra.conclusion == 'success' }}
        run: vendor/bin/phpunit --group realm-stack --coverage-php build/cov/coverage-stack.cov --coverage-filter ./src
        env:
          REDIS_STACK_SERVER_PORT: 6479

      - name: Run stack tests using Relay
        if: ${{ matrix.php != '8.4' && matrix.redis == '7.4' }}
        run: vendor/bin/phpunit --group realm-stack -c phpunit.relay.xml

      - name: Run stack tests using Relay with coverage
        if: ${{ matrix.php == '8.4' && matrix.redis == '7.4' }}
        run: vendor/bin/phpunit --group realm-stack -c phpunit.relay.xml --coverage-php build/cov/coverage-stack-relay.cov --coverage-filter ./src
        env:
          REDIS_STACK_SERVER_PORT: 6479

      - name: Run tests against cluster
        if: ${{ (matrix.php != '8.4' || matrix.redis != '7.4') && steps.cluster_infra.conclusion == 'success' }}
        run: |
          vendor/bin/phpunit --group cluster

      - name: Run tests against cluster with coverage
        if: ${{ matrix.php == '8.4' && matrix.redis == '7.4' && steps.cluster_infra.conclusion == 'success' }}
        run: |
          vendor/bin/phpunit --group cluster --coverage-php build/cov/coverage-cluster.cov --coverage-filter ./src

      - name: Run tests against cluster using Relay
        if: ${{ matrix.php != '8.4' && matrix.redis == '7.4' }}
        run: |
          vendor/bin/phpunit -c phpunit.relay.xml --group cluster

      - name: Merge coverage reports
        if: ${{ matrix.php == '8.4' && matrix.redis == '7.4' }}
        run: php vendor/bin/phpcov merge --clover build/logs/clover.xml build/cov

      - name: Send coverage to Coveralls
        uses: coverallsapp/github-action@v2
        if: ${{ matrix.php == '8.4' && matrix.redis == '7.4' }}
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          parallel: true

  finish:
    name: Finish Coverall
    needs: predis
    if: ${{ always() }}
    runs-on: ubuntu-latest
    steps:
      - name: Coveralls Finished
        uses: coverallsapp/github-action@v2
        with:
          parallel-finished: true