Skip to content

Commit

Permalink
Update benchmark workflow (#510)
Browse files Browse the repository at this point in the history
* Update Makefile

* Update release

* Update

* Updating release

* Added runtime check

* Consolidate all branches into main

* Update check_runtime

* update benchmark workflow

* fix makefile

* diff base branch

* diff base branch

* diff base branch

* fix makefile

* github.ref

* i give up

* show-current

* use commit sha

* fetch main branch

* try again

Co-authored-by: Seun Lanlege <seunlanlege@gmail.com>
  • Loading branch information
haroldsphinx and seunlanlege authored Jan 19, 2022
1 parent a8c5bfb commit d8c6701
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 56 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Run Benchmark

on:
workflow_dispatch:

jobs:
benchmark:
name: Benchmark
runs-on:
- self-hosted
- linux
- x64
- bmark
if: github.event.pull_request.draft == false
steps:
- uses: actions/checkout@v2
with:
ref: main

- name: Check for runtime changes
env:
BASE_BRANCH: ${{ github.event.pull_request.base.ref }}
id: check_runtime
run: .maintain/check_runtime.sh

- name: Benchmark Test
env:
BASE_BRANCH: ${{ github.event.pull_request.base.ref }}
if: "$${{ env.RUNTIME_CHECK }} == 1"
id: run_benchmarks
run: .maintain/run_benchmarks.sh
5 changes: 4 additions & 1 deletion .github/workflows/build-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
push:
branches:
- fix-release
- update-benchmark-workflow
tags:
- '*'

Expand Down Expand Up @@ -42,6 +42,9 @@ jobs:
run: |
.maintain/client_release.sh
- name: Echo Output
run: echo $${{ env.picasso-wasm }}

- name: Build wasm with srtool
id: runtime_release
run: |
Expand Down
21 changes: 10 additions & 11 deletions .github/workflows/picashot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ jobs:
ansible-playbook -l _mainnet_collator_yes picashot.yml -i picasso-gcp.yaml --user root -e 'ansible_python_interpreter=/usr/bin/python3'
dalishot:
runs-on:
- self-hosted
- linux
- X64
- ansible-runner

steps:
- name: Run ansible playbook
working-directory: "./.maintain/playbooks"
run: |
ansible-playbook -l _collator_node_yes picashot.yml -i gcp.yaml --user runner -e 'ansible_python_interpreter=/usr/bin/python3'
runs-on:
- self-hosted
- linux
- X64
- ansible-runner

steps:
- name: Run ansible playbook
working-directory: "./.maintain/playbooks"
run: |
ansible-playbook -l _collator_node_yes picashot.yml -i gcp.yaml --user runner -e 'ansible_python_interpreter=/usr/bin/python3'
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
name: Check Runtime
name: Run Simnode
on:
push:
branches:
- releases
- main
pull_request:
branches:
- releases
- main
jobs:
check-runtime:
simnode:
runs-on:
- self-hosted
- linux
Expand All @@ -19,34 +15,20 @@ jobs:
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
ref: main

- name: Check for runtime changes
id: check_runtime
env:
BASE_BRANCH: ${{ github.event.pull_request.base.ref }}
run: .maintain/check_runtime.sh

- name: Echo output
run: echo ${{ env.RUNTIME_CHECK }}

- name: Run Simnode
env:
BASE_BRANCH: ${{ github.event.pull_request.base.ref }}
if: "$${{ env.RUNTIME_CHECK }} == 1"
id: run_simnode
run: .maintain/run_simnode.sh

benchmark:
name: Benchmark
runs-on:
- self-hosted
- linux
- x64
- bmark
if: github.event.pull_request.draft == false
steps:
- uses: actions/checkout@v2
- name: Benchmark Test
if: "$${{ env.RUNTIME_CHECK }} == 1"
id: run_benchmarks
run: .maintain/run_benchmarks.sh



7 changes: 2 additions & 5 deletions .maintain/check_runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,11 @@ VERSIONS_FILES=(
git log --graph --oneline --decorate=short -n 10

echo "make sure the main branch and release tag are available in shallow clones"
git fetch --depth="${GIT_DEPTH:-100}" origin main
git fetch --depth="${GIT_DEPTH:-100}" origin "${LATEST_TAG_NAME}"
git tag -f "${LATEST_TAG_NAME}" FETCH_HEAD
git log -n1 "${LATEST_TAG_NAME}"
git fetch --depth="${GIT_DEPTH:-100}" origin "${BASE_BRANCH}"

simnode_check() {
VERSIONS_FILE="$1"
if has_runtime_changes "${LATEST_TAG_NAME}" "${GITHUB_REF_NAME}" "$3" && check_runtime "$VERSIONS_FILE" "$2"
if has_runtime_changes "${BASE_BRANCH}" "${GITHUB_REF_NAME}" "$3" && check_runtime "$VERSIONS_FILE" "$2"
then
echo "Wasm sources have changed"
echo "RUNTIME_CHECK=1" >> "$GITHUB_ENV"
Expand Down
2 changes: 1 addition & 1 deletion .maintain/client_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
RELEASE_VERSION=$(git tag --sort=committerdate | grep -E '^v[0-9]' | tail -1 )


if has_client_changes "${LATEST_TAG_NAME}" "${GITHUB_REF_NAME}"
if has_client_changes "${BASE_BRANCH}" "${GITHUB_REF_NAME}"
then
boldprint "Building new client binaries"
cargo build --release -p composable
Expand Down
9 changes: 8 additions & 1 deletion .maintain/common/lib.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

api_base="https://api.github.com/repos"
GITHUB_REF_NAME=$(git rev-parse --abbrev-ref HEAD)
GITHUB_REF_NAME=$(git rev-parse HEAD)

# Function to take 2 git tags/commits and get any lines from commit messages
# that contain something that looks like a PR reference: e.g., (#1234)
Expand All @@ -22,6 +22,13 @@ get_latest_release() {
}
LATEST_TAG_NAME=$(get_latest_release ComposableFi/composable)

if [[ $BASE_BRANCH == "releases" ]] # this is a pr to the releases branch, use the latest tag instead
then
BASE_BRANCH=$LATEST_TAG_NAME
git tag -f "${BASE_BRANCH}" FETCH_HEAD
git log -n1 "${BASE_BRANCH}"
fi

# Returns the last published release on github
# Note: we can't just use /latest because that ignores prereleases
# repo: 'organization/repo'
Expand Down
9 changes: 1 addition & 8 deletions .maintain/run_benchmarks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@ pallets=(
dutch_auction
)

echo "make sure the main branch and release tag are available in shallow clones"
git fetch --depth="${GIT_DEPTH:-100}" origin main
git fetch --depth="${GIT_DEPTH:-100}" origin "${LATEST_TAG_NAME}"
git tag -f "${LATEST_TAG_NAME}" FETCH_HEAD
git log -n1 "${LATEST_TAG_NAME}"


/home/runner/.cargo/bin/rustup install nightly
/home/runner/.cargo/bin/rustup target add wasm32-unknown-unknown --toolchain nightly
/home/runner/.cargo/bin/cargo build --release -p composable --features=runtime-benchmarks
Expand Down Expand Up @@ -78,7 +71,7 @@ run_benchmarks() {

for i in "${VERSIONS_FILES[@]}"; do
while IFS=',' read -r output chain folder; do
if has_runtime_changes "${LATEST_TAG_NAME}" "${GITHUB_REF_NAME}" "$folder"; then
if has_runtime_changes "${BASE_BRANCH}" "${GITHUB_REF_NAME}" "$folder"; then
run_benchmarks $output $chain $folder
fi
done <<<"$i"
Expand Down
2 changes: 1 addition & 1 deletion .maintain/run_simnode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ run_simnode() {
for i in "${VERSIONS_FILES[@]}"; do
while IFS=',' read -r chain folder; do
echo "check if the wasm sources changed for $chain"
if has_runtime_changes "${LATEST_TAG_NAME}" "${GITHUB_REF_NAME}" "$folder"; then
if has_runtime_changes "${BASE_BRANCH}" "${GITHUB_REF_NAME}" "$folder"; then
# shellcheck disable=SC2086
run_simnode $chain
fi
Expand Down
3 changes: 2 additions & 1 deletion .maintain/runtime_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ build_runtime () {
for i in "${VERSIONS_FILES[@]}"; do
while IFS=',' read -r output chain folder; do
echo "check if the wasm sources changed for $chain"
if has_runtime_changes "${LATEST_TAG_NAME}" "${GITHUB_REF_NAME}" "$folder"
if has_runtime_changes "${BASE_BRANCH}" "${GITHUB_REF_NAME}" "$folder"
then
build_runtime $output $chain $folder

echo "$chain-wasm=1" >> "$GITHUB_ENV"
fi
done <<< "$i"
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ REPO=composablefi
SERVICE_NAME=composable
INSTALL_DIR=docker/
IMAGE_URL:=${REPO}/${SERVICE_NAME}
RELEASE_VERSION:=$(shell git tag --sort=committerdate | grep -E '^v[0-9]' | tail -1)
CARGO_VERSION:=$(shell git tag --sort=committerdate | grep -E '^v[0-9]' | tail -1 | cut -c2-)
RELEASE_VERSION:=$(shell git tag --sort=committerdate | grep -E '^[0-9]' | tail -1)
CARGO_VERSION:=$(sed -i '' "s|^version =.*|version = "${VERSION}"|" node/Cargo.toml)
AUTO_UPDATE:=1


Expand Down

0 comments on commit d8c6701

Please sign in to comment.