Skip to content

Commit

Permalink
Modify JMH Benchmark Workflow For Shellcheck (#813)
Browse files Browse the repository at this point in the history
Enable shellcheck checking as part of our build, and fix Shellcheck errors for JMH workflow files.

---------

Co-authored-by: Manu Sridharan <msridhar@gmail.com>
  • Loading branch information
armughan11 and msridhar authored Aug 21, 2023
1 parent 540eaa9 commit 7cf3e3b
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .buildscript/check_git_clean.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/sh -eux

if [ -n "$(git status --porcelain)" ]; then
echo 'warning: source tree contains uncommitted changes; .gitignore patterns may need to be fixed'
git status
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ jobs:
uses: gradle/gradle-build-action@v2
with:
arguments: build
- name: Run shellcheck
uses: gradle/gradle-build-action@v2
with:
arguments: shellcheck
if: runner.os == 'Linux'
- name: Report jacoco coverage
uses: gradle/gradle-build-action@v2
env:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/get_repo_details.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ REPO_FULL_NAME=$(echo "$PR_DETAILS" | jq -r .head.repo.full_name)
BRANCH_NAME=$(echo "$PR_DETAILS" | jq -r .head.ref)

# Export vars to GITHUB_ENV so they can be used by later scripts
echo "REPO_FULL_NAME=$REPO_FULL_NAME" >> $GITHUB_ENV
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
echo "REPO_FULL_NAME=$REPO_FULL_NAME" >> "$GITHUB_ENV"
echo "BRANCH_NAME=$BRANCH_NAME" >> "$GITHUB_ENV"
8 changes: 4 additions & 4 deletions .github/workflows/run_gcp_benchmarks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ chmod +x ./.github/workflows/gcloud_ssh.sh
./.github/workflows/gcloud_ssh.sh "export BRANCH_NAME=${BRANCH_NAME} && mkdir $BRANCH_NAME"

# Using gcloud compute scp to copy the bash scripts that will run the benchmarks onto the GCCE
gcloud compute scp ./.github/workflows/run_pr_benchmarks.sh root@nullway-jmh:$BRANCH_NAME/ --zone=us-central1-a
gcloud compute scp ./.github/workflows/run_main_benchmarks.sh root@nullway-jmh:$BRANCH_NAME/ --zone=us-central1-a
gcloud compute scp ./.github/workflows/run_pr_benchmarks.sh root@nullway-jmh:"$BRANCH_NAME/" --zone=us-central1-a
gcloud compute scp ./.github/workflows/run_main_benchmarks.sh root@nullway-jmh:"$BRANCH_NAME/" --zone=us-central1-a

# Running the benchmark script for the pull request branch and main branch on GCCE
./.github/workflows/gcloud_ssh.sh " export BRANCH_NAME=${BRANCH_NAME} && export REPO_NAME=${REPO_FULL_NAME} && chmod +x $BRANCH_NAME/run_pr_benchmarks.sh && $BRANCH_NAME/run_pr_benchmarks.sh && cd && chmod +x $BRANCH_NAME/run_main_benchmarks.sh && $BRANCH_NAME/run_main_benchmarks.sh"

# Copying the benchmark results from GCCE back to the Github runner for the PR branch
gcloud compute scp root@nullway-jmh:$BRANCH_NAME/pr/NullAway/jmh/build/results/jmh/results.txt ./pr_text.txt --zone=us-central1-a
gcloud compute scp root@nullway-jmh:"$BRANCH_NAME/pr/NullAway/jmh/build/results/jmh/results.txt" ./pr_text.txt --zone=us-central1-a

# Copying the benchmark results from GCCE back to the Github runner for the main branch
gcloud compute scp root@nullway-jmh:$BRANCH_NAME/main/NullAway/jmh/build/results/jmh/results.txt ./main_text.txt --zone=us-central1-a
gcloud compute scp root@nullway-jmh:"$BRANCH_NAME/main/NullAway/jmh/build/results/jmh/results.txt" ./main_text.txt --zone=us-central1-a
8 changes: 4 additions & 4 deletions .github/workflows/run_main_benchmarks.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/bash
#!/bin/bash -eux

cd $BRANCH_NAME/
cd "$BRANCH_NAME/"
mkdir main
cd main/
cd main/
git clone git@github.com:Uber/NullAway.git
cd NullAway/
cd NullAway/

./gradlew jmh --no-daemon
10 changes: 5 additions & 5 deletions .github/workflows/run_pr_benchmarks.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/bash
#!/bin/bash -eux

cd $BRANCH_NAME/
cd "$BRANCH_NAME/"
mkdir pr
cd pr/
git clone --branch $BRANCH_NAME --single-branch git@github.com:$REPO_NAME.git NullAway
cd NullAway/
cd pr/
git clone --branch "$BRANCH_NAME" --single-branch git@github.com:"$REPO_NAME".git NullAway
cd NullAway/

./gradlew jmh --no-daemon
11 changes: 11 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ plugins {
id "com.github.kt3k.coveralls" version "2.12.0" apply false
id "me.champeau.jmh" version "0.7.1" apply false
id "com.github.ben-manes.versions" version "0.47.0"
id "com.felipefzdz.gradle.shellcheck" version "1.4.6"
}

repositories {
Expand Down Expand Up @@ -121,6 +122,16 @@ spotless {
spotlessPredeclare {
java { googleJavaFormat('1.17.0') }
}

shellcheck {
useDocker = false
shellcheckBinary = "shellcheck"
sourceFiles =
fileTree(".") {
include("**/*.sh")
}
}

////////////////////////////////////////////////////////////////////////
//
// Google Java Format pre-commit hook installation
Expand Down

0 comments on commit 7cf3e3b

Please sign in to comment.