Skip to content

Commit

Permalink
ci: Cache librocksdb to speed up CI (#2360)
Browse files Browse the repository at this point in the history
* ci: Cache librocksdb to speed up CI

Signed-off-by: Xuanwo <github@xuanwo.io>

* Fix typo

Signed-off-by: Xuanwo <github@xuanwo.io>

* Fix path

Signed-off-by: Xuanwo <github@xuanwo.io>

* Add prefix for key

Signed-off-by: Xuanwo <github@xuanwo.io>

* Install dep

Signed-off-by: Xuanwo <github@xuanwo.io>

* try again

Signed-off-by: Xuanwo <github@xuanwo.io>

* fix build

Signed-off-by: Xuanwo <github@xuanwo.io>

* fix typo

Signed-off-by: Xuanwo <github@xuanwo.io>

* Fix lib

Signed-off-by: Xuanwo <github@xuanwo.io>

* Fix if

Signed-off-by: Xuanwo <github@xuanwo.io>

* Fix cache

Signed-off-by: Xuanwo <github@xuanwo.io>

* Remove rust update hack

Signed-off-by: Xuanwo <github@xuanwo.io>

* Use static lib instead

Signed-off-by: Xuanwo <github@xuanwo.io>

* Fix rocksdb version

Signed-off-by: Xuanwo <github@xuanwo.io>

---------

Signed-off-by: Xuanwo <github@xuanwo.io>
  • Loading branch information
Xuanwo authored May 30, 2023
1 parent 46ba442 commit 07c163f
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 39 deletions.
57 changes: 39 additions & 18 deletions .github/actions/setup/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,13 @@

name: Setup Rust Builder
description: 'Prepare Rust Build Environment'
inputs:
cache-key:
description: 'the rust cache key suffix'
required: false
default: ''

runs:
using: "composite"
steps:
- name: Cache Cargo
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}${{ inputs.cache-key }}
restore-keys: |
${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
${{ runner.os }}-cargo
- name: Setup rust related environment variables
shell: bash
run: |
# Update rust to latest stable
rustup update stable
# Disable full debug symbol generation to speed up CI build and keep memory down
# "1" means line tables only, which is useful for panic tracebacks.
echo "RUSTFLAGS=-C debuginfo=1" >> $GITHUB_ENV
Expand All @@ -51,3 +33,42 @@ runs:
echo "RUST_LOG=debug" >> $GITHUB_ENV
# Enable sparse index
echo "CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse" >> $GITHUB_ENV
- name: Setup rust on linux
if: runner.os == 'Linux'
shell: bash
run: |
# Set rocksdb lib path
echo "ROCKSDB_LIB_DIR=/tmp/rocksdb/lib" >> $GITHUB_ENV
echo "ROCKSDB_STATIC=true" >> $GITHUB_ENV
- name: Cache rocksdb
id: cache-rocksdb
uses: actions/cache@v3
if: runner.os == 'Linux'
with:
path: /tmp/rocksdb
key: r0-rocksdb-8.1.1
restore-keys: |
r0-rocksdb-
- name: Build rocksdb if not cached
if: ${{ steps.cache-rocksdb.outputs.cache-hit != 'true' && runner.os == 'Linux' }}
shell: bash
run: |
set -e
sudo apt-get install libgflags-dev libsnappy-dev zlib1g-dev libbz2-dev liblz4-dev libzstd-dev
cd /tmp
curl https://github.com/facebook/rocksdb/archive/refs/tags/v8.1.1.tar.gz -L -o rocksdb.tar.gz
tar -xzf rocksdb.tar.gz
cd rocksdb-8.1.1
mkdir /tmp/rocksdb
cmake -DCMAKE_INSTALL_PREFIX=/tmp/rocksdb
make -j$(nproc)
make install
cd ..
rm -rf /tmp/rocksdb-8.1.1
9 changes: 1 addition & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ jobs:

- name: Setup Rust toolchain
uses: ./.github/actions/setup
with:
cache-key: "-check"

- name: Check license headers
uses: korandoru/hawkeye@v2.0.0
Expand All @@ -59,8 +57,6 @@ jobs:

- name: Setup Rust toolchain
uses: ./.github/actions/setup
with:
cache-key: "-check"

- name: Checkout python env
uses: actions/setup-python@v4
Expand All @@ -83,8 +79,6 @@ jobs:

- name: Setup Rust toolchain
uses: ./.github/actions/setup
with:
cache-key: "-check"

- name: Checkout python env
uses: actions/setup-python@v4
Expand Down Expand Up @@ -149,8 +143,7 @@ jobs:

- name: Setup Rust toolchain
uses: ./.github/actions/setup
with:
cache-key: "-build-all-features"

- name: Build
run: cargo build --all-features

Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ jobs:

- name: Setup Rust toolchain
uses: ./.github/actions/setup
with:
cache-key: "-docs"

- uses: actions/setup-java@v3
with:
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/service_test_rocksdb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ jobs:
- uses: actions/checkout@v3
- name: Setup Rust toolchain
uses: ./.github/actions/setup
with:
cache-key: "-services-rocksdb"
- name: Test
shell: bash
working-directory: core
Expand Down
27 changes: 19 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ reqsign = { version = "0.12.0", default-features = false, optional = true }
reqwest = { version = "0.11.13", features = [
"stream",
], default-features = false }
rocksdb = { version = "0.20.1", default-features = false, optional = true }
rocksdb = { version = "0.21.0", default-features = false, optional = true }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
sled = { version = "0.34.7", optional = true }
Expand Down

0 comments on commit 07c163f

Please sign in to comment.