Skip to content

Commit 1620002

Browse files
authored
Add commenting functionality (#11672)
1 parent a03ed9c commit 1620002

File tree

3 files changed

+98
-0
lines changed

3 files changed

+98
-0
lines changed

.github/ghprcomment.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
- jobName: Checkstyle
2+
message: |
3+
Your code currently does not meet [JabRef's code guidelines](https://devdocs.jabref.org/getting-into-the-code/guidelines-for-setting-up-a-local-workspace/intellij-13-code-style.html).
4+
We use [Checkstyle](https://checkstyle.sourceforge.io/) to identify issues.
5+
The tool reviewdog already placed comments on GitHub to indicate the places. See the tab "Files" in you PR.
6+
Please carefully follow [the setup guide for the codestyle](https://devdocs.jabref.org/getting-into-the-code/guidelines-for-setting-up-a-local-workspace/intellij-13-code-style.html).
7+
Afterwards, please [run checkstyle locally](https://devdocs.jabref.org/getting-into-the-code/guidelines-for-setting-up-a-local-workspace/intellij-13-code-style.html#run-checkstyle) and fix the issues.
8+
9+
10+
You can check review dog's comments at the tab "Files changed" of your pull request.
11+
- jobName: OpenRewrite
12+
message: |
13+
Your code currently does not meet JabRef's code guidelines.
14+
We use [OpenRewrite](https://docs.openrewrite.org/) to ensure "modern" Java coding practices.
15+
The issues found can be **automatically fixed**.
16+
Please execute the gradle task *`rewriteRun`*, check the results, commit, and push.
17+
18+
You can check the detailed error output by navigating to your pull request, selecting the tab "Checks", section "Tests" (on the left), subsection "OpenRewrite".
19+
- jobName: Modernizer
20+
message: |
21+
Your code currently does not meet JabRef's code guidelines.
22+
We use [Gradle Modernizer Plugin](https://github.com/andygoossens/gradle-modernizer-plugin#gradle-modernizer-plugin) to ensure "modern" Java coding practices.
23+
Please fix the detected errors, commit, and push.
24+
25+
You can check the detailed error output by navigating to your pull request, selecting the tab "Checks", section "Tests" (on the left), subsection "Modernizer".
26+
- jobName: Markdown
27+
message: |
28+
You modified Markdown (`*.md`) files and did not meet JabRef's rules for consistently formatted Markdown files.
29+
To ensure consistent styling, we have [markdown-lint](https://github.com/DavidAnson/markdownlint) in place.
30+
[Markdown lint's rules](https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#rules) help to keep our Markdown files consistent within this repository and consistent with the Markdown files outside here.
31+
32+
You can check the detailed error output by navigating to your pull request, selecting the tab "Checks", section "Tests" (on the left), subsection "Markdown".
33+
- jobName: CHANGELOG.md
34+
message: |
35+
While the PR was in progress, a new version of JabRef has been released.
36+
You have to merge `upstream/main` and move your entry in `CHANGELOG.md` up to the section `## [Unreleased]`.

.github/workflows/pr-comment.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Description: This workflow is triggered when the "Check" workflow completes.
2+
# Since this pull request has write permissions on the target repo, we should **NOT** execute any untrusted code.
3+
# https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
4+
# Based on https://github.com/spring-projects/spring-security/pull/15477/files
5+
---
6+
name: Comment on PR
7+
8+
on:
9+
workflow_run:
10+
workflows: ["Tests"]
11+
types:
12+
- completed
13+
14+
jobs:
15+
comment:
16+
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-a-workflow-based-on-the-conclusion-of-another-workflow
17+
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
18+
runs-on: ubuntu-latest
19+
permissions:
20+
actions: read
21+
contents: read
22+
pull-requests: write
23+
timeout-minutes: 10
24+
steps:
25+
- name: Download PR number
26+
uses: actions/download-artifact@v4
27+
with:
28+
name: pr_number
29+
github-token: ${{ secrets.GITHUB_TOKEN }}
30+
run-id: ${{ github.event.workflow_run.id }}
31+
- name: Read pr_number.txt
32+
id: read-pr_number
33+
run: |
34+
PR_NUMBER=$(cat pr_number.txt)
35+
echo "Read PR number $PR_NUMBER"
36+
echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT
37+
- name: Checkout
38+
if: ${{ steps.read-pr_number.outputs.pr_number != '' }}
39+
uses: actions/checkout@v4
40+
with:
41+
fetch-depth: '0'
42+
show-progress: 'false'
43+
token: ${{ secrets.GITHUB_TOKEN }}
44+
- name: jbang
45+
if: ${{ steps.read-pr_number.outputs.pr_number != '' }}
46+
uses: jbangdev/[email protected]
47+
with:
48+
script: ghprcomment@koppor/ghprcomment
49+
scriptargs: "-r koppor/workflow-comment-test -p ${{ steps.read-pr_number.outputs.pr_number }} -w ${{ github.event.workflow_run.id }}"
50+
trust: https://github.com/koppor/ghprcomment/
51+
env:
52+
GITHUB_OAUTH: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/tests.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,3 +363,13 @@ jobs:
363363
with:
364364
script: |
365365
core.setFailed('Pull requests should come from a branch other than "main"\n\n👉 Please read https://devdocs.jabref.org/contributing again carefully. 👈')
366+
367+
upload-pr-number:
368+
runs-on: ubuntu-latest
369+
steps:
370+
- name: Create pr_number.txt
371+
run: echo "${{ github.event.number }}" > pr_number.txt
372+
- uses: actions/upload-artifact@v4
373+
with:
374+
name: pr_number
375+
path: pr_number.txt

0 commit comments

Comments
 (0)