Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
permissions:
actions: read
contents: read
pull-requests: write
security-events: write

steps:
Expand All @@ -33,8 +34,30 @@ jobs:
run: ./gradlew build

- name: Lint
id: lint
continue-on-error: true
run: ./gradlew lint

- name: Count lint violations
id: count_violations
if: steps.lint.outcome == 'failure'
run: |
./gradlew lint || echo "::warning::Checkstyle found violations. See the checkstyle-report artifact for details."
count=$(grep -r '<error ' build/reports/checkstyle/ | wc -l)
echo "count=$count" >> $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 ${count} style violation${count === 1 ? '' : 's'}.** Download the **checkstyle-report** artifact from the [Actions run](${runUrl}) for details.`
})

- name: Determine artifact name
id: find_artifact
Expand Down
Loading