From 2085acd097ce041439f557e72ae30403d4ce10b0 Mon Sep 17 00:00:00 2001 From: Bas van Dijk Date: Fri, 25 Apr 2025 14:22:07 +0000 Subject: [PATCH 01/29] chore: use --execution_log_compact_file to prevent OOM --- .github/actions/bazel/action.yaml | 59 ++-- .github/actions/bazel/bin/bazel | 4 +- bazel/BUILD.bazel | 27 ++ bazel/execution_log_compact_to_csv.py | 92 ++++++ bazel/spawn.proto | 460 ++++++++++++++++++++++++++ 5 files changed, 607 insertions(+), 35 deletions(-) create mode 100644 bazel/execution_log_compact_to_csv.py create mode 100644 bazel/spawn.proto diff --git a/.github/actions/bazel/action.yaml b/.github/actions/bazel/action.yaml index 4106c040bde4..844e807d221c 100644 --- a/.github/actions/bazel/action.yaml +++ b/.github/actions/bazel/action.yaml @@ -73,46 +73,39 @@ runs: ${{ steps.metrics-tmpdir.outputs.dir }}/bazel-bep-*.pb.gpg ${{ steps.metrics-tmpdir.outputs.dir }}/profile-*.json - - # Remove unnecessary entries from the JSON execlogs and create a CSV out of them - - name: Clean up execlogs + - name: Build execution_log_compact_to_csv shell: bash if: (success() || failure()) && inputs.execlogs-artifact-name != '' + env: + # Used by the bazel wrapper + BUILDBUDDY_LINKS: '[CI Job](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})' run: | - execlogs_json_in='${{ steps.metrics-tmpdir.outputs.dir }}/execlogs.json' - find '${{ steps.metrics-tmpdir.outputs.dir }}' -name 'execlog-*.json' \ - -exec cat {} \; > "$execlogs_json_in" + set -euo pipefail - execlogs_csv_out='${{ steps.metrics-tmpdir.outputs.dir }}/execlogs.csv' - if ! [ -s "$execlogs_json_in" ]; then - echo "no execlogs found" - exit 0 - fi + # Here we overwrite the PATH with our custom bazel wrapper to ensure + # the specified commands are run with the CI-specific options included + # in the wrapper. + export BAZEL_ACTION_OLDPATH="$PATH" + # github.action_path doesn't seem to work + PATH="$PWD/.github/actions/bazel/bin:$BAZEL_ACTION_OLDPATH" + hash -r - # this filters out some entries from the input JSON execlogs. Without this, - # jq takes 3+ minutes to parse the execlogs. - # Effectively removes a full line of "commandArgs", and takes care of skipping - # multiple lines for some multiline array values we don't care about - prog=' - BEGIN { arr = 0; } - arr == 1 && / }],?/ { arr = 0; next } - arr == 1 { next } - / "commandArgs":.*/ { next } - / "environmentVariables": \[\{/ { arr = 1; next; } - / "inputs": \[\{/ { arr = 1; next; } - { print } - ' + # Used by the bazel wrapper + export BAZEL_ACTION_METRICS_OUT='${{ steps.metrics-tmpdir.outputs.dir }}' - # Turns the JSON execlogs into a CSV with the following columns: - #