Migrate nightly benchmarks to GH Actions #28
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: benchmarks | |
on: | |
schedule: | |
- cron: '0 17 * * *' | |
pull_request: # TODO Remove again | |
env: | |
PNG_REPORT_FILE: out.png | |
BENCHMARK_RESULT: benchmark-result.txt | |
WORKING_DIRECTORY: testing/benchmark | |
jobs: | |
benchmarks: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ${{ env.WORKING_DIRECTORY }} | |
env: | |
SSH_KEY: ./id_rsa_terraform | |
TF_VAR_private_key: ./id_rsa_terraform | |
TF_VAR_public_key: ./id_rsa_terraform.pub | |
TFVARS_SOURCE: "system-profiles/8GBx1zone.tfvars" # // Default to use an 8gb profile | |
TF_VAR_BUILD_ID: ${{ github.run_id }} | |
TF_VAR_ENVIRONMENT: ci | |
TF_VAR_REPO: ${{ github.repository }} | |
GOBENCH_TAGS: branch=${{ github.head_ref || github.ref }},commit=${{ github.sha }},target_branch=${{ github.base_ref }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-go@v4 | |
with: | |
go-version-file: 'go.mod' | |
- uses: rlespinasse/github-slug-action@d1ca8ffbce40ea2371e35bca356db0acacf567d2 | |
- name: Set up env | |
run: | | |
SLUGGED_BRANCH_NAME=${{ env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }} | |
CREATED_AT=$(date +%s) | |
echo "TF_VAR_BRANCH=${SLUGGED_BRANCH_NAME}" >> "$GITHUB_ENV" | |
echo "TF_VAR_CREATED_AT=${CREATED_AT}" >> "$GITHUB_ENV" | |
echo "USER=benchci-$SLUGGED_BRANCH_NAME-$CREATED_AT" >> "$GITHUB_ENV" | |
- uses: elastic/apm-pipeline-library/.github/actions/docker-login@main | |
with: | |
registry: docker.elastic.co | |
secret: secret/observability-team/ci/docker-registry/prod | |
url: ${{ secrets.VAULT_ADDR }} | |
roleId: ${{ secrets.VAULT_ROLE_ID }} | |
secretId: ${{ secrets.VAULT_SECRET_ID }} | |
- uses: hashicorp/vault-action@v2.6.0 | |
with: | |
url: ${{ secrets.VAULT_ADDR }} | |
roleId: ${{ secrets.VAULT_ROLE_ID }} | |
secretId: ${{ secrets.VAULT_SECRET_ID }} | |
method: approle | |
secrets: | | |
secret/observability-team/ci/elastic-observability-aws-account-auth access_key | AWS_ACCESS_KEY_ID ; | |
secret/observability-team/ci/elastic-observability-aws-account-auth secret_key | AWS_SECRET_ACCESS_KEY ; | |
secret/observability-team/ci/benchmark-cloud user | GOBENCH_USERNAME ; | |
secret/observability-team/ci/benchmark-cloud password | GOBENCH_PASSWORD ; | |
secret/observability-team/ci/benchmark-cloud url | GOBENCH_HOST ; | |
secret/observability-team/ci/elastic-cloud/observability-pro apiKey | EC_API_KEY ; | |
secret/observability-team/ci/apm-benchmark-kibana user | KIBANA_USERNAME ; | |
secret/observability-team/ci/apm-benchmark-kibana password | KIBANA_PASSWORD ; | |
secret/observability-team/ci/apm-benchmark-kibana kibana_url | KIBANA_ENDPOINT ; | |
secret/observability-team/ci/apm-benchmark-kibana kibana_dashboard_url | KIBANA_DASHBOARD_URL ; | |
secret/observability-team/ci/stack-integartion-token integration_token | SLACK_BOT_TOKEN ; | |
- uses: hashicorp/setup-terraform@v2 | |
with: | |
terraform_version: 1.3.7 | |
terraform_wrapper: false | |
# - name: Build apmbench | |
# run: make apmbench $SSH_KEY terraform.tfvars | |
# - name: Spin up benchmark environment | |
# run: make docker-override-committed-version init apply; echo "-> infra setup done" | |
# - name: Run benchmarks | |
# run: make run-benchmark-autotuned index-benchmark-results | |
# - if: always() | |
# run: ls -la | |
- run: echo ${{ github.workspace }} | |
- name: Download PNG | |
run: >- | |
${{ github.workspace }}/.ci/scripts/download-png-from-kibana.sh | |
$KIBANA_ENDPOINT | |
$KIBANA_USERNAME | |
$KIBANA_PASSWORD | |
$PNG_REPORT_FILE | |
- id: base64_image_string | |
run: | |
echo "base64_image_string=$(cat ${{ env.WORKING_DIRECTORY }}/${{ env.PNG_REPORT_FILE }} | base64)" >> "$GITHUB_OUTPUT" | |
- name: Upload PNG | |
uses: actions/upload-artifact@v3 | |
with: | |
name: kibana-png-report | |
path: ${{ env.WORKING_DIRECTORY }}/${{ env.PNG_REPORT_FILE }} | |
if-no-files-found: error | |
- name: Upload PNG to AWS S3 | |
id: s3-upload-png | |
run: | | |
DEST_NAME="github-run-id-${{ github.run_id }}.png" | |
aws s3 cp ${{ env.WORKING_DIRECTORY }}/${{ env.PNG_REPORT_FILE }} s3://elastic-apm-server-benchmark-reports/${DEST_NAME} | |
echo "png_report_url=https://elastic-apm-server-benchmark-reports.s3.amazonaws.com/${DEST_NAME}" >> "$GITHUB_OUTPUT" | |
# - name: Upload benchmark result | |
# uses: actions/upload-artifact@v3 | |
# if: always() | |
# with: | |
# name: benchmark-result | |
# path: ${{ env.WORKING_DIRECTORY }}/${{ env.BENCHMARK_RESULT }} | |
# if-no-files-found: error | |
# - name: Tear down benchmark environment | |
# if: always() | |
# run: make destroy | |
- if: failure() | |
uses: elastic/apm-pipeline-library/.github/actions/notify-build-status@current | |
with: | |
vaultUrl: ${{ secrets.VAULT_ADDR }} | |
vaultRoleId: ${{ secrets.VAULT_ROLE_ID }} | |
vaultSecretId: ${{ secrets.VAULT_SECRET_ID }} | |
slackChannel: "#observablt-bots" | |
- name: Post to a Slack channel | |
id: slack | |
uses: slackapi/slack-github-action@v1.24.0 | |
with: | |
# Slack channel id, channel name, or user id to post message. | |
# See also: https://api.slack.com/methods/chat.postMessage#channels | |
channel-id: '#observablt-bots' | |
# For posting a rich message using Block Kit | |
payload: | | |
{ | |
"text": "GitHub Action build result: ${{ job.status }}\n${{ github.event.pull_request.html_url || github.event.head_commit.url }}", | |
"blocks": [ | |
{ | |
"type": "image", | |
"image_url": "${{ steps.s3-upload-png.outputs.png_report_url }}", | |
"alt_text": "ok" | |
}, | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": "GitHub Action build result: ${{ job.status }}\n${{ github.event.pull_request.html_url || github.event.head_commit.url }}" | |
} | |
} | |
] | |
} |