-
Notifications
You must be signed in to change notification settings - Fork 25
178 lines (159 loc) · 8.5 KB
/
run_tests.yml
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
#
# BSD 2-Clause License
#
# Copyright (c) 2021-2023, Hewlett Packard Enterprise
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
name: run_tests
# This file is for tests that are to be run frequently, with each push to a PR.
on:
push:
branches:
- master
- develop
pull_request:
branches:
- master
- develop
env:
HOMEBREW_NO_ANALYTICS: "ON" # Make Homebrew installation a little quicker
HOMEBREW_NO_AUTO_UPDATE: "ON"
HOMEBREW_NO_BOTTLE_SOURCE_FALLBACK: "ON"
HOMEBREW_NO_GITHUB_API: "ON"
HOMEBREW_NO_INSTALL_CLEANUP: "ON"
DEBIAN_FRONTEND: "noninteractive" # disable interactive apt installs
SR_LOG_FILE: "smartredis_cicd_tests_log.txt"
SR_LOG_LEVEL: "INFO"
jobs:
run_tests:
name: Run smartredis tests using ${{ matrix.os }}, Python ${{ matrix.py_v }}, RedisAI ${{ matrix.rai_v }}, and compiler ${{ matrix.compiler }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04] # cannot test on macOS as docker isn't supported on Mac
rai_v: [1.2.4, 1.2.5] # versions of RedisAI
py_v: ['3.7.x', '3.8.x', '3.9.x', '3.10.x'] # versions of Python
compiler: [intel, 8, 9, 10, 11] # intel compiler, and versions of GNU compiler
env:
FC: gfortran-${{ matrix.compiler }}
GCC_V: ${{ matrix.compiler }} # used when the compiler is gcc/gfortran
steps:
# download a copy of SmartRedis before running CI tests
- uses: actions/checkout@v3
# Setup python within the container
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.py_v }}
# Install compilers (Intel or GCC)
- name: Install GCC
if: "!contains( matrix.compiler, 'intel' )" # if using GNU compiler
run: |
sudo apt-get -y update &&
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test &&
sudo apt-get -y update &&
sudo apt-get -y install -y gcc-${GCC_V} gfortran-${GCC_V} g++-${GCC_V} &&
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${GCC_V} 100 \
--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${GCC_V} \
--slave /usr/bin/g++ g++ /usr/bin/g++-${GCC_V} \
--slave /usr/bin/gcov gcov /usr/bin/gcov-${GCC_V} &&
echo "CC=gcc" >> $GITHUB_ENV &&
echo "CXX=g++" >> $GITHUB_ENV &&
echo "FC=gfortran" >> $GITHUB_ENV
# Note CC and CXX need to be set otherwise, some Ubuntu images default to
# a Debian-flavored compiler
- name: Install Intel compiler
if: "contains( matrix.compiler, 'intel' )" # if using intel compiler
run: |
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB &&
sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB &&
rm GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB &&
echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list &&
sudo apt-get update -y &&
sudo apt-get install -y intel-oneapi-compiler-fortran intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic
source /opt/intel/oneapi/setvars.sh &&
printenv >> $GITHUB_ENV &&
echo "CC=icx" >> $GITHUB_ENV &&
echo "CXX=icpx" >> $GITHUB_ENV &&
echo "FC=ifort" >> $GITHUB_ENV
# Install additional dependencies
- name: Install Cmake Linux
if: contains(matrix.os, 'ubuntu')
run: sudo apt-get -y install cmake
- name: Build SmartRedis python and install
run: python -m pip install -e .[dev,xarray]
- name: Build and install test dependencies
run: make lcov && make catch2
- name: Install docker, redis-server, and RedisAI
run: |
sudo apt-get -y update && sudo apt-get -y install curl gnupg lsb-release software-properties-common ca-certificates && \
# Add latest redis to apt sources
sudo echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list && \
sudo curl -fsSL https://packages.redis.io/gpg | gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg && \
# Add latest docker to apt sources
sudo mkdir -m 0755 -p /etc/apt/keyrings &&
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg &&
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null &&
# Install and update
sudo apt-get -y update && \
sudo apt-get -y install iputils-ping docker-ce docker-ce-cli containerd.io redis-tools=6:6.2.5-1rl1~focal1 redis-server=6:6.2.5-1rl1~focal1 &&
CONTAINER_NAME="redisai_$RANDOM" &&
sudo docker create --name $CONTAINER_NAME --rm redislabs/redisai:${{ matrix.rai_v }}-cpu-bionic && \
sudo mkdir -p /usr/lib/redis/modules/ &&
sudo docker cp $CONTAINER_NAME:/usr/lib/redis/modules/redisai.so /usr/lib/redis/modules &&
sudo docker cp $CONTAINER_NAME:/usr/lib/redis/modules/backends/ /usr/lib/redis/modules/ &&
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/install/lib" >> $GITHUB_ENV &&
echo "REDISAI_CPU_INSTALL_PATH=/usr/lib/redis/modules/" >> $GITHUB_ENV &&
echo "SR_CICD_EXECUTION=True" >> $GITHUB_ENV &&
echo "REDISAI_MODULES=/usr/lib/redis/modules/redisai.so \
TF /usr/lib/redis/modules/backends/redisai_tensorflow/redisai_tensorflow.so \
TORCH /usr/lib/redis/modules/backends/redisai_torch/redisai_torch.so" >> $GITHUB_ENV
# Check the static build by compiling and linking examples
# Only supported on Linux; static builds are not currently available for MacOS
- name: Install MPI for parallel examples -- for GCC, we can just use the std install
if: contains(matrix.os, 'ubuntu') && !contains(matrix.compiler, 'intel')
run: sudo apt-get install -y mpich
- name: Test static build -- GNU compilers
if: contains(matrix.os, 'ubuntu') && !contains(matrix.compiler, 'intel')
run: make build-examples SR_LINK=Static SR_FORTRAN=ON
- name: Test static build -- intel compilers
if: contains(matrix.os, 'ubuntu') && contains(matrix.compiler, 'intel')
run: make build-example-serial SR_LINK=Static SR_FORTRAN=ON
# Run the tests using various DB deployments
- name: Run tests
run: |
make test-verbose-with-coverage \
COV_FLAGS="--cov=./src/python/module/smartredis/ --cov-report=xml --cov-append" \
SR_FORTRAN=ON SR_PYTHON=ON SR_TEST_REDIS_MODE=All SR_TEST_PORT=7000 \
SR_TEST_REDISAI_VER=v${{ matrix.rai_v }}
# Process and upload code coverage (Python was collected during pytest)
- name: Collect coverage from C/C++/Fortran testers
run: third-party/lcov/install/usr/local/bin/lcov -c -d build/Coverage/CMakeFiles -o coverage.info
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml, ./coverage.info
- name: Run Pylint
run: make check-lint