Spotless auto-pr (#8)

* Show detailed gradle logs and stacktraces on errors

* Generate a new PR on spotless failures against the failing PR branch
This commit is contained in:
Raven Szewczyk 2022-08-19 11:12:58 +01:00 committed by GitHub
parent 9a3d1d63b4
commit 3700d3b91d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 6 deletions

View File

@ -43,16 +43,40 @@ jobs:
run: chmod +x gradlew
- name: Setup the workspace
run: ./gradlew ${{ inputs.workspace }}
run: ./gradlew --info --stacktrace ${{ inputs.workspace }}
- name: Build the mod
run: ./gradlew build
id: build_mod
run: ./gradlew --info --stacktrace build
- name: Attempt to make a PR fixing spotless errors
if: ${{ failure() && steps.build_mod.conclusion == 'failure' && github.event_name == 'pull_request' }}
run: |
./gradlew --info --stacktrace spotlessApply || exit 1
git diff --exit-code && exit 1
git config user.name "GitHub GTNH Actions"
git config user.email "<>"
git switch -c "${FIXED_BRANCH}"
git commit -am "spotlessApply"
git push --force-with-lease origin "${FIXED_BRANCH}"
gh pr create \
--head "${FIXED_BRANCH}" \
--base "${PR_BRANCH}" \
--title "Spotless apply for branch ${PR_BRANCH} for #${{ github.event.pull_request.number }}" \
--body "Automatic spotless apply to fix formatting errors, applies to PR #${{ github.event.pull_request.number }}" \
2>&1 | tee pr-message.log || true
gh pr comment "${PR_BRANCH}" -F pr-message.log || true
shell: bash # ensures set -eo pipefail
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_BRANCH: ${{ github.head_ref }}
FIXED_BRANCH: ${{ github.head_ref }}-spotless-fixes
- name: Run server for ${{ inputs.timeout }} seconds
run: |
mkdir run
echo "eula=true" > run/eula.txt
timeout ${{ inputs.timeout }} ./gradlew runServer 2>&1 | tee -a server.log || true
timeout ${{ inputs.timeout }} ./gradlew --info --stacktrace runServer 2>&1 | tee -a server.log || true
- name: Test no errors reported during server run
run: |

View File

@ -40,10 +40,10 @@ jobs:
run: chmod +x gradlew
- name: Setup the workspace
run: ./gradlew ${{ inputs.workspace }}
run: ./gradlew --info --stacktrace ${{ inputs.workspace }}
- name: Build the mod
run: ./gradlew build
run: ./gradlew --info --stacktrace build
# Continue on error in the following steps to make sure releases still get made even if one of the methods fails
@ -60,7 +60,7 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to Maven
run: ./gradlew publish
run: ./gradlew --info --stacktrace publish
continue-on-error: true
env:
MAVEN_USER: ${{ secrets.MAVEN_USER }}