Skip to content

Commit

Permalink
updating ci pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
Juanito87 committed Oct 12, 2023
1 parent 87a4071 commit 4a7b7dc
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 128 deletions.
140 changes: 60 additions & 80 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,90 +1,70 @@
name: Publish plerkle plugin

on:
workflow_dispatch:
push:
tags:
- "v*"
- 'v*'

env:
CARGO_TERM_COLOR: always
IMAGE_NAME: plerkle-test-validator
RUST_VERSION: 1.69.0
SOLANA_VERSION_STABLE: v1.16.6

jobs:
release-stable:
runs-on: buildjet-8vcpu-ubuntu-2004
build20:

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/env.sh
echo "GEYSER_PLUGIN_NAME=$plugin_name" | tee -a $GITHUB_ENV
echo "GEYSER_PLUGIN_LIB=lib${plugin_lib_name}" | tee -a $GITHUB_ENV
- if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get upgrade
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-add-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main"
sudo apt-get update
sudo apt-get install -y libudev-dev libssl-dev libsasl2-dev libzstd-dev
sudo apt-get install -y openssl --allow-unauthenticated
sudo apt-get install -y libssl1.1 --allow-unauthenticated
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_VERSION }}
override: true
profile: minimal
components: rustfmt
- name: Build Plugin
run: |
echo "CI_TAG=${GITHUB_REF#refs/*/}" >> "$GITHUB_ENV"
echo "CI_OS_NAME=linux" >> "$GITHUB_ENV"
cargo build --release
- name: Build release tarball
run: ./ci/create-tarball.sh
- name: Publish to crates registry
run: |
cargo publish -p plerkle_serialization --token $CARGO_TOKEN --no-verify || true
sleep 30
cargo publish -p plerkle_messenger --token $CARGO_TOKEN --no-verify || true
shell: bash
env:
CARGO_TOKEN: ${{ secrets.CARGO_TOKEN }}
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
name: STABLE ${{ env.CI_TAG }}
body: |
## STABLE VERSION:

- name: checkout repo
uses: actions/checkout@v3
with:
submodules: true
lfs: true

- name: set env vars
run: |
source ci/env.sh
echo "RUST_VERSION=$rust_version" | tee -a "$GITHUB_ENV"
echo "RUST_PROFILE=$rust_profile" | tee -a "$GITHUB_ENV"
echo "RUST_COMPONENTS=$rust_components" | tee -a "$GITHUB_ENV"
echo "SOLANA_VERSION=$solana_version" | tee -a "$GITHUB_ENV"
echo "PLUGIN_VERSION=$plugin_version" | tee -a "$GITHUB_ENV"
echo "RELEASE=$release" | tee -a "$GITHUB_ENV"
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_VERSION }}
override: true
profile: ${{ env.RUST_PROFILE }}
components: ${{ env.RUST_COMPONENTS }}

- name: Build plerkle plugin
run: cargo build --verbose --release

- name: Package libplerkle
working-directory: target/release
run: tar -cvjf plerkle-x86_64-unknown-linux-gnu.tar.bz2 libplerkle.so

- name: Package libplerkle22
if: matrix.os == 'ubuntu-22.04'
working-directory: target/release
run: tar -cvjf plerkle2222-x86_64-unknown-linux-gnu.tar.bz2 libplerkle.so

