# This file defines a workflow that runs the libc++ benchmarks when a comment is added to the PR. # # The comment is of the form: # # /libcxx-bot benchmark # # That will cause the specified benchmarks to be run on the PR and on the pull-request target, and # their results to be compared. name: Benchmark libc++ permissions: contents: read on: issue_comment: types: - created - edited env: CC: clang-22 CXX: clang++-22 jobs: permission-check: if: >- github.event.issue.pull_request && contains(github.event.comment.body, '/libcxx-bot benchmark') runs-on: ubuntu-24.04 environment: name: main-branch-only deployment: false steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: persist-credentials: false sparse-checkout: | .github/workflows/ - name: Check Permissions uses: ./.github/workflows/require-team-membership with: team-slug: llvm-committers LLVM_TOKEN_GENERATOR_CLIENT_ID: ${{ secrets.LLVM_TOKEN_GENERATOR_CLIENT_ID }} LLVM_TOKEN_GENERATOR_PRIVATE_KEY: ${{ secrets.LLVM_TOKEN_GENERATOR_PRIVATE_KEY }} run-benchmarks: permissions: pull-requests: write runs-on: llvm-premerge-libcxx-next-runners # TODO: This should run on a dedicated set of machines needs: - permission-check steps: - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 with: python-version: '3.14' - name: Setup virtual environment run: | python3 -m venv .venv source .venv/bin/activate python -m pip install pygithub==2.8.1 - name: Extract information from the PR id: vars env: COMMENT_BODY: ${{ github.event.comment.body }} run: | source .venv/bin/activate cat <> ${GITHUB_OUTPUT} import github repo = github.Github(auth=github.Auth.Token("${{ github.token }}")).get_repo("${{ github.repository }}") pr = repo.get_pull(${{ github.event.issue.number }}) print(f"pr_base={pr.base.sha}") print(f"pr_head={pr.head.sha}") EOF BENCHMARKS=$(echo "$COMMENT_BODY" | sed -nE 's/\/libcxx-bot benchmark (.+)/\1/p') echo "benchmarks=${BENCHMARKS}" >> ${GITHUB_OUTPUT} - name: Update comment with link to the job run: | source .venv/bin/activate cat < Benchmark results: \`\`\` {benchmark_results} \`\`\` """ comment.edit(new_comment_text) EOF