fix: restore instance @BeforeEach lifecycle so BrowserlessTest composes with CDI extensions (#112) #118
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
| name: Format Code | |
| on: | |
| issue_comment: | |
| types: [created] | |
| permissions: | |
| pull-requests: write | |
| jobs: | |
| format: | |
| name: Apply Spotless Formatting | |
| if: >- | |
| github.event.issue.pull_request && | |
| startsWith(github.event.comment.body, '/format') | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| env: | |
| JAVA_VERSION: 21 | |
| steps: | |
| - name: Check user permission | |
| uses: actions-cool/check-user-permission@main | |
| id: check-permission | |
| with: | |
| username: ${{ github.triggering_actor }} | |
| require: 'write' | |
| - name: Deny if no write access | |
| if: steps.check-permission.outputs.require-result != 'true' | |
| run: | | |
| echo "User ${{ github.triggering_actor }} does not have write permission" | |
| exit 1 | |
| - name: Add eyes reaction | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| await github.rest.reactions.createForIssueComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: context.payload.comment.id, | |
| content: 'eyes' | |
| }); | |
| - name: Get PR details | |
| id: pr | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const pr = await github.rest.pulls.get({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| pull_number: context.issue.number | |
| }); | |
| const headRepo = pr.data.head.repo.full_name; | |
| const baseRepo = pr.data.base.repo.full_name; | |
| if (headRepo !== baseRepo) { | |
| core.setFailed(`Cannot format fork PRs (head: ${headRepo}, base: ${baseRepo}). Cannot push to external forks.`); | |
| return; | |
| } | |
| core.setOutput('head-ref', pr.data.head.ref); | |
| - name: Checkout PR branch | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ steps.pr.outputs.head-ref }} | |
| token: ${{ secrets.VAADIN_BOT_TOKEN }} | |
| - name: Set up JDK ${{ env.JAVA_VERSION }} | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: ${{ env.JAVA_VERSION }} | |
| distribution: 'temurin' | |
| - name: Cache Maven dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.m2/repository | |
| key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-maven- | |
| - name: Run spotless:apply | |
| run: mvn spotless:apply --batch-mode --no-transfer-progress | |
| - name: Check for changes | |
| id: diff | |
| run: | | |
| if git diff --quiet; then | |
| echo "has-changes=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "has-changes=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Commit and push | |
| if: steps.diff.outputs.has-changes == 'true' | |
| run: | | |
| git config user.name "vaadin-bot" | |
| git config user.email "20280877+vaadin-bot@users.noreply.github.com" | |
| git add -A | |
| git commit -m "chore: apply spotless formatting" | |
| git push | |
| - name: Add rocket reaction on success | |
| if: success() | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| await github.rest.reactions.createForIssueComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: context.payload.comment.id, | |
| content: 'rocket' | |
| }); | |
| - name: Post result comment | |
| if: always() | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; | |
| const hasChanges = '${{ steps.diff.outputs.has-changes }}'; | |
| const jobStatus = '${{ job.status }}'; | |
| const marker = '<!-- format-apply-comment -->'; | |
| let body; | |
| if (jobStatus === 'success' && hasChanges === 'true') { | |
| body = `${marker}\nFormatting applied and pushed. :white_check_mark:\n\n[Workflow run](${runUrl})`; | |
| } else if (jobStatus === 'success' && hasChanges === 'false') { | |
| body = `${marker}\nCode is already formatted correctly. :white_check_mark:\n\n[Workflow run](${runUrl})`; | |
| } else { | |
| body = `${marker}\nFormatting failed. :x:\n\n[Workflow run](${runUrl})`; | |
| } | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body: body | |
| }); | |
| - name: Add confused reaction on failure | |
| if: failure() | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| await github.rest.reactions.createForIssueComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: context.payload.comment.id, | |
| content: 'confused' | |
| }); |