Skip to content

Commit 3b4922c

Browse files
committed
Python: added MacOS and amazonlinux build tests to github actions CI
1 parent fad22c1 commit 3b4922c

File tree

4 files changed

+143
-24
lines changed

4 files changed

+143
-24
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Build Python wrapper
2+
3+
inputs:
4+
os:
5+
description: "The current operating system"
6+
required: true
7+
type: string
8+
options:
9+
- macOS
10+
- ubuntu
11+
- amazon-linux
12+
release_mode:
13+
description: "Enable building the wrapper in release mode"
14+
required: false
15+
type: boolean
16+
default: 'false'
17+
18+
env:
19+
CARGO_TERM_COLOR: always
20+
21+
runs:
22+
using: "composite"
23+
steps:
24+
- name: Install software dependencies for macOS
25+
shell: bash
26+
if: "${{ inputs.os == 'macOS' }}"
27+
run: |
28+
brew install git gcc pkgconfig protobuf openssl redis
29+
30+
- name: Install software dependencies for Ubuntu
31+
shell: bash
32+
if: "${{ inputs.os == 'ubuntu' }}"
33+
run: |
34+
sudo apt update
35+
sudo apt install protobuf-compiler
36+
37+
- name: Install software dependencies for Amazon-Linux
38+
shell: bash
39+
if: "${{ inputs.os == 'amazon-linux' }}"
40+
run: |
41+
yum install -y python3 gcc pkgconfig protobuf-compiler openssl openssl-devel which curl redis6 --allowerasing
42+
43+
- name: Install Python software dependencies
44+
shell: bash
45+
run: |
46+
python3 -m ensurepip --upgrade
47+
python3 -m pip install --upgrade pip
48+
python3 -m pip install virtualenv mypy-protobuf
49+
50+
- name: Install Rust
51+
shell: bash
52+
run: |
53+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
54+
55+
- name: Generate protobuf files
56+
shell: bash
57+
working-directory: .
58+
run: |
59+
export PATH="$PATH:$HOME/.local/bin"
60+
MYPY_PROTOC_PATH=`which protoc-gen-mypy`
61+
protoc --plugin=protoc-gen-mypy=${MYPY_PROTOC_PATH} -Iprotobuf=./babushka-core/src/protobuf/ --python_out=./python/python/pybushka --mypy_out=./python/python/pybushka ./babushka-core/src/protobuf/*.proto
62+
63+
- name: Build Pybushka
64+
shell: bash
65+
working-directory: ./python
66+
run: |
67+
source "$HOME/.cargo/env"
68+
python3 -m venv .env
69+
source .env/bin/activate
70+
python3 -m pip install --upgrade pip
71+
python3 -m pip install -r requirements.txt
72+
RELEASE_FLAG=`if [ ${{ inputs.release_mode }} = 'true' ]; then echo --release; fi`
73+
maturin develop ${RELEASE_FLAG}

.github/workflows/python.yml

+66-24
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,20 @@ on:
88
- babushka-core/src/**
99
- submodules/**
1010
- utils/cluster_manager.py
11+
- .github/workflows/python.yml
1112
pull_request:
1213
paths:
1314
- python/**
1415
- babushka-core/src/**
1516
- submodules/**
1617
- utils/cluster_manager.py
18+
- .github/workflows/python.yml
1719

1820
permissions:
1921
contents: read
2022

2123
jobs:
22-
build:
24+
test-ubuntu-latest:
2325
runs-on: ubuntu-latest
2426
timeout-minutes: 15
2527
strategy:
@@ -39,11 +41,6 @@ jobs:
3941
with:
4042
redis-version: ${{ matrix.redis }}
4143

42-
- name: Install protoc
43-
run: |
44-
sudo apt update
45-
sudo apt install protobuf-compiler
46-
4744
- name: Set up Python 3.10
4845
uses: actions/setup-python@v3
4946
with:
@@ -73,23 +70,11 @@ jobs:
7370
run: |
7471
black --target-version py36 --check --diff .
7572
76-
- name: Start redis server
77-
working-directory: ./python
78-
run: redis-server &
79-
80-
- name: Generate protobuf files
81-
working-directory: .
82-
run: |
83-
MYPY_PROTOC_PATH=`which protoc-gen-mypy`
84-
protoc --plugin=protoc-gen-mypy=${MYPY_PROTOC_PATH} -Iprotobuf=./babushka-core/src/protobuf/ --python_out=./python/python/pybushka --mypy_out=./python/python/pybushka ./babushka-core/src/protobuf/*.proto
85-
86-
- name: Build Pybushka
87-
working-directory: ./python
88-
run: |
89-
python -m venv .env
90-
source .env/bin/activate
91-
pip install -r requirements.txt
92-
maturin develop --release
73+
- name: Build Python wrapper
74+
uses: ./.github/workflows/build-python-wrapper
75+
with:
76+
os: 'ubuntu'
77+
release_mode: 'true'
9378

9479
- name: Type check with mypy
9580
working-directory: ./python
@@ -101,7 +86,7 @@ jobs:
10186
# Install the benchmark requirements
10287
pip install -r ../benchmarks/python/requirements.txt
10388
python -m mypy ..
104-
89+
10590
- name: Test with pytest
10691
working-directory: ./python
10792
run: |
@@ -120,3 +105,60 @@ jobs:
120105
with:
121106
cargo-toml-folder: ./python
122107
name: lint python-rust
108+
109+
build-macos-latest:
110+
runs-on: macos-latest
111+
timeout-minutes: 15
112+
steps:
113+
- uses: actions/checkout@v4
114+
with:
115+
submodules: recursive
116+
- name: Set up Homebrew
117+
uses: Homebrew/actions/setup-homebrew@master
118+
119+
- name: Build Python wrapper
120+
uses: ./.github/workflows/build-python-wrapper
121+
with:
122+
os: 'macOS'
123+
- name: Test compatibility with pytest
124+
working-directory: ./python
125+
run: |
126+
source .env/bin/activate
127+
pytest --asyncio-mode=auto -m smoke_test
128+
129+
build-amazonlinux-latest:
130+
runs-on: ubuntu-latest
131+
container: amazonlinux:latest
132+
timeout-minutes: 15
133+
steps:
134+
- name: Install git
135+
run: |
136+
yum -y remove git
137+
yum -y remove git-*
138+
yum -y install https://packages.endpointdev.com/rhel/7/os/x86_64/endpoint-repo.x86_64.rpm
139+
yum install -y git
140+
git --version
141+
142+
- uses: actions/checkout@v3
143+
144+
- name: Checkout submodules
145+
run: |
146+
git config --global --add safe.directory "$GITHUB_WORKSPACE"
147+
git submodule update --init --recursive
148+
149+
- name: Build Python wrapper
150+
uses: ./.github/workflows/build-python-wrapper
151+
with:
152+
os: 'amazon-linux'
153+
154+
- name: Create a symbolic Link for redis6 binaries
155+
working-directory: ./python
156+
run: |
157+
ln -s /usr/bin/redis6-server /usr/bin/redis-server
158+
ln -s /usr/bin/redis6-cli /usr/bin/redis-cli
159+
160+
- name: Test compatibility with pytest
161+
working-directory: ./python
162+
run: |
163+
source .env/bin/activate
164+
pytest --asyncio-mode=auto -m smoke_test

python/pytest.ini

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[pytest]
2+
markers =
3+
smoke_test: mark a test as a build verification testing.

python/python/tests/test_async_client.py

+1
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ async def test_select_standalone_database_id(self, request):
197197

198198
@pytest.mark.asyncio
199199
class TestCommands:
200+
@pytest.mark.smoke_test
200201
@pytest.mark.parametrize("cluster_mode", [True, False])
201202
async def test_socket_set_get(self, redis_client: TRedisClient):
202203
key = get_random_string(10)

0 commit comments

Comments
 (0)