Skip to content

Commit 2f942de

Browse files
committed
Rework caching and building librocksdb.
Following suggestions from code review, this commit avoid re-using the working directory from different versions of the library.
1 parent 9cbbea6 commit 2f942de

File tree

2 files changed

+28
-22
lines changed

2 files changed

+28
-22
lines changed

.github/workflows/build.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
# vim:ts=2:sw=2:et:ai:sts=2
22
name: 'Build'
33

4-
on: ['push', 'pull_request']
4+
on:
5+
push:
56

67
jobs:
78
# Build the RocksDB C library and cache the result.
89
librocksdb:
910
name: 'Build librocksdb'
1011
runs-on: ${{ matrix.os }}
12+
env:
13+
LIBROCKSDB_PATH: /opt/rocksdb-${{ matrix.rocksdb_ver }}
1114
strategy:
1215
matrix:
1316
os: [ubuntu-latest]
@@ -18,10 +21,7 @@ jobs:
1821
id: cache-librocksdb
1922
with:
2023
key: ${{ matrix.os }}-librocksdb-${{ matrix.rocksdb_ver }}
21-
path: /opt/rocksdb
22-
restore-keys: |
23-
librocksdb-${{ matrix.os }}-
24-
librocksdb-
24+
path: ${{ env.LIBROCKSDB_PATH }}
2525

2626
- name: 'Install dependencies'
2727
if: steps.cache-librocksdb.outputs.cache-hit != 'true'
@@ -31,19 +31,19 @@ jobs:
3131
3232
- name: 'Clone & build RocksDB ${{ matrix.rocksdb_ver }}'
3333
if: steps.cache-librocksdb.outputs.cache-hit != 'true'
34-
run: |
35-
pushd /opt &&
36-
git clone https://github.com/facebook/rocksdb &&
37-
cd rocksdb &&
38-
git reset --hard ${{ matrix.rocksdb_ver }} &&
34+
run: >
35+
git clone https://github.com/facebook/rocksdb --depth 1
36+
--branch ${{ matrix.rocksdb_ver }} ${{ env.LIBROCKSDB_PATH }} &&
37+
pushd ${{ env.LIBROCKSDB_PATH }} &&
3938
CXXFLAGS='-flto -Os -s' PORTABLE=1 make shared_lib -j 4 &&
40-
make shared_lib &&
4139
popd
4240
4341
test:
4442
name: 'Build and test python-rocksdb'
4543
needs: librocksdb
4644
runs-on: ${{ matrix.os }}
45+
env:
46+
LIBROCKSDB_PATH: /opt/rocksdb-${{ matrix.rocksdb_ver }}
4747
strategy:
4848
matrix:
4949
os: [ubuntu-latest]
@@ -71,13 +71,13 @@ jobs:
7171
id: cache-librocksdb
7272
with:
7373
key: ${{ matrix.os }}-librocksdb-${{ matrix.rocksdb_ver }}
74-
path: /opt/rocksdb
74+
path: ${{ env.LIBROCKSDB_PATH }}
7575

7676
- name: 'Install RocksDB ${{ matrix.rocksdb_ver }}'
7777
if: steps.cache-librocksdb.outputs.cache-hit == 'true'
7878
# DO NOT FORGET to call `ldconfig`!
7979
run: |
80-
pushd /opt/rocksdb &&
80+
pushd ${{ env.LIBROCKSDB_PATH }} &&
8181
sudo make install-shared &&
8282
sudo ldconfig &&
8383
popd

.github/workflows/dist.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@ on:
1010
jobs:
1111
build_wheels:
1212
name: 'Build wheels'
13-
runs-on: ubuntu-latest
13+
runs-on: ${{ matrix.os }}
14+
env:
15+
LIBROCKSDB_PATH: /opt/rocksdb-${{ matrix.rocksdb_ver }}
16+
strategy:
17+
matrix:
18+
os: [ubuntu-latest]
19+
rocksdb_ver: ['v6.14.6']
1420

1521
steps:
1622
- uses: actions/checkout@v2
@@ -29,7 +35,6 @@ jobs:
2935
run: |
3036
python3 -m cibuildwheel --output-dir dist
3137
env:
32-
ROCKSDB_VERSION: 'v6.14.6'
3338
CIBW_MANYLINUX_X86_64_IMAGE: 'manylinux2014'
3439
CIBW_BUILD: 'cp3*'
3540
CIBW_SKIP: '*-manylinux_i686'
@@ -46,14 +51,15 @@ jobs:
4651
CIBW_BEFORE_BUILD: >
4752
yum install -y bzip2-devel lz4-devel snappy-devel zlib-devel
4853
python3-Cython &&
49-
pushd /opt &&
50-
test -d rocksdb || (
51-
git clone https://github.com/facebook/rocksdb &&
52-
cd rocksdb &&
53-
git reset --hard $ROCKSDB_VERSION &&
54-
CXXFLAGS='-flto -Os -s' PORTABLE=1 make shared_lib -j 4 &&
55-
make install-shared
54+
test -d ${{ env.LIBROCKSDB_PATH }} || (
55+
git clone https://github.com/facebook/rocksdb --depth 1
56+
--branch ${{ matrix.rocksdb_ver }} ${{ env.LIBROCKSDB_PATH }} &&
57+
cd ${{ env.LIBROCKSDB_PATH }} &&
58+
CXXFLAGS='-flto -Os -s' PORTABLE=1 make shared_lib -j 4
5659
) &&
60+
pushd ${{ env.LIBROCKSDB_PATH }} &&
61+
make install-shared &&
62+
ldconfig &&
5763
popd
5864
5965
- uses: actions/upload-artifact@v2

0 commit comments

Comments
 (0)