-
Notifications
You must be signed in to change notification settings - Fork 1k
Add spotless auto-fix for PRs #13872
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
trask
merged 4 commits into
open-telemetry:main
from
trask:add-spotless-auto-fix-for-prs
May 19, 2025
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| name: Auto spotless | ||
| on: | ||
| pull_request_target: | ||
| types: | ||
| - opened | ||
| - synchronize | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.event.pull_request.number }} | ||
| cancel-in-progress: true | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| check: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| patch-created: ${{ steps.create-patch-file.outputs.nonempty }} | ||
| steps: | ||
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
|
|
||
| - 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: Check out PR branch | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| run: gh pr checkout ${{ github.event.pull_request.number }} | ||
|
|
||
| - name: Spotless | ||
| run: ./gradlew spotlessApply | ||
|
|
||
| - id: create-patch-file | ||
| name: Create patch file | ||
| run: | | ||
| git diff > patch | ||
| if [ -s patch ]; then | ||
| echo "nonempty=true" >> "$GITHUB_OUTPUT" | ||
| fi | ||
|
|
||
| - name: Upload patch file | ||
| if: steps.create-patch-file.outputs.nonempty == 'true' | ||
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | ||
| with: | ||
| path: patch | ||
| name: patch | ||
|
|
||
| apply: | ||
| runs-on: ubuntu-latest | ||
| needs: check | ||
| if: needs.check.outputs.patch-created == 'true' | ||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
| steps: | ||
| - 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: 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 [email protected] | ||
|
|
||
| - 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: | ||
| 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 "🔧 The result from \`./gradlew spotlessApply\` was committed to the PR branch." | ||
|
||
|
|
||
| - if: failure() | ||
|
||
| env: | ||
| GH_TOKEN: ${{ steps.otelbot-token.outputs.token }} | ||
| run: | | ||
| gh pr comment $PR_NUM --body "❌ The result from \`./gradlew spotlessApply\` could not be committed to the PR branch, see logs: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID." | ||
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.