From f1713f6fdcf4059df5b78b665ee5196319aebde3 Mon Sep 17 00:00:00 2001 From: Touseef Liaqat Date: Wed, 21 Jun 2023 16:14:12 -0700 Subject: [PATCH] Github action to run vault perf test and publish results to datadog --- .github/actions/publish-metric/action.yml | 52 +++++++++++++++++++++++ .github/workflows/benchmarks.yml | 36 ++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 .github/actions/publish-metric/action.yml create mode 100644 .github/workflows/benchmarks.yml diff --git a/.github/actions/publish-metric/action.yml b/.github/actions/publish-metric/action.yml new file mode 100644 index 00000000000..e3ba069fd0d --- /dev/null +++ b/.github/actions/publish-metric/action.yml @@ -0,0 +1,52 @@ +name: Publish Datadog Metric +description: GitHub Action to publish a metric to DD. + +inputs: + datadog-token: + description: 'secret datadog API token' + required: true + metric: + description: 'metric name for datadog' + required: true + metric-value: + description: 'metric value for datadog' + required: true + +runs: + using: 'composite' + steps: + - name: Publish Given Metric to Datadog using API. + shell: bash + id: publish_metric + env: + DATADOG_API_KEY: ${{ inputs.datadog-token }} + VALUE: ${{ inputs.metric-value }} + METRIC: ${{ inputs.metric }} + run: | + export NOW="$(date +%s)" + curl -v POST "https://api.us3.datadoghq.com/api/v1/series" \ + -H "Content-Type: application/json" \ + -H "DD-API-KEY: $DATADOG_API_KEY" \ + -d @- << EOF + { + "series": [{ + "metric": "ci.${METRIC}", + "points": [ + [ + $NOW, + $VALUE + ] + ], + "tags": [ + "os:${{ runner.os }}", + "arch:${{ runner.arch }}", + "repo:${{ github.repository }}", + "job:${{ github.job }}", + "workflow:${{ github.workflow }}", + "source:Github Actions", + "branch:${GITHUB_REF##*/}" + ], + "type": "gauge" + }] + } + EOF diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml new file mode 100644 index 00000000000..550533f6998 --- /dev/null +++ b/.github/workflows/benchmarks.yml @@ -0,0 +1,36 @@ +name: Run Benchmarks + +# run on changes to trunk, and also nightly + +on: + push: + branches: [master] + schedule: + # Run an hour after the daily test-all-packages.yml job, so it can + # populate the build caches + - cron: '47 6 * * *' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + benchmark: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/restore-node + with: + node-version: '18.x' + + - name: yarn bench (vats) + shell: bash + run: | + cd packages/vats && yarn bench + echo "METRIC_VALUE=`cat benchmark-stress-vaults.json | jq .avgPerVaultMs`" >> $GITHUB_ENV + + - uses: ./.github/actions/publish-metric + with: + metric: 'vats.perf.avgPerVaultMs' + metric-value: ${{env.METRIC_VALUE}} + datadog-token: ${{ secrets.DATADOG_API_KEY }}