Skip to content

Commit

Permalink
Update deps script
Browse files Browse the repository at this point in the history
  • Loading branch information
riptl committed Feb 11, 2024
1 parent 9806b5d commit 0320302
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 27 deletions.
54 changes: 54 additions & 0 deletions .github/actions/deps/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: deps
description: 'Build and cache dependencies'
inputs:
deps-script-path:
description: 'Path of deps.sh script'
required: true
default: './deps.sh'
deps-bundle-path:
description: 'Path of deps-bundle.sh script'
required: true
default: './contrib/deps-bundle.sh'
outputs: {}
runs:
using: composite
steps:
- name: Has apt-get?
shell: bash
run: |
if command -v apt-get > /dev/null 2>&1; then
echo "HAS_APT_GET=1" >> $GITHUB_ENV
else
echo "HAS_APT_GET=0" >> $GITHUB_ENV
fi
- name: apt-get update
shell: bash
run: sudo apt-get update
if: env.HAS_APT_GET == '1'

- id: deps-sh-hash
shell: bash
run: sha256sum '${{ inputs.deps-script-path }}' | awk '{print "HASH=" $1}' >> "$GITHUB_OUTPUT"

- id: deps-sh-cache
uses: actions/cache@v4
with:
path: deps-bundle.tar.zst
key: ${{ runner.os }}-deps-sh-${{ steps.deps-sh-hash.outputs.HASH }}

- name: Install system level dependencies
shell: bash
run: '${{ inputs.deps-script-path }}' check

- name: Install dependencies from cache
shell: bash
run: tar -Izstd -xvf deps-bundle.tar.zst
if: steps.deps-sh-cache.outputs.cache-hit == 'true'

- name: Install dependencies from scratch
shell: bash
run: |
'${{ inputs.deps-script-path }}' install
'${{ inputs.deps-bundle-path }}'
if: steps.deps-sh-cache.outputs.cache-hit != 'true'
14 changes: 5 additions & 9 deletions .github/workflows/go_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,14 @@ jobs:
go-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: ./.github/actions/deps

- name: Setup Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: 1.20.5

- name: Fetch deps
run: |
# Hosted with Git LFS. See ./contrib/deps-bundle.sh
wget -q https://github.com/firedancer-io/radiance/raw/deps/deps-bundle.tar.zst
tar -I zstd -xf deps-bundle.tar.zst
go-version: 1.22.0

- name: Vet
run: source activate-opt && go vet ./...
Expand Down
4 changes: 1 addition & 3 deletions contrib/deps-bundle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ cd -- "$( dirname -- "${BASH_SOURCE[0]}" )"/..
rm -f deps-bundle.tar.zst

tar -Izstd -cf deps-bundle.tar.zst \
./opt/{include,lib,lib64}
./opt/{include,lib}

echo "[+] Created deps-bundle.tar.zst"

# Now you can commit this file to the deps branch of the repository
21 changes: 6 additions & 15 deletions deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ install_zstd () {
cd ./opt/git/zstd/lib

echo "[+] Installing zstd to $PREFIX"
"${MAKE[@]}" DESTDIR="$PREFIX" PREFIX="" install-pc install-static install-includes
"${MAKE[@]}" DESTDIR="$PREFIX" PREFIX="" MOREFLAGS="-fPIC" install-pc install-static install-includes
echo "[+] Successfully installed zstd"
}

Expand Down Expand Up @@ -336,13 +336,12 @@ install_lz4 () {

install_rocksdb () {
cd ./opt/git/rocksdb

echo "[+] Configuring RocksDB"
mkdir -p build
cd build
cmake .. \
-G"Unix Makefiles" \
-DCMAKE_INSTALL_PREFIX:PATH="" \
-DCMAKE_INSTALL_PREFIX:PATH="$PREFIX" \
-DCMAKE_INSTALL_LIBDIR="lib" \
-DCMAKE_BUILD_TYPE=Release \
-DROCKSDB_BUILD_SHARED=OFF \
-DWITH_GFLAGS=OFF \
Expand All @@ -364,21 +363,13 @@ install_rocksdb () {
-DSnappy_INCLUDE_DIRS="$PREFIX/include"
echo "[+] Configured RocksDB"

echo "[+] Building RocksDB"
local NJOBS
if [[ "$OS" == linux ]]; then
NJOBS=$(( $(nproc) / 2 ))
NJOBS=$((NJOBS>0 ? NJOBS : 1))
elif [[ "$OS" == darwin ]]; then
NJOBS=$(sysctl -n hw.physicalcpu)
else
NJOBS=2
fi
NJOBS=$(( $(nproc) / 2 ))
NJOBS=$((NJOBS>0 ? NJOBS : 1))
make -j $NJOBS
echo "[+] Successfully built RocksDB"

echo "[+] Installing RocksDB to $PREFIX"
make install DESTDIR="$PREFIX"
make install
echo "[+] Successfully installed RocksDB"
}

Expand Down

0 comments on commit 0320302

Please sign in to comment.