From 56a04f945eaf7a7f28ff12fb800c3e956eda6270 Mon Sep 17 00:00:00 2001 From: Jan Calanog Date: Thu, 10 Oct 2024 18:09:06 +0200 Subject: [PATCH] ci: fix benchmarks cleanup (#14334) * ci: fix benchmarks cleanup * ok * test * uncomment again (cherry picked from commit 9499f3dea83d007eebc7f4bc2e0c71686577699b) # Conflicts: # .github/workflows/benchmarks.yml --- .github/workflows/benchmarks.yml | 73 ++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index eda117cdc7a..e226c289a83 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -44,6 +44,11 @@ jobs: SSH_KEY: ./id_rsa_terraform TF_VAR_private_key: ./id_rsa_terraform TF_VAR_public_key: ./id_rsa_terraform.pub +<<<<<<< HEAD +======= + TF_VAR_run_standalone: ${{ inputs.runStandalone || github.event.schedule=='0 5 */5 * *' }} + RUN_STANDALONE: ${{ inputs.runStandalone || github.event.schedule=='0 5 */5 * *' }} +>>>>>>> 9499f3dea (ci: fix benchmarks cleanup (#14334)) TFVARS_SOURCE: ${{ inputs.profile || 'system-profiles/8GBx1zone.tfvars' }} # // Default to use an 8gb profile TF_VAR_BUILD_ID: ${{ github.run_id }} TF_VAR_ENVIRONMENT: ci @@ -115,7 +120,10 @@ jobs: admin_console_url=$(terraform output -raw admin_console_url) echo "admin_console_url=$admin_console_url" >> "$GITHUB_OUTPUT" echo "-> infra setup done" +<<<<<<< HEAD +======= +>>>>>>> 9499f3dea (ci: fix benchmarks cleanup (#14334)) - name: Run benchmarks autotuned if: ${{ inputs.benchmarkAgents == '' }} run: make run-benchmark-autotuned index-benchmark-results @@ -156,6 +164,71 @@ jobs: path: ${{ env.WORKING_DIRECTORY }}/${{ env.BENCHMARK_RESULT }} if-no-files-found: error +<<<<<<< HEAD +======= + # The next section injects CPU profile collected by apmbench into the build. + # By copying the profile, uploading it to the artifacts and pushing it + # via a PR to update default.pgo. + + - name: Copy CPU profile + run: make cp-cpuprof + + - name: Upload CPU profile + uses: actions/upload-artifact@v4 + with: + name: cpu-profile + path: ${{ env.WORKING_DIRECTORY }}/${{ env.BENCHMARK_CPU_OUT }} + if-no-files-found: error + + - name: Get token + id: get_token + uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0 + with: + app_id: ${{ secrets.OBS_AUTOMATION_APP_ID }} + private_key: ${{ secrets.OBS_AUTOMATION_APP_PEM }} + permissions: >- + { + "contents": "write", + "pull_requests": "write" + } + + # Required to use a service account, otherwise PRs created by + # GitHub bot won't trigger any CI builds. + # See https://github.com/peter-evans/create-pull-request/issues/48#issuecomment-537478081 + - name: Configure git user + uses: elastic/oblt-actions/git/setup@v1 + with: + github-token: ${{ steps.get_token.outputs.token }} + + - name: Import GPG key + uses: crazy-max/ghaction-import-gpg@01dd5d3ca463c7f10f7f4f7b4f177225ac661ee4 # v6.1.0 + with: + gpg_private_key: ${{ secrets.APM_SERVER_RELEASE_GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.APM_SERVER_RELEASE_PASSPHRASE }} + git_user_signingkey: true + git_commit_gpgsign: true + + - name: Open PGO PR + if: ${{ env.RUN_STANDALONE == 'true' }} + run: ${{ github.workspace }}/.ci/scripts/push-pgo-pr.sh + env: + WORKSPACE_PATH: ${{ github.workspace }} + PROFILE_PATH: ${{ env.WORKING_DIRECTORY }}/${{ env.BENCHMARK_CPU_OUT }} + GITHUB_TOKEN: ${{ steps.get_token.outputs.token }} + WORKFLOW: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }} + + # Secrets are rotated daily, if the benchmarks run between the rotation window, then + # there is a high chance things will stop working + # This is trying to reduce the chances of that happening. + # See https://github.com/elastic/observability-test-environments/actions/workflows/cluster-rotate-api-keys.yml + - uses: google-github-actions/get-secretmanager-secrets@95a0b09b8348ef3d02c68c6ba5662a037e78d713 # v2.1.4 + if: always() + with: + export_to_environment: true + secrets: |- + EC_API_KEY:elastic-observability/elastic-cloud-observability-team-pro-api-key + +>>>>>>> 9499f3dea (ci: fix benchmarks cleanup (#14334)) - name: Tear down benchmark environment if: always() run: make destroy