From b58cc13b39a3110c0495475330527bd0b8322ad5 Mon Sep 17 00:00:00 2001 From: Manu Sridharan Date: Sun, 9 Jun 2024 13:09:49 -0700 Subject: [PATCH 1/6] restore safer jmh benchmark workflow --- .github/workflows/jmh-benchmark.yml | 68 +++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 .github/workflows/jmh-benchmark.yml diff --git a/.github/workflows/jmh-benchmark.yml b/.github/workflows/jmh-benchmark.yml new file mode 100644 index 0000000000..7f9e5f77da --- /dev/null +++ b/.github/workflows/jmh-benchmark.yml @@ -0,0 +1,68 @@ +# This GitHub Actions workflow runs JMH benchmarks when a new comment is created on a pull request +name: Run JMH Benchmarks for Pull Request + +on: + pull_request: # This workflow triggers when a comment is created + types: [labeled] + +# Only allow one instance of JMH benchmarking to be running at any given time +concurrency: all + +jobs: + benchmarking: + # Only run this job if a comment on a pull request contains '/benchmark' and is a PR on the uber/NullAway repository + if: github.event.label.name == 'run-benchmarks' + runs-on: ubuntu-latest + permissions: write-all + + steps: + + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set branch name + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + chmod +x ./.github/workflows/get_repo_details.sh + ./.github/workflows/get_repo_details.sh "${{ secrets.GITHUB_TOKEN }}" "${{ github.event.issue.number }}" "${{ github.repository }}" + + - id: 'auth' + name: Authenticating + uses: google-github-actions/auth@v2 + with: + credentials_json: '${{ secrets.GCP_SA_KEY_1 }}' + + - name: Set up Google Cloud SDK + uses: google-github-actions/setup-gcloud@v2 + + - name: Start VM + run: gcloud compute instances start nullway-jmh --zone=us-central1-a + + - name: Run benchmarks + run: | + chmod +x ./.github/workflows/run_gcp_benchmarks.sh + ./.github/workflows/run_gcp_benchmarks.sh + + - name: Cleanup + # Delete the branch directory on the Google Cloud instance + if: always() + run: | + ./.github/workflows/gcloud_ssh.sh " export BRANCH_NAME=${BRANCH_NAME} && rm -r -f $BRANCH_NAME" + + - name: Formatting Benchmark # Create a text file containing the benchmark results + run: | + (echo 'Main Branch:'; echo '```' ; cat main_text.txt; echo '```'; echo 'With This PR:'; echo '```' ; cat pr_text.txt; echo '```') > benchmark.txt + + - name: Comment Benchmark + uses: mshick/add-pr-comment@v2 + if: always() # This step is for adding the comment + with: + message-path: benchmark.txt # The path to the message file to leave as a comment + message-id: benchmark + - name: Stop VM + if: always() + run: gcloud compute instances stop nullway-jmh --zone=us-central1-a + + + From 6f4748d0f800dbc53b540ff3f35b46de9d4ad757 Mon Sep 17 00:00:00 2001 From: Manu Sridharan Date: Sun, 9 Jun 2024 14:05:29 -0700 Subject: [PATCH 2/6] tweaks --- .github/workflows/jmh-benchmark.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jmh-benchmark.yml b/.github/workflows/jmh-benchmark.yml index 7f9e5f77da..3214c75df1 100644 --- a/.github/workflows/jmh-benchmark.yml +++ b/.github/workflows/jmh-benchmark.yml @@ -25,7 +25,7 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | chmod +x ./.github/workflows/get_repo_details.sh - ./.github/workflows/get_repo_details.sh "${{ secrets.GITHUB_TOKEN }}" "${{ github.event.issue.number }}" "${{ github.repository }}" + ./.github/workflows/get_repo_details.sh "${{ secrets.GITHUB_TOKEN }}" "${{ github.event.number }}" "${{ github.event.repository }}" - id: 'auth' name: Authenticating From 5afc3b9002b10a313558cead8070475b73676fea Mon Sep 17 00:00:00 2001 From: Manu Sridharan Date: Sun, 9 Jun 2024 14:14:19 -0700 Subject: [PATCH 3/6] tweaks --- .github/workflows/jmh-benchmark.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/jmh-benchmark.yml b/.github/workflows/jmh-benchmark.yml index 3214c75df1..ad9f919c17 100644 --- a/.github/workflows/jmh-benchmark.yml +++ b/.github/workflows/jmh-benchmark.yml @@ -20,12 +20,15 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 + - name: Print repo name + - run: echo ${{ github.repository }} + - name: Set branch name env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | chmod +x ./.github/workflows/get_repo_details.sh - ./.github/workflows/get_repo_details.sh "${{ secrets.GITHUB_TOKEN }}" "${{ github.event.number }}" "${{ github.event.repository }}" + ./.github/workflows/get_repo_details.sh "${{ secrets.GITHUB_TOKEN }}" "${{ github.event.number }}" "${{ github.repository }}" - id: 'auth' name: Authenticating From 1263a15f3e69bd8914b142e08c7d9fd5761e66cd Mon Sep 17 00:00:00 2001 From: Manu Sridharan Date: Sun, 9 Jun 2024 14:16:29 -0700 Subject: [PATCH 4/6] fix --- .github/workflows/jmh-benchmark.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jmh-benchmark.yml b/.github/workflows/jmh-benchmark.yml index ad9f919c17..753525afc0 100644 --- a/.github/workflows/jmh-benchmark.yml +++ b/.github/workflows/jmh-benchmark.yml @@ -21,7 +21,7 @@ jobs: uses: actions/checkout@v4 - name: Print repo name - - run: echo ${{ github.repository }} + run: echo ${{ github.repository }} - name: Set branch name env: From fa5b1f3c23daf37451d0e30043b94ac74140815a Mon Sep 17 00:00:00 2001 From: Manu Sridharan Date: Sun, 9 Jun 2024 18:07:30 -0700 Subject: [PATCH 5/6] comments --- .github/workflows/jmh-benchmark.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/jmh-benchmark.yml b/.github/workflows/jmh-benchmark.yml index 753525afc0..2d58634cb4 100644 --- a/.github/workflows/jmh-benchmark.yml +++ b/.github/workflows/jmh-benchmark.yml @@ -1,8 +1,8 @@ -# This GitHub Actions workflow runs JMH benchmarks when a new comment is created on a pull request +# This GitHub Actions workflow runs JMH benchmarks when requested name: Run JMH Benchmarks for Pull Request on: - pull_request: # This workflow triggers when a comment is created + pull_request: # Trigger when a label is added. Only contributors have permissions to add labels types: [labeled] # Only allow one instance of JMH benchmarking to be running at any given time @@ -10,7 +10,7 @@ concurrency: all jobs: benchmarking: - # Only run this job if a comment on a pull request contains '/benchmark' and is a PR on the uber/NullAway repository + # Only run this job if the label is 'run-benchmarks' and the PR in on the uber/NullAway repository if: github.event.label.name == 'run-benchmarks' runs-on: ubuntu-latest permissions: write-all From 959446bb8b2fd06715408d2cac3a0bab195a49aa Mon Sep 17 00:00:00 2001 From: Manu Sridharan Date: Sun, 9 Jun 2024 18:22:03 -0700 Subject: [PATCH 6/6] tweaks --- .github/workflows/jmh-benchmark.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/jmh-benchmark.yml b/.github/workflows/jmh-benchmark.yml index 2d58634cb4..9e59a448e1 100644 --- a/.github/workflows/jmh-benchmark.yml +++ b/.github/workflows/jmh-benchmark.yml @@ -11,7 +11,7 @@ concurrency: all jobs: benchmarking: # Only run this job if the label is 'run-benchmarks' and the PR in on the uber/NullAway repository - if: github.event.label.name == 'run-benchmarks' + if: github.event.label.name == 'run-benchmarks' && github.repository == 'uber/NullAway' runs-on: ubuntu-latest permissions: write-all @@ -20,10 +20,7 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - - name: Print repo name - run: echo ${{ github.repository }} - - - name: Set branch name + - name: Set branch name env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: |