Skip to content

Commit 216c5c3

Browse files
committed
Create reusable action to run tests
- Reduce copy paste by using reusable action for running tests - Gain better control of tests matrix
1 parent f51a99d commit 216c5c3

File tree

2 files changed

+106
-121
lines changed

2 files changed

+106
-121
lines changed

.github/actions/run-tests/action.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: 'Run redis-py tests'
2+
description: 'Runs redis-py tests against different Redis versions and configurations'
3+
inputs:
4+
python-version:
5+
description: 'Python version to use for running tests'
6+
required: true
7+
default: '3.12'
8+
test-type:
9+
description: 'Type of tests to run'
10+
required: true
11+
default: 'standalone'
12+
parser-backend:
13+
description: 'Parser backend to use'
14+
required: true
15+
default: 'plain'
16+
resp-protocol:
17+
description: 'RESP protocol version to use'
18+
required: true
19+
default: '2'
20+
redis-version:
21+
description: 'Redis version to test against'
22+
required: true
23+
hiredis-version:
24+
description: 'hiredis version to test against'
25+
required: false
26+
default: '>3.0.0'
27+
event-loop:
28+
description: 'Event loop to use'
29+
required: false
30+
default: 'asyncio'
31+
runs:
32+
using: "composite"
33+
steps:
34+
- uses: actions/checkout@v4
35+
36+
- uses: actions/setup-python@v5
37+
with:
38+
python-version: ${{ inputs.python-version }}
39+
cache: 'pip'
40+
41+
- name: Run tests
42+
run: |
43+
pip install -U setuptools wheel
44+
pip install -r requirements.txt
45+
pip install -r dev_requirements.txt
46+
if [ "${{inputs.parser-backend}}" == "hiredis" ]; then
47+
pip install hiredis${{inputs.hiredis-version}}
48+
fi
49+
invoke devenv
50+
sleep 10 # time to settle
51+
52+
if [ "${{input.event-loop}}" == "uvloop" ]; then
53+
invoke ${{input.test-type}}-tests --uvloop --protocol=${{inputs.resp-protocol}}
54+
else
55+
invoke ${{input.test-type}}-tests --protocol=${{inputs.resp-protocol}}
56+
fi
57+
58+
ls -1
59+
shell: bash
60+
61+
- name: Upload test results and profiling data
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: pytest-results-${{input.test-type}}-${{input.parser-backend}}-${{input.python-version}}-${{input.event-loop}}-${{input.resp-protocol}}
65+
path: |
66+
${{input.test-type}}*-results.xml
67+
prof/**
68+
profile_output*
69+
if-no-files-found: error
70+
retention-days: 10
71+
72+
- name: Upload codecov coverage
73+
uses: codecov/codecov-action@v4
74+
with:
75+
fail_ci_if_error: false

.github/workflows/integration.yaml

Lines changed: 31 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -56,148 +56,58 @@ jobs:
5656
pip install -r dev_requirements.txt
5757
invoke linters
5858
59-
resp2-tests:
59+
tests:
6060
runs-on: ubuntu-latest
6161
timeout-minutes: 60
6262
strategy:
6363
max-parallel: 15
6464
fail-fast: false
6565
matrix:
66-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', 'pypy-3.9', 'pypy-3.10']
66+
redis-version: ['8.0.0-M01']
67+
resp-protocol: ['2', '3']
6768
test-type: ['standalone', 'cluster']
68-
connection-type: ['hiredis', 'plain']
69-
env:
70-
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
71-
name: RESP2 ${{ matrix.python-version }} ${{matrix.test-type}}-${{matrix.connection-type}}
72-
steps:
73-
- uses: actions/checkout@v4
74-
75-
- uses: actions/setup-python@v5
76-
with:
77-
python-version: ${{ matrix.python-version }}
78-
cache: 'pip'
79-
80-
- name: Run tests
81-
run: |
82-
pip install -U setuptools wheel
83-
pip install -r requirements.txt
84-
pip install -r dev_requirements.txt
85-
if [ "${{matrix.connection-type}}" == "hiredis" ]; then
86-
pip install hiredis
87-
fi
88-
invoke devenv
89-
sleep 10 # time to settle
90-
invoke ${{matrix.test-type}}-tests
91-
ls -1
92-
93-
- name: Run tests against hiredis < 3.0.0
94-
if: ${{ matrix.connection-type == 'hiredis' && matrix.python-version == '3.12'}}
95-
run: |
96-
pip uninstall hiredis -y
97-
pip install -U setuptools wheel
98-
pip install -r requirements.txt
99-
pip install -r dev_requirements.txt
100-
if [ "${{matrix.connection-type}}" == "hiredis" ]; then
101-
pip install "hiredis<3.0.0"
102-
fi
103-
invoke devenv
104-
sleep 10 # time to settle
105-
invoke ${{matrix.test-type}}-tests
106-
ls -1
107-
108-
- name: Upload test results and profiling data
109-
uses: actions/upload-artifact@v4
110-
with:
111-
name: pytest-results-${{matrix.test-type}}-${{matrix.connection-type}}-${{matrix.python-version}}
112-
path: |
113-
${{matrix.test-type}}*-results.xml
114-
prof/**
115-
profile_output*
116-
if-no-files-found: error
117-
retention-days: 10
118-
119-
- name: Upload codecov coverage
120-
uses: codecov/codecov-action@v4
121-
with:
122-
fail_ci_if_error: false
123-
124-
resp3-tests:
125-
runs-on: ubuntu-latest
126-
strategy:
127-
fail-fast: false
128-
matrix:
12969
python-version: ['3.8', '3.12']
130-
test-type: ['standalone', 'cluster']
131-
connection-type: ['hiredis', 'plain']
132-
event-loop: ['asyncio', 'uvloop']
70+
parser-backend: ['hiredis', 'plain']
71+
event-loop: ['asyncio']
72+
include:
73+
# Run python compatibility and uvloop tests only for latest redis version and plain parser backends
74+
- python-version: ['3.9', '3.10', '3.11', 'pypy-3.9', 'pypy-3.10']
75+
event-loop: ['asyncio', 'uvloop']
76+
resp-protocol: '2'
77+
redis-version: '8.0.0-M01'
78+
parser-backend: 'plain'
13379
exclude:
13480
- test-type: 'cluster'
135-
connection-type: 'hiredis'
81+
parser-backend: 'hiredis'
82+
resp-protocol: '3'
13683
env:
13784
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
138-
name: RESP3 ${{ matrix.python-version }} ${{matrix.test-type}}-${{matrix.connection-type}}-${{matrix.event-loop}}
85+
name: RESP${{ matrix.resp-protocol }} ${{ matrix.python-version }} ${{matrix.test-type}}-${{matrix.parser-backend}}
13986
steps:
140-
- uses: actions/checkout@v4
141-
142-
- uses: actions/setup-python@v5
143-
with:
144-
python-version: ${{ matrix.python-version }}
145-
cache: 'pip'
146-
14787
- name: Run tests
148-
run: |
149-
pip install -U setuptools wheel
150-
pip install -r requirements.txt
151-
pip install -r dev_requirements.txt
152-
if [ "${{matrix.connection-type}}" == "hiredis" ]; then
153-
pip install hiredis
154-
fi
155-
invoke devenv
156-
sleep 10 # time to settle
157-
if [ "${{matrix.event-loop}}" == "uvloop" ]; then
158-
invoke ${{matrix.test-type}}-tests --uvloop --protocol=3
159-
else
160-
invoke ${{matrix.test-type}}-tests --protocol=3
161-
fi
162-
163-
- name: Run tests against hiredis < 3.0.0
164-
if: ${{ matrix.connection-type == 'hiredis' && matrix.python-version == '3.12'}}
165-
run: |
166-
pip uninstall hiredis -y
167-
pip install -U setuptools wheel
168-
pip install -r requirements.txt
169-
pip install -r dev_requirements.txt
170-
if [ "${{matrix.connection-type}}" == "hiredis" ]; then
171-
pip install "hiredis<3.0.0"
172-
fi
173-
invoke devenv
174-
sleep 10 # time to settle
175-
if [ "${{matrix.event-loop}}" == "uvloop" ]; then
176-
invoke ${{matrix.test-type}}-tests --uvloop --protocol=3
177-
else
178-
invoke ${{matrix.test-type}}-tests --protocol=3
179-
fi
180-
181-
- name: Upload test results and profiling data
182-
uses: actions/upload-artifact@v4
88+
uses: ./.github/actions/run-tests
18389
with:
184-
name: pytest-results-${{matrix.test-type}}-${{matrix.connection-type}}-${{matrix.python-version}}-${{matrix.event-loop}}-resp3
185-
path: |
186-
${{matrix.test-type}}*-results.xml
187-
prof/**
188-
profile_output*
189-
if-no-files-found: error
190-
retention-days: 10
90+
python-version: ${{ matrix.python-version }}
91+
test-type: ${{ matrix.test-type }}
92+
parser-backend: ${{ matrix.parser-backend }}
93+
resp-protocol: ${{ matrix.resp-protocol }}
94+
redis-version: ${{ matrix.redis-version }}
19195

192-
- name: Upload codecov coverage
193-
uses: codecov/codecov-action@v4
96+
- name: Run tests against hiredis < 3.0.0
97+
uses: ./.github/actions/run-tests
98+
if: ${{ matrix.parser-backend == 'hiredis' && matrix.python-version == '3.12'}}
19499
with:
195-
fail_ci_if_error: false
100+
python-version: ${{ matrix.python-version }}
101+
test-type: ${{ matrix.test-type }}
102+
parser-backend: ${{ matrix.parser-backend }}
103+
resp-protocol: ${{ matrix.resp-protocol }}
104+
redis-version: ${{ matrix.redis-version }}
105+
hiredis-version: '<3.0.0'
196106

197107
build-and-test-package:
198108
name: Validate building and installing the package
199109
runs-on: ubuntu-latest
200-
needs: [resp2-tests, resp3-tests]
110+
needs: [tests]
201111
strategy:
202112
fail-fast: false
203113
matrix:

0 commit comments

Comments
 (0)