From c150663e4b3adc58e87e5e30ef35846033c61f2a Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Thu, 15 May 2025 10:59:29 -0700 Subject: [PATCH 1/4] Add comment-driven fix on PRs for spotless --- .github/workflows/auto-spotless.yml | 97 +++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 .github/workflows/auto-spotless.yml diff --git a/.github/workflows/auto-spotless.yml b/.github/workflows/auto-spotless.yml new file mode 100644 index 000000000000..49c0a4a9660e --- /dev/null +++ b/.github/workflows/auto-spotless.yml @@ -0,0 +1,97 @@ +name: Auto spotless +on: + pull_request_target: + types: + - synchronize + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + create-patch: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Check out PR branch + run: gh pr checkout ${{ github.event.pull_request.number }} + + - name: Free disk space + run: .github/scripts/gha-free-disk-space.sh + + - name: Set up JDK for running Gradle + uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1 + with: + distribution: temurin + java-version-file: .java-version + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@06832c7b30a0129d7fb559bcc6e43d26f6374244 # v4.3.1 + with: + cache-read-only: true + + - name: Spotless + run: ./gradlew spotlessApply + + - name: Create patch + run: git diff > patch + + - name: Upload patch + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + path: patch + + apply-patch: + runs-on: ubuntu-latest + needs: create-patch + permissions: + contents: write + pull-requests: write + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Check out PR branch + run: gh pr checkout ${{ github.event.pull_request.number }} + + - name: Download patch + uses: actions/download-artifact@v4 + with: + name: patch + + - name: Use CLA approved github bot + # IMPORTANT do not call the .github/scripts/use-cla-approved-bot.sh + # since that script could have been compromised in the PR branch + run: | + git config user.name otelbot + git config user.email 197425009+otelbot@users.noreply.github.com + + - uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6 + id: otelbot-token + with: + app-id: ${{ vars.OTELBOT_APP_ID }} + private-key: ${{ secrets.OTELBOT_PRIVATE_KEY }} + + - name: Apply patch and push + env: + # not using secrets.GITHUB_TOKEN since pushes from that token do not run workflows + GH_TOKEN: ${{ steps.otelbot-token.outputs.token }} + run: | + git apply patch + git commit -a -m "./gradlew spotlessApply" + git push + + - if: success() + env: + GH_TOKEN: ${{ steps.otelbot-token.outputs.token }} + run: | + gh pr comment $PR_NUM --body "✅ \`fix:spotless\` applied successfully" + + - if: failure() + env: + GH_TOKEN: ${{ steps.otelbot-token.outputs.token }} + run: | + gh pr comment $PR_NUM --body "❌ \`fix:spotless\` failed, see logs: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" From 8038766dacce2f451880ccd1aec5fe798d973572 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Fri, 16 May 2025 10:19:46 -0700 Subject: [PATCH 2/4] up --- .github/workflows/auto-spotless.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/auto-spotless.yml b/.github/workflows/auto-spotless.yml index 49c0a4a9660e..61cd7d4944af 100644 --- a/.github/workflows/auto-spotless.yml +++ b/.github/workflows/auto-spotless.yml @@ -2,6 +2,7 @@ name: Auto spotless on: pull_request_target: types: + - opened - synchronize concurrency: From 7a0be942ce3d6c260245295638da31df54cbd464 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Fri, 16 May 2025 10:30:09 -0700 Subject: [PATCH 3/4] testing --- .github/workflows/auto-spotless.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/auto-spotless.yml b/.github/workflows/auto-spotless.yml index 61cd7d4944af..895638199244 100644 --- a/.github/workflows/auto-spotless.yml +++ b/.github/workflows/auto-spotless.yml @@ -19,6 +19,8 @@ jobs: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Check out PR branch + env: + GH_TOKEN: ${{ github.token }} run: gh pr checkout ${{ github.event.pull_request.number }} - name: Free disk space From acc0abc9e827ff9a95a634ba909cdabee255b823 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Fri, 16 May 2025 10:28:23 -0700 Subject: [PATCH 4/4] testing --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index ac71affb699b..b390a985bc3d 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +testing + # OpenTelemetry Instrumentation for Java [![Release](https://img.shields.io/github/v/release/open-telemetry/opentelemetry-java-instrumentation?include_prereleases&style=)](https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/)