diff --git a/.github/actions/deps/action.yml b/.github/actions/deps/action.yml new file mode 100644 index 0000000..1104add --- /dev/null +++ b/.github/actions/deps/action.yml @@ -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' diff --git a/.github/workflows/go_build.yml b/.github/workflows/go_build.yml index b150162..8310e14 100644 --- a/.github/workflows/go_build.yml +++ b/.github/workflows/go_build.yml @@ -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 ./... diff --git a/contrib/deps-bundle.sh b/contrib/deps-bundle.sh index 02bfe07..e87b07e 100755 --- a/contrib/deps-bundle.sh +++ b/contrib/deps-bundle.sh @@ -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 diff --git a/deps.sh b/deps.sh index c393897..94a4a54 100755 --- a/deps.sh +++ b/deps.sh @@ -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" } @@ -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 \ @@ -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" }