From 541bfe44c704d470b098c4e273facb97b760648b Mon Sep 17 00:00:00 2001 From: Parth Iyer Date: Thu, 2 Apr 2026 19:35:35 -0400 Subject: [PATCH 1/2] Add comment when linting fails --- .github/workflows/check.yml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index aec440c6..02286131 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -12,6 +12,7 @@ jobs: permissions: actions: read contents: read + pull-requests: write security-events: write steps: @@ -33,8 +34,21 @@ jobs: run: ./gradlew build - name: Lint - run: | - ./gradlew lint || echo "::warning::Checkstyle found violations. See the checkstyle-report artifact for details." + id: lint + continue-on-error: true + run: ./gradlew lint + + - name: Comment on PR if lint failed + if: steps.lint.outcome == 'failure' && github.event_name == 'pull_request' + uses: actions/github-script@v6 + with: + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: ':warning: **Checkstyle found style violations.** See the **checkstyle-report** artifact for details.' + }) - name: Determine artifact name id: find_artifact From 93ae2ffea887ed064b2731c738a00652472dc307 Mon Sep 17 00:00:00 2001 From: Parth Iyer Date: Thu, 2 Apr 2026 19:52:36 -0400 Subject: [PATCH 2/2] Add count and link to run --- .github/workflows/check.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 02286131..cc424ff1 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -38,16 +38,25 @@ jobs: continue-on-error: true run: ./gradlew lint + - name: Count lint violations + id: count_violations + if: steps.lint.outcome == 'failure' + run: | + count=$(grep -r '> $GITHUB_OUTPUT + - name: Comment on PR if lint failed if: steps.lint.outcome == 'failure' && github.event_name == 'pull_request' uses: actions/github-script@v6 with: script: | + const count = ${{ steps.count_violations.outputs.count }}; + const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: ':warning: **Checkstyle found style violations.** See the **checkstyle-report** artifact for details.' + body: `:warning: **Checkstyle found ${count} style violation${count === 1 ? '' : 's'}.** Download the **checkstyle-report** artifact from the [Actions run](${runUrl}) for details.` }) - name: Determine artifact name