Skip to content

Commit

Permalink
adding benchmark execution time github action
Browse files Browse the repository at this point in the history
  • Loading branch information
tommady committed Nov 15, 2021
1 parent ba08bb3 commit 363b094
Showing 1 changed file with 138 additions and 0 deletions.
138 changes: 138 additions & 0 deletions .github/workflows/benchmark_execution_time.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
name: Benchmark execution time comparison with the main branch

on:
pull_request:
branches: [main]

jobs:
building-pr-branch:
if: contains( github.event.pull_request.labels.*.name, 'benchmark-exec-time' )
runs-on: ubuntu-latest

steps:
- name: Checkout to PR branch
uses: actions/checkout@v2

- name: Setup Linux env
run: |
sudo apt -y update
sudo apt install libsystemd-dev librust-libdbus-sys-dev libseccomp-dev
- name: Setting rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
profile: minimal

- name: Building PR branch
run: ./build.sh --release

- name: Uploading PR build to artifact
uses: actions/upload-artifact@v2
with:
name: pr-youki
path: ./youki

building-main-branch:
if: contains( github.event.pull_request.labels.*.name, 'benchmark-exec-time' )
runs-on: ubuntu-latest

steps:
- name: Checkout to main branch
uses: actions/checkout@v2
with:
ref: main

- name: Setup Linux env
run: |
sudo apt -y update
sudo apt install libsystemd-dev librust-libdbus-sys-dev libseccomp-dev
- name: Setting rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
profile: minimal

- name: Building main branch
run: ./build.sh --release

- name: Uploading main build to artifact
uses: actions/upload-artifact@v2
with:
name: main-youki
path: ./youki

benchmark-exec:
if: contains( github.event.pull_request.labels.*.name, 'benchmark-exec-time' )
needs:
- building-pr-branch
- building-main-branch
runs-on: ubuntu-latest

steps:
- name: Setup Linux env
run: |
sudo apt -y update
sudo apt install jq podman
- name: Checkout to PR branch
uses: actions/checkout@v2

- name: Downloading PR build from artifact
uses: actions/download-artifact@v2
with:
name: pr-youki
path: ./pr_youki

- name: Downloading main build from artifact
uses: actions/download-artifact@v2
with:
name: main-youki
path: ./main_youki

- name: Preparing binaries
run: |
mv ./main_youki/youki ./youki_main
mv ./pr_youki/youki ./youki_pr
chmod +x ./youki_main
chmod +x ./youki_pr
- name: Preparing benchmark bundle
run: |
mkdir -p ./benchmark_exec_bundle/rootfs
cd benchmark_exec_bundle
sudo bash -c 'podman export $(podman create busybox) | tar -C rootfs -xvf -'
../youki_main spec
sed -i 's/"sh"/"sh", "-c", "echo Hi, my PID is $$; echo Bye Bye"/' config.json
sed -i 's/"terminal": true/"terminal": false/' config.json
- name: Installing hyperfine
run: |
curl -s https://api.github.com/repos/sharkdp/hyperfine/releases/latest \
| jq -r '.assets[] | select(.name? | match("hyperfine-musl_.*_amd64.deb")) | .browser_download_url' \
| wget -qi -
sudo dpkg -i *.deb
- name: Running benchmark
run: |
hyperfine --prepare 'sudo sync; echo 3 | sudo tee /proc/sys/vm/drop_caches' \
--export-markdown bench_exec_result.md \
--warmup 10 \
--min-runs 100 \
--command-name 'main youki build' \
'sudo ./youki_main run -b benchmark_exec_bundle main_container && sudo ./youki_main delete -f main_container' \
--command-name 'pr youki build' \
'sudo ./youki_pr run -b benchmark_exec_bundle pr_container && sudo ./youki_pr delete -f pr_container'
- name: Adding info into result
run: |
sed -i '1i > commit (${{ github.sha }})\n' bench_exec_result.md
- name: Writting report to PR comment
uses: marocchino/sticky-pull-request-comment@v2
with:
append: true
path: ./bench_exec_result.md

0 comments on commit 363b094

Please sign in to comment.