-
Notifications
You must be signed in to change notification settings - Fork 23
193 lines (187 loc) · 5.99 KB
/
build.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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
name: Tests
on:
push:
pull_request:
release:
types:
- published
schedule:
# At 12:00 on every day-of-month
- cron: "0 12 */1 * *"
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
COMDB2_DBNAME: mattdb
TIMEOUT: 30
jobs:
build_bloomberg_comdb2:
name: Build bloomberg-comdb2 from source
runs-on: ubuntu-latest
steps:
- name: Checkout bloomberg-comdb2 repository
uses: actions/checkout@v4
with:
repository: bloomberg/comdb2
path: bloomberg-comdb2
- name: Install build dependencies
run: '
sudo apt-get update &&
sudo apt-get install -qy
bison
build-essential
cmake
flex
libevent-dev
liblz4-dev
libprotobuf-c-dev
libreadline-dev
libsqlite3-dev
libssl-dev
libunwind-dev
ncurses-dev
protobuf-c-compiler
tcl
uuid-dev
zlib1g-dev
'
- name: Build from source
run: '
(
mkdir bloomberg-comdb2/build &&
cd bloomberg-comdb2/build &&
cmake .. &&
make
)
'
- name: Archive bloomberg-comdb2 repo with build artifacts
run: 'tar czvf bloomberg-comdb2.tar.gz bloomberg-comdb2/'
- name: Upload bloomberg-comdb2 repo with build artifacts
uses: actions/upload-artifact@v3
with:
name: bloomberg-comdb2
path: ./bloomberg-comdb2.tar.gz
build_sdist:
name: Build python-comdb2 source distribution
runs-on: ubuntu-latest
needs: [build_bloomberg_comdb2]
steps:
- name: Download bloomberg-comdb2 with build artifacts
uses: actions/download-artifact@v3
with:
name: bloomberg-comdb2
path: .
- name: Install bloomberg-comdb2
run: '
sudo apt-get install -qy
libevent-dev
liblz4-dev
libprotobuf-c-dev
libsqlite3-dev
libssl-dev
libunwind-dev
zlib1g-dev &&
tar xvf bloomberg-comdb2.tar.gz &&
(cd bloomberg-comdb2/build && sudo make install)
'
- uses: actions/checkout@v4
- name: 'Set up Python 3.7'
uses: actions/setup-python@v4 # note that this step overwrites the PKG_CONFIG_PATH variable
with:
python-version: '3.7' # the lowest version that we support in CI
- name: Build sdist
run: '
sudo apt-get install -qy pkg-config &&
PKG_CONFIG_PATH=/opt/bb/lib/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig:$PKG_CONFIG_PATH
pipx run build --sdist
'
- name: Upload sdist
uses: actions/upload-artifact@v3
with:
name: python-comdb2-sdist
path: dist/*.tar.gz
test:
name: Test suite
runs-on: ubuntu-latest
needs: [build_sdist]
strategy:
matrix:
python-version:
- '3.12'
- '3.11'
- '3.10'
- '3.9'
- '3.8'
- '3.7'
steps:
- name: Download comdb2 repo with build artifacts
uses: actions/download-artifact@v3
with:
name: bloomberg-comdb2
path: .
- name: Install bloomberg-comdb2
run: '
sudo apt-get install -qy
libevent-dev
liblz4-dev
libprotobuf-c-dev
libsqlite3-dev
libssl-dev
libunwind-dev
zlib1g-dev &&
tar xvf bloomberg-comdb2.tar.gz &&
(cd bloomberg-comdb2/build && sudo make install)
'
- name: Start local comdb2 instance
run: '
sudo mkdir -p /opt/bb/share/schemas/$COMDB2_DBNAME &&
echo "$COMDB2_DBNAME 1234 $(hostname -f)" > /opt/bb/etc/cdb2/config/comdb2db.cfg &&
(/opt/bb/bin/pmux -n &) &&
echo started pmux &&
/opt/bb/bin/comdb2 --create $COMDB2_DBNAME &&
(/opt/bb/bin/comdb2 $COMDB2_DBNAME > /tmp/$COMDB2_DBNAME.log 2>&1 &);
iterations=0;
until /opt/bb/bin/cdb2sql $COMDB2_DBNAME local "select 1+1" > /dev/null 2>&1;
do
echo -n ".";
sleep 1;
iterations=$(($iterations + 1));
if [ "$iterations" -ge "$TIMEOUT" ]; then
echo >&2 "$COMDB2_DBNAME failed to start after $iterations seconds";
exit 1;
fi;
done
'
- name: Download python-comdb2 sdist
uses: actions/download-artifact@v3
with:
name: python-comdb2-sdist
path: dist
- name: Extract python-comdb2 sdist
run: '
(cd dist/ && tar xvf comdb2-*.tar.gz && rm comdb2-*.tar.gz) &&
mv dist/comdb2-* python-comdb2-sdist && rmdir dist
'
- name: Create tables
run: |
tables="$(cat python-comdb2-sdist/tests/schemas/$COMDB2_DBNAME/table_constraint_order.txt)"
for table_name in $tables
do
table_file="python-comdb2-sdist/tests/schemas/$COMDB2_DBNAME/$table_name.csc2"
echo "Creating $table_name from $table_file"
/opt/bb/bin/cdb2sql "$COMDB2_DBNAME" local "create table $table_name { $(cat $table_file) }"
done
- name: Set up Python ${{matrix.python_version}}
uses: actions/setup-python@v4 # note that this step overwrites the PKG_CONFIG_PATH variable
with:
python-version: "${{matrix.python_version}}"
- name: Install python-comdb2 from the sdist
run: '
sudo apt-get install -qy pkg-config &&
python -m pip install --upgrade pip &&
PKG_CONFIG_PATH=/opt/bb/lib/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig:$PKG_CONFIG_PATH
LDFLAGS="-Wl,-rpath,/opt/bb/lib"
python -m pip install ./python-comdb2-sdist[tests]
'
- name: Run Tests
run: (cd python-comdb2-sdist/tests && python -m pytest -vvv)