diff --git a/ci/cargo-build-test.sh b/ci/cargo-build-test.sh new file mode 100755 index 0000000..7878de8 --- /dev/null +++ b/ci/cargo-build-test.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +# Source: +# https://github.com/solana-labs/solana-accountsdb-plugin-postgres/blob/master/ci/cargo-build-test.sh + +set -e +cd "$(dirname "$0")/.." + +source ./ci/rust-version.sh stable + +export RUSTFLAGS="-D warnings" +export RUSTBACKTRACE=1 + +set -x + +# Build/test all host crates +cargo +"$rust_stable" build +cargo +"$rust_stable" test -- --nocapture + +exit 0 diff --git a/ci/cargo-install-all.sh b/ci/cargo-install-all.sh new file mode 100755 index 0000000..2f172f5 --- /dev/null +++ b/ci/cargo-install-all.sh @@ -0,0 +1,78 @@ +#!/usr/bin/env bash + +set -e + + +usage() { + exitcode=0 + if [[ -n "$1" ]]; then + exitcode=1 + echo "Error: $*" + fi + cat <] [--debug] +EOF + exit $exitcode +} + +case "$CI_OS_NAME" in +osx) + libExt=dylib + ;; +linux) + libExt=so + ;; +*) + echo CI_OS_NAME unsupported + exit 1 + ;; +esac + +maybeRustVersion= +installDir= +buildVariant=release +maybeReleaseFlag=--release + +while [[ -n $1 ]]; do + if [[ ${1:0:1} = - ]]; then + if [[ $1 = --debug ]]; then + maybeReleaseFlag= + buildVariant=debug + shift + else + usage "Unknown option: $1" + fi + elif [[ ${1:0:1} = \+ ]]; then + maybeRustVersion=$1 + shift + else + installDir=$1 + shift + fi +done + +if [[ -z "$installDir" ]]; then + usage "Install directory not specified" + exit 1 +fi + +installDir="$(mkdir -p "$installDir"; cd "$installDir"; pwd)" + +echo "Install location: $installDir ($buildVariant)" + +cd "$(dirname "$0")"/.. + +SECONDS=0 + +mkdir -p "$installDir/lib" + +( + set -x + # shellcheck disable=SC2086 # Don't want to double quote $rust_version + cargo $maybeRustVersion build $maybeReleaseFlag --lib +) + +cp -fv "target/$buildVariant/${GEYSER_PLUGIN_LIB}.$libExt" "$installDir"/lib/ + +echo "Done after $SECONDS seconds" + diff --git a/ci/create-tarball.sh b/ci/create-tarball.sh new file mode 100755 index 0000000..b55504b --- /dev/null +++ b/ci/create-tarball.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash +set -e + +cd "$(dirname "$0")/.." + +case "$CI_OS_NAME" in +osx) + _cputype="$(uname -m)" + if [[ $_cputype = arm64 ]]; then + _cputype=aarch64 + fi + TARGET=${_cputype}-apple-darwin + ;; +linux) + TARGET=x86_64-unknown-linux-gnu + ;; +*) + echo CI_OS_NAME unsupported + exit 1 + ;; +esac + +RELEASE_BASENAME="${RELEASE_BASENAME:="${GEYSER_PLUGIN_NAME}-release"}" +TARBALL_BASENAME="${TARBALL_BASENAME:="$RELEASE_BASENAME"}" + +echo --- Creating release tarball +( + set -x + rm -rf "${RELEASE_BASENAME:?}"/ + mkdir "${RELEASE_BASENAME}"/ + + COMMIT="$(git rev-parse HEAD)" + + ( + echo "channel: $CI_TAG" + echo "commit: $COMMIT" + echo "target: $TARGET" + ) > "${RELEASE_BASENAME}"/version.yml + + # Make CHANNEL available to include in the software version information + export CHANNEL + + source ci/rust-version.sh stable + ci/cargo-install-all.sh stable "${RELEASE_BASENAME}" + + tar cvf "${TARBALL_BASENAME}"-$TARGET.tar "${RELEASE_BASENAME}" + bzip2 "${TARBALL_BASENAME}"-$TARGET.tar + cp "${RELEASE_BASENAME}"/version.yml "${TARBALL_BASENAME}"-$TARGET.yml +) + +echo --- ok diff --git a/ci/env.sh b/ci/env.sh new file mode 100755 index 0000000..980027a --- /dev/null +++ b/ci/env.sh @@ -0,0 +1,3 @@ +#!/bin/bash +plugin_name=solana-geyser-sqs-grpc-release +plugin_lib_name=solana_geyser_connector_plugin_grpc diff --git a/ci/rust-version.sh b/ci/rust-version.sh new file mode 100755 index 0000000..4530093 --- /dev/null +++ b/ci/rust-version.sh @@ -0,0 +1,137 @@ +#!/usr/bin/env bash + +# Source: +# https://github.com/solana-labs/solana-accountsdb-plugin-postgres/blob/master/ci/rust-version.sh + +# +# This file maintains the rust versions for use by CI. +# +# Obtain the environment variables without any automatic toolchain updating: +# $ source ci/rust-version.sh +# +# Obtain the environment variables updating both stable and nightly, only stable, or +# only nightly: +# $ source ci/rust-version.sh all +# $ source ci/rust-version.sh stable +# $ source ci/rust-version.sh nightly + +# Then to build with either stable or nightly: +# $ cargo +"$rust_stable" build +# $ cargo +"$rust_nightly" build +# + +if [[ -n $RUST_STABLE_VERSION ]]; then + stable_version="$RUST_STABLE_VERSION" +else + stable_version=1.59.0 +fi + +if [[ -n $RUST_NIGHTLY_VERSION ]]; then + nightly_version="$RUST_NIGHTLY_VERSION" +else + nightly_version=2022-02-24 +fi + + +export rust_stable="$stable_version" +export rust_stable_docker_image=solanalabs/rust:"$stable_version" + +export rust_nightly=nightly-"$nightly_version" +export rust_nightly_docker_image=solanalabs/rust-nightly:"$nightly_version" + +[[ -z $1 ]] || ( + rustup_install() { + declare toolchain=$1 + if ! cargo +"$toolchain" -V > /dev/null; then + echo "$0: Missing toolchain? Installing...: $toolchain" >&2 + rustup install "$toolchain" + cargo +"$toolchain" -V + fi + } + + set -e + cd "$(dirname "${BASH_SOURCE[0]}")" + case $1 in + stable) + rustup_install "$rust_stable" + ;; + nightly) + rustup_install "$rust_nightly" + ;; + all) + rustup_install "$rust_stable" + rustup_install "$rust_nightly" + ;; + *) + echo "$0: Note: ignoring unknown argument: $1" >&2 + ;; + esac +)#!/usr/bin/env bash + +# Source: +# https://github.com/solana-labs/solana-accountsdb-plugin-postgres/blob/master/ci/rust-version.sh + +# +# This file maintains the rust versions for use by CI. +# +# Obtain the environment variables without any automatic toolchain updating: +# $ source ci/rust-version.sh +# +# Obtain the environment variables updating both stable and nightly, only stable, or +# only nightly: +# $ source ci/rust-version.sh all +# $ source ci/rust-version.sh stable +# $ source ci/rust-version.sh nightly + +# Then to build with either stable or nightly: +# $ cargo +"$rust_stable" build +# $ cargo +"$rust_nightly" build +# + +if [[ -n $RUST_STABLE_VERSION ]]; then + stable_version="$RUST_STABLE_VERSION" +else + stable_version=1.59.0 +fi + +if [[ -n $RUST_NIGHTLY_VERSION ]]; then + nightly_version="$RUST_NIGHTLY_VERSION" +else + nightly_version=2022-02-24 +fi + + +export rust_stable="$stable_version" +export rust_stable_docker_image=solanalabs/rust:"$stable_version" + +export rust_nightly=nightly-"$nightly_version" +export rust_nightly_docker_image=solanalabs/rust-nightly:"$nightly_version" + +[[ -z $1 ]] || ( + rustup_install() { + declare toolchain=$1 + if ! cargo +"$toolchain" -V > /dev/null; then + echo "$0: Missing toolchain? Installing...: $toolchain" >&2 + rustup install "$toolchain" + cargo +"$toolchain" -V + fi + } + + set -e + cd "$(dirname "${BASH_SOURCE[0]}")" + case $1 in + stable) + rustup_install "$rust_stable" + ;; + nightly) + rustup_install "$rust_nightly" + ;; + all) + rustup_install "$rust_stable" + rustup_install "$rust_nightly" + ;; + *) + echo "$0: Note: ignoring unknown argument: $1" >&2 + ;; + esac +) diff --git a/ci/solana-version.sh b/ci/solana-version.sh new file mode 100755 index 0000000..d0e8adb --- /dev/null +++ b/ci/solana-version.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +# Prints the Solana version. + +set -e + +cd "$(dirname "$0")/.." + +cargo read-manifest | jq -r '.dependencies[] | select(.name == "solana-geyser-plugin-interface") | .req'