From bb6f8a870c588b162fa0dda953b6442ac0ef46f7 Mon Sep 17 00:00:00 2001 From: Kirill Fomichev Date: Fri, 6 Oct 2023 19:24:21 +0400 Subject: [PATCH] workflow --- .github/workflows/release.yml | 49 ++++++++++++++++++++----- .github/workflows/test.yml | 41 +++++++++++++++++---- ci/cargo-build-test.sh | 3 +- ci/create-tarball.sh | 1 - ci/rust-version.sh | 69 ----------------------------------- 5 files changed, 74 insertions(+), 89 deletions(-) delete mode 100755 ci/rust-version.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ac54802..3355bf1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,29 +1,52 @@ on: push: - tags: - - 'v*' - pull_request: - paths: - - '.github/workflows/release.yml' env: CARGO_TERM_COLOR: always jobs: release: - runs-on: ubuntu-20.04 + strategy: + matrix: + os: [ubuntu-20.04, ubuntu-22.04] + runs-on: ["${{ matrix.os }}"] steps: - uses: actions/checkout@v2 - name: Set env vars run: | - source ci/rust-version.sh + rust_stable=$(rustc --version | awk '{print $2}') echo "RUST_STABLE=$rust_stable" | tee -a $GITHUB_ENV - - if: runner.os == 'Linux' + - name: instal dependencies for 20.04 + if: matrix.os == 'ubuntu-20.04' run: | sudo apt-get update - sudo apt-get install -y libudev-dev libssl-dev libsasl2-dev libzstd-dev + sudo apt-get install -y \ + gnupg \ + libudev-dev \ + libsasl2-dev \ + libssl-dev \ + libzstd-dev + + - name: install protobuff 3.12 + if: matrix.os == 'ubuntu-20.04' + run: | + curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v3.15.8/protoc-3.15.8-linux-x86_64.zip + unzip protoc-3.15.8-linux-x86_64.zip -d $HOME/.local + export PATH="$PATH:$HOME/.local/bin" + + - name: Install dependencies for 22.04 + if: matrix.os == 'ubuntu-22.04' + run: | + sudo apt-get update + sudo apt-get install -y \ + gnupg \ + libudev-dev \ + libsasl2-dev \ + libssl-dev \ + libzstd-dev \ + protobuf-compiler - uses: actions-rs/toolchain@v1 with: @@ -44,6 +67,12 @@ jobs: - name: Build release tarball run: ./ci/create-tarball.sh + - name: Rename binaries for ubuntu22 release + if: matrix.os == 'ubuntu-22.04' + run: | + mv solana-accountsdb-plugin-kafka-release-x86_64-unknown-linux-gnu.tar.bz2 solana-accountsdb-plugin-kafka-release22-x86_64-unknown-linux-gnu.tar.bz2 + mv solana-accountsdb-plugin-kafka-release-x86_64-unknown-linux-gnu.yml solana-accountsdb-plugin-kafka-release22-x86_64-unknown-linux-gnu.yml + - name: Release uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/') @@ -53,4 +82,4 @@ jobs: solana ${{ env.SOLANA_VERSION }} rust ${{ env.RUST_STABLE }} files: | - solana-accountsdb-plugin-kafka-release-* + solana-accountsdb-plugin-kafka-release* diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1f93a04..41505b1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,26 +3,53 @@ on: push: - pull_request: env: CARGO_TERM_COLOR: always jobs: test: - runs-on: ubuntu-latest + strategy: + matrix: + os: [ubuntu-20.04, ubuntu-22.04] + runs-on: ["${{ matrix.os }}"] steps: - uses: actions/checkout@v2 - name: Set env vars run: | - source ci/rust-version.sh + rust_stable=$(rustc --version | awk '{print $2}') echo "RUST_STABLE=$rust_stable" | tee -a $GITHUB_ENV - - if: runner.os == 'Linux' + - name: instal dependencies for 20.04 + if: matrix.os == 'ubuntu-20.04' run: | sudo apt-get update - sudo apt-get install -y libudev-dev libssl-dev libsasl2-dev libzstd-dev + sudo apt-get install -y \ + gnupg \ + libudev-dev \ + libsasl2-dev \ + libssl-dev \ + libzstd-dev + + - name: install protobuff 3.12 + if: matrix.os == 'ubuntu-20.04' + run: | + curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v3.15.8/protoc-3.15.8-linux-x86_64.zip + unzip protoc-3.15.8-linux-x86_64.zip -d $HOME/.local + export PATH="$PATH:$HOME/.local/bin" + + - name: Install dependencies for 22.04 + if: matrix.os == 'ubuntu-22.04' + run: | + sudo apt-get update + sudo apt-get install -y \ + gnupg \ + libudev-dev \ + libsasl2-dev \ + libssl-dev \ + libzstd-dev \ + protobuf-compiler - uses: actions-rs/toolchain@v1 with: @@ -31,12 +58,12 @@ jobs: profile: minimal components: rustfmt, clippy - - uses: actions/cache@v2 + - uses: actions/cache@v3 with: path: | ~/.cargo/registry ~/.cargo/git - key: cargo-build-${{ hashFiles('**/Cargo.lock') }}-${{ env.RUST_STABLE}} + key: ${{ matrix.os }}-cargo-build-${{ hashFiles('**/Cargo.lock', 'rust-toolchain.toml') }}-${{ env.RUST_STABLE }} - name: cargo fmt uses: actions-rs/cargo@v1 diff --git a/ci/cargo-build-test.sh b/ci/cargo-build-test.sh index 7878de8..b8b4c77 100755 --- a/ci/cargo-build-test.sh +++ b/ci/cargo-build-test.sh @@ -6,14 +6,13 @@ 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 +rust_stable=$(rustc --version | awk '{print $2}') cargo +"$rust_stable" build cargo +"$rust_stable" test -- --nocapture diff --git a/ci/create-tarball.sh b/ci/create-tarball.sh index a7507a1..95c4460 100755 --- a/ci/create-tarball.sh +++ b/ci/create-tarball.sh @@ -40,7 +40,6 @@ echo --- Creating release tarball # 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}" diff --git a/ci/rust-version.sh b/ci/rust-version.sh deleted file mode 100755 index dc871e6..0000000 --- a/ci/rust-version.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/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.60.0 -fi - -if [[ -n $RUST_NIGHTLY_VERSION ]]; then - nightly_version="$RUST_NIGHTLY_VERSION" -else - nightly_version=2022-04-01 -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 -)