From f25415396205f50de45a2513f492f826383cb0c5 Mon Sep 17 00:00:00 2001 From: Paul Ritter Date: Tue, 10 May 2022 10:58:42 +0200 Subject: [PATCH] benchmark script (#2745) * benchmark script * more changes * oopsie * adjust workflow * Put a concurrency limit on the benchmarks action * Update run_benchmarks.py Co-authored-by: Paul Co-authored-by: Pieter-Jan Briers --- .github/workflows/benchmarks.yml | 36 ++++++++++++++++---------------- Tools/run_benchmarks.py | 34 ++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 18 deletions(-) create mode 100644 Tools/run_benchmarks.py diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index 6de068153..a6830b198 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -1,11 +1,12 @@ name: Benchmarks -#on: -# push - #schedule: - # - cron: '0 5 * * *' - #push: - # tags: - # - 'v*' +on: + schedule: + - cron: '0 5 * * *' + push: + tags: + - 'v*' + +concurrency: benchmarks env: ROBUST_BENCHMARKS_ENABLE_SQL: 1 @@ -20,14 +21,13 @@ jobs: name: Run Benchmarks runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - with: - submodules: true - - name: Setup .NET Core - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 6.0.x - - name: Install dependencies - run: dotnet restore - - name: Run benchmark - run: cd Robust.Benchmarks && sudo dotnet run --filter '*' --configuration Release + - name: Run script on centcomm + uses: appleboy/ssh-action@master + with: + host: centcomm.spacestation14.io + username: robust-benchmark-runner + key: ${{ secrets.CENTCOMM_ROBUST_BENCHMARK_RUNNER_KEY }} + script: | + wget https://github.com/space-wizards/RobustToolbox/blob/master/Tools/run_benchmarks.py + python3 run_benchmarks.py ${{ secrets.BENCHMARKS_WRITE_ADDRESS }} ${{ secrets.BENCHMARKS_WRITE_PORT }} ${{ secrets.BENCHMARKS_WRITE_USER }} ${{ secrets.BENCHMARKS_WRITE_PASSWORD }} $GITHUB_SHA + rm run_benchmarks.py diff --git a/Tools/run_benchmarks.py b/Tools/run_benchmarks.py new file mode 100644 index 000000000..84368cd5e --- /dev/null +++ b/Tools/run_benchmarks.py @@ -0,0 +1,34 @@ +from argparse import ArgumentParser +from os import nice, environ +from subprocess import run +from shutil import rmtree + +parser = ArgumentParser() +parser.add_argument("address", type=str) +parser.add_argument("port", type=int) +parser.add_argument("user", type=str) +parser.add_argument("pwd", type=str) +parser.add_argument("commit", type=str) +parser.add_argument("--database", type=str, default="benchmarks") +parser.add_argument("--repo", type=str, default="https://github.com/space-wizards/RobustToolbox.git") +parser.add_argument("--project", type=str, default="Robust.Benchmarks") + +args = parser.parse_args() + +run(f"git clone {args.repo} repo_dir", shell=True) +run(f"git checkout {args.commit}", shell=True) +run("git submodule update --init --recursive", cwd="repo_dir", shell=True) +run("dotnet restore", cwd="repo_dir/Robust.Benchmarks", shell=True) +run("dotnet run --filter '*' --configuration Release", + cwd=f"repo_dir/{args.project}", + shell=True, + env=environ | { + "ROBUST_BENCHMARKS_ENABLE_SQL": "1", + "ROBUST_BENCHMARKS_SQL_ADDRESS": args.address, + "ROBUST_BENCHMARKS_SQL_PORT": str(args.port), + "ROBUST_BENCHMARKS_SQL_USER": args.user, + "ROBUST_BENCHMARKS_SQL_PASSWORD": args.pwd, + "ROBUST_BENCHMARKS_SQL_DATABASE": args.database, + "GITHUB_SHA": args.commit + }) +rmtree("repo_dir")