Skip to content

Commit

Permalink
Unify TileDB installation scripts and cache outputs.
Browse files Browse the repository at this point in the history
This change unifies the build scripts between Mac OS and Linux,
and caches build outputs. This means that future builds of the same
version don’t need to rerun the entire build process; they can use the
previously-built version.

We do a few things to accomplish this:

- Move compilation/installation into the `~/tiledb-core/install`
  directory. This allows us to cache it.
- Set appropriate `CGO_*FLAGS` variables to point to that directory.
  This includes the `rpath` directive, which embeds the full path
  to the dynamic library in the binary, so it knows it needs to look in
  `~/tiledb-core/install/lib` for `libtiledb.so`.
- Matrixes things out to reduce repetition.
  • Loading branch information
thetorpedodog committed Jul 15, 2022
1 parent 95977bb commit 524675b
Show file tree
Hide file tree
Showing 10 changed files with 157 additions and 164 deletions.
16 changes: 16 additions & 0 deletions .github/scripts/env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Subroutine to set up environment variables.

CORE_ROOT="$HOME/tiledb-core"

case "$(uname -s)" in
Linux)
OS="linux"
;;
Darwin)
OS="macos"
;;
*)
echo 'Unknown OS!'
exit 1
;;
esac
8 changes: 8 additions & 0 deletions .github/scripts/install_tiledb_binary.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -exo pipefail
. "${BASH_SOURCE%/*}/env.sh"
mkdir "$CORE_ROOT"
cd "$CORE_ROOT"
mkdir install
curl --location -o tiledb.tar.gz "https://github.com/TileDB-Inc/TileDB/releases/download/${CORE_VERSION}/tiledb-${OS}-x86_64-${CORE_VERSION}-${CORE_HASH}.tar.gz"
tar -C ./install -xf tiledb.tar.gz
4 changes: 0 additions & 4 deletions .github/scripts/install_tiledb_linux.sh

This file was deleted.

8 changes: 0 additions & 8 deletions .github/scripts/install_tiledb_linux_debug.sh

This file was deleted.

3 changes: 0 additions & 3 deletions .github/scripts/install_tiledb_macos.sh

This file was deleted.

23 changes: 23 additions & 0 deletions .github/scripts/install_tiledb_source.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
set -exo pipefail
. "${BASH_SOURCE%/*}/env.sh"
mkdir "$CORE_ROOT"
cd "$CORE_ROOT"
case "$OS" in
linux)
NPROC="$(nproc)"
;;
macos)
NPROC="$(sysctl -n hw.ncpu)"
;;
esac
git clone --depth 1 -b "$CORE_VERSION" https://github.com/TileDB-Inc/TileDB.git
cd TileDB
mkdir build
cd build
# BUILD_FLAGS is unquoted because it needs to expand into multiple strings.
cmake $BUILD_FLAGS -DCMAKE_INSTALL_PREFIX="${CORE_ROOT}/install" ..
make -j"$NPROC"

mkdir "${CORE_ROOT}/install"
make -C tiledb install
8 changes: 0 additions & 8 deletions .github/scripts/install_tiledb_source_linux.sh

This file was deleted.

7 changes: 0 additions & 7 deletions .github/scripts/install_tiledb_source_macos.sh

This file was deleted.

12 changes: 12 additions & 0 deletions .github/scripts/post_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
set -exo pipefail
. "${BASH_SOURCE%/*}/env.sh"

# Sets up the environment after installing or extracting TileDB.

if [ "$OS" = "linux" ]; then
/sbin/ldconfig -n "${CORE_ROOT}/install/lib"
fi

go env -w "CGO_CFLAGS=-I${CORE_ROOT}/install/include"
go env -w "CGO_LDFLAGS=-L${CORE_ROOT}/install/lib/ -Wl,-rpath,${CORE_ROOT}/install/lib/"
232 changes: 98 additions & 134 deletions .github/workflows/tiledb-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,157 +7,121 @@ on:
pull_request:
branches: [ master ]

env:
# The version of TileDB to test against.
CORE_VERSION: "2.10.2"
# The first seven characters of that version's commit hash
# (the same ones that GitHub displays on a release page).
CORE_HASH: "9ab84f9"

jobs:
golangci:
name: lint
runs-on: ubuntu-20.04
steps:

# Checks out repository
- uses: actions/checkout@v2

# Downloads TileDB-Core from release assets and install
- name: Run TileDB install script
run: ./.github/scripts/install_tiledb_linux.sh
shell: bash

- name: golangci-lint
uses: golangci/golangci-lint-action@v2
continue-on-error: true
with:
# Required: the version of golangci-lint is required and must be
# specified without patch version: we always use the latest patch version.
version: v1.35.2

Linux_Test:
runs-on: ubuntu-20.04
# Checks out repository
- uses: actions/checkout@v2

- name: Cache build
id: build-cache
uses: actions/cache@v2
with:
path: ~/tiledb-core/install
key: golangci-${{ runner.os }}-${{ env.CORE_VERSION }}-${{ env.CORE_HASH }}-${{ hashFiles('./.github/scripts/install_tiledb_binary.sh') }}

- name: Install TileDB Core
if: steps.build-cache.outputs.cache-hit != 'true'
run: './.github/scripts/install_tiledb_binary.sh'

- name: Post-install
run: ./.github/scripts/post_install.sh

- name: golangci-lint
uses: golangci/golangci-lint-action@v2
continue-on-error: true
with:
# Required: the version of golangci-lint is required and must be
# specified without patch version: we always use the latest patch version.
version: v1.35.2

binary-test:
name: binary-${{ matrix.runner }}-go${{ matrix.go }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
# Will be checking following versions
go: ["1.18"]
steps:
runner: ["macos-11", "ubuntu-20.04"]

# Checks out repository
- uses: actions/checkout@v2

# Downloads TileDB-Core from release assets and install
- name: Run TileDB install script
run: ./.github/scripts/install_tiledb_linux.sh
shell: bash

# Following action sets up Go and uses the strategy matrix to test on
# specific versions
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
steps:

# Tests TileDB-Go
- name: Test TileDB-Go
run: go test -v ./...
- uses: actions/checkout@v2

Macos_Test:
runs-on: macos-11
strategy:
matrix:
# Will be checking following versions
go: ["1.18"]
steps:
# Checks out repository
- uses: actions/checkout@v2

# Downloads TileDB-Core from release assets and install
- name: Run TileDB install script
run: ./.github/scripts/install_tiledb_macos.sh
shell: bash

# Following action sets up Go and uses the strategy matrix to test on
# specific versions
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}

# Tests TileDB-Go
- name: Test TileDB-Go
run: go test -v ./...

Linux_Experimental_Test:
runs-on: ubuntu-20.04
strategy:
matrix:
# Will be checking following versions
go: ["1.18"]
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}

# Checks out repository
- uses: actions/checkout@v2
- name: Cache build
id: build-cache
uses: actions/cache@v2
with:
path: ~/tiledb-core/install
key: golangci-${{ runner.os }}-${{ env.CORE_VERSION }}-${{ env.CORE_HASH }}-${{ hashFiles('./.github/scripts/install_tiledb_binary.sh') }}

# Downloads TileDB-Core from release assets and install
- name: Run TileDB install script
run: ./.github/scripts/install_tiledb_source_linux.sh
shell: bash
- name: Install TileDB Core
if: steps.build-cache.outputs.cache-hit != 'true'
run: './.github/scripts/install_tiledb_binary.sh'

# Following action sets up Go and uses the strategy matrix to test on
# specific versions
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- name: Post-install
run: ./.github/scripts/post_install.sh

# Tests TileDB-Go
- name: Test TileDB-Go
run: go test -tags=experimental -v ./...
- name: Run tests
run: go test -v ./...

Macos_Experimental_Test:
runs-on: macos-11
source-test:
name: ${{ matrix.name }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
# Will be checking following versions
go: ["1.18"]
steps:
# Checks out repository
- uses: actions/checkout@v2

# Downloads TileDB-Core from release assets and install
- name: Run TileDB install script
run: ./.github/scripts/install_tiledb_source_macos.sh
shell: bash

# Following action sets up Go and uses the strategy matrix to test on
# specific versions
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}

# Tests experimental bindings of TileDB-Go
- name: Test TileDB-Go
run: go test -tags=experimental -v ./...

Linux_Address_Sanitizer:
runs-on: ubuntu-20.04
strategy:
matrix:
# Will be checking following versions
go: [1.18]
include:
- name: macos-experimental
runner: macos-11
flags: "-DTILEDB_VERBOSE=OFF -DTILEDB_S3=ON -DTILEDB_SERIALIZATION=ON -DCMAKE_BUILD_TYPE=Release"
test-command: go test -tags=experimental -v ./...
- name: linux-experimental
runner: ubuntu-20.04
flags: "-DTILEDB_VERBOSE=OFF -DTILEDB_S3=ON -DTILEDB_SERIALIZATION=ON -DCMAKE_BUILD_TYPE=Release"
test-command: go test -tags=experimental -v ./...
- name: linux-asan
runner: ubuntu-20.04
flags: "-DSANITIZER=leak -DTILEDB_VERBOSE=OFF -DTILEDB_S3=ON -DTILEDB_SERIALIZATION=ON -DCMAKE_BUILD_TYPE=Debug"
test-command: go run -tags asan ./cmd/tiledb-go-examples

steps:
# Checks out repository
- uses: actions/checkout@v2

# Downloads TileDB-Core from release assets and install
- name: Run TileDB install script
run: ./.github/scripts/install_tiledb_linux_debug.sh
shell: bash

# Following action sets up Go and uses the strategy matrix to test on
# specific versions
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}

# Tests TileDB-Go
- name: Running examples using address sanitizer flags
continue-on-error: true
run: go run -tags asan ./cmd/tiledb-go-examples
- uses: actions/checkout@v2

- uses: actions/setup-go@v2
with:
go-version: "1.18"

- name: Cache build
id: build-cache
uses: actions/cache@v2
with:
path: ~/tiledb-core/install
key: tiledb-binary-${{ runner.os }}-${{ env.CORE_VERSION }}-${{ env.CORE_HASH }}-${{ hashFiles('./.github/scripts/install_tiledb_source.sh') }}-${{ matrix.flags }}

- name: Compile TileDB Core
if: steps.build-cache.output.cache-hit != 'true'
run: './.github/scripts/install_tiledb_source.sh'
env:
BUILD_FLAGS: ${{ matrix.flags }}

- name: Post-install
run: ./.github/scripts/post_install.sh

- name: Run test
run: ${{ matrix.test-command }}

0 comments on commit 524675b

Please sign in to comment.