- name: Publish to release
uses: softprops/action-gh-release@v1
with:
name: STABLE ${{ env.RELEASE }}
token: ${{ github.token }}
body: |
## STABLE VERSION:
Reccomended for Mainnet
${{ env.GEYSER_PLUGIN_NAME }} ${{ env.CI_TAG }}
solana ${{ env.SOLANA_VERSION_STABLE }}
${{ env.GEYSER_PLUGIN_NAME }} ${{ env.RELEASE }}
solana ${{ env.SOLANA_VERSION }}
rust ${{ env.RUST_VERSION }}
files: |
${{ env.GEYSER_PLUGIN_NAME }}-release-*
push-stable:
runs-on: ubuntu-latest
needs: release-stable
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v3
- name: Build image
run: docker build . --file Solana.Dockerfile --tag $IMAGE_NAME --label 'runnumber=${GITHUB_RUN_ID}'
- name: Log in to registry
run: echo '${{ secrets.GITHUB_TOKEN }}' | docker login ghcr.io -u $ --password-stdin
- name: Push image Stable
if: startsWith(github.ref, 'refs/tags/')
run: |
CI_TAG=${GITHUB_REF#refs/*/}
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$CI_TAG
echo IMAGE_ID=$IMAGE_ID
export TAG=$VERSION-${{ env.RUST_VERSION }}-${{ env.SOLANA_VERSION_STABLE }}
echo VERSION=$TAG
docker tag $IMAGE_NAME $IMAGE_ID:$TAG
docker push $IMAGE_ID:$TAG
files: |
target/release/plerkle*-x86_64-unknown-linux-gnu.tar.bz2
90 changes: 43 additions & 47 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,52 @@
# Source:
# https://github.com/solana-labs/solana-accountsdb-plugin-postgres/blob/master/.github/workflows/test.yml
name: Build plerkle plugin

on:
workflow_dispatch:
push:
branches:
- main
pull_request:
branches:
- main

env:
CARGO_TERM_COLOR: always
IMAGE_NAME: plerkle-test-validator
RUST_VERSION: 1.69.0
SOLANA_VERSION_STABLE: v1.16.6

jobs:
test-stable:
runs-on: buildjet-4vcpu-ubuntu-2004
build:
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/env.sh
echo "GEYSER_PLUGIN_NAME=$plugin_name" | tee -a $GITHUB_ENV
echo "GEYSER_PLUGIN_LIB=lib${plugin_lib_name}" | tee -a $GITHUB_ENV
- if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get upgrade
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-add-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main"
sudo apt-get update
sudo apt-get install -y libudev-dev libssl-dev libsasl2-dev libzstd-dev
sudo apt-get install -y openssl --allow-unauthenticated
sudo apt-get install -y libssl1.1 --allow-unauthenticated
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_VERSION }}
override: true
profile: minimal
components: rustfmt, clippy
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: cargo-build-${{ hashFiles('**/Cargo.lock') }}-${{ env.RUST_STABLE}}
- name: cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --workspace --all-targets #-- --deny=warnings
- name: Build
run: ./ci/cargo-build-test.sh

- name: checkout repo
uses: actions/checkout@v3
with:
submodules: true
lfs: true

- name: set env vars
run: |
source ci/env.sh
echo "RUST_VERSION=$rust_version" | tee -a "$GITHUB_ENV"
echo "RUST_PROFILE=$rust_profile" | tee -a "$GITHUB_ENV"
echo "RUST_COMPONENTS=$rust_components" | tee -a "$GITHUB_ENV"
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_VERSION }}
override: true
profile: ${{ env.RUST_PROFILE }}
components: ${{ env.RUST_COMPONENTS }}

- name: cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --workspace --all-targets #-- --deny=warnings

- name: cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: -- --nocapture

- name: Build plerkle plugin
run: cargo build --verbose --release
36 changes: 35 additions & 1 deletion ci/env.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
#!/bin/bash
plugin_name=plerkle
#Function definition
readCargoVariable() {
declare variable="$1"
declare Cargo_toml="$2"

while read -r name equals value _; do
if [[ $name = "$variable" && $equals = = ]]; then
echo "${value//\"/}"
return
fi
done < <(cat "$Cargo_toml")
echo "Unable to locate $variable in $Cargo_toml" 1>&2
}

# Variable definition
plugin_name="$(readCargoVariable name plerkle/Cargo.toml)"
plugin_lib_name=plerkle
plugin_version="$(readCargoVariable version plerkle/Cargo.toml)"
targets="$(readCargoVariable targets plerkle/Cargo.toml | sed 's/\[\(.*\)\]/\1/')"

# This mas be a dot separeted value to identify pre-release/build
rust_version="$(readCargoVariable channel rust-toolchain.toml)"
rust_profile="$(readCargoVariable profile rust-toolchain.toml)"
rust_components="$(grep components rust-toolchain.toml | awk -F = '{print $2}' | sed "s/\[//" | sed "s/\]//" | sed "s/\"//g")"

# Validation of solana_version
solana_version="$(grep solana-sdk plerkle/Cargo.toml | awk -F = '{print $4}' | sed 's/\"//g' | sed 's/}//' | sed 's/\=//' | sed 's/ *$//' | sed 's/^[ \t]*//')"
validate=${#solana_version}
if [[ validate -lt 5 ]]
then
solana_version="$(grep solana-sdk plerkle/Cargo.toml | awk -F = '{print $3}' | sed 's/\"//g' | sed 's/}//' | sed 's/\~//' | sed 's/ *$//' | sed 's/^[ \t]*//')"
fi


build_meta=solana"$solana_version"
release=$plugin_version

0 comments on commit 4a7b7dc

Please sign in to comment.