Skip to content

Commit

Permalink
Adding auto benchmark workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
merschformann committed Dec 16, 2024
1 parent 8937c46 commit 183e41a
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
31 changes: 31 additions & 0 deletions .github/workflows/auto-benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: auto benchmark
on: [push]

env:
GO_VERSION: 1.23
PYTHON_VERSION: 3.12

jobs:
python-test:
runs-on: ubuntu-latest
steps:
- name: git clone
uses: actions/checkout@v4

- name: set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- name: set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: install dependencies
run: |
python -m pip install --upgrade pip
pip install -r .nextmv/benchmark.requirements.txt
- name: run acceptance test
run: python .nextmv/benchmark.py
21 changes: 20 additions & 1 deletion .nextmv/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@
import subprocess
from datetime import datetime, timezone

import requests
from nextmv import cloud

APP_ID = "nextroute-bench"
API_KEY = os.environ["NEXTMV_API_KEY"]
API_KEY = os.environ["BENCHMARK_API_KEY_PROD"]
SLACK_WEBHOOK = os.getenv("SLACK_URL_DEV_SCIENCE", None)
BRANCH_NAME = os.getenv("BRANCH_NAME", None)


METRICS = [
Expand Down Expand Up @@ -139,6 +142,22 @@ def main():
passed = "passed" if result.results.passed else "failed"
print(f"Acceptance test completed with status: {passed}")

if SLACK_WEBHOOK and BRANCH_NAME == "develop":
print("Posting to Slack...")
response = requests.post(
SLACK_WEBHOOK,
json={
"text": f"Acceptance test {result.id} completed with status: {passed}",
},
)

if response.status_code != 200:
print(f"Failed to send notification to Slack: {response.text}")
else:
print("Notification sent to Slack")

print("Done")


if __name__ == "__main__":
main()
2 changes: 2 additions & 0 deletions .nextmv/benchmark.requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
nextmv>=0.14.1
requests>=2.32.3

0 comments on commit 183e41a

Please sign in to comment.