Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 5 additions & 5 deletions .github/ghprcomment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,25 +168,25 @@

Give it a read, and you’ll discover the ancient wisdom of assigning issues to yourself. Trust me, it’s worth it. 🚀

- jobName: 'PR title must not start with "Fix for issue <number>"'
workflowName: 'PR Tests'
- jobName: 'PR title must not contain "issue <number>"'
workflowName: 'PR Format'
always: true
message: >
The title of the pull request must not start with "Fix for issue xyz".
Please use a concise one-line summary that explains what the fix or change actually does.
Example of a good title: "Prevent crash when importing malformed BibTeX entries".
- jobName: 'Mandatory Checks present'
workflowName: 'PR Tests'
workflowName: 'PR Format'
always: true
message: >
You have removed the "Mandatory Checks" section from your pull request description. Please adhere to our [pull request template](https://github.com/JabRef/jabref/blob/main/.github/PULL_REQUEST_TEMPLATE.md?plain=1#L10).
- jobName: 'PR checklist OK'
workflowName: 'PR Tests'
workflowName: 'PR Format'
always: true
message: >
Note that your PR will not be reviewed/accepted until you have gone through the mandatory checks in the description and marked each of them them exactly in the format of `[x]` (done), `[ ]` (not done yet) or `[/]` (not applicable).
- jobName: 'Determine issue number'
workflowName: 'PR Tests'
workflowName: 'On PR opened/updated'
always: true
message: |
Your pull request needs to link an issue correctly.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/on-pr-opened.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Welcome a first-time contributor

on:
pull_request_target:
types: opened
types: [opened]

jobs:
welcome-first-time-contributor:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/pr-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ name: Comment on PR

on:
workflow_run:
workflows: ["Source Code Tests", "On PR opened/updated", "PR Tests"]
# note when updating via a PR and testing - `workflow_run` executes from the `main` branch and not the PR branch
workflows: ["Source Code Tests", "On PR opened/updated", "PR Tests", "PR Format"]
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-a-workflow-based-on-the-conclusion-of-another-workflow
types: [completed]
workflow_dispatch:
Expand Down
124 changes: 124 additions & 0 deletions .github/workflows/pr-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
name: PR Format

on:
pull_request:
types: [opened, reopened, edited]

permissions:
pull-requests: write

jobs:
check_title_format:
name: PR title must not contain "issue <number>"
if: github.actor != 'dependabot[bot]' && github.event.pull_request.head.repo.full_name != 'JabRef/jabref'
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v5
with:
submodules: 'false'
show-progress: 'false'
- name: Check PR title
run: |
TITLE=$(gh pr view "${{ github.event.number }}" --json title --template '{{.title}}')
echo "Title: $TITLE"

if echo "$TITLE" | grep -Eiq 'issue ?#?[0-9]+.+'; then
echo "❌ Title contains 'issue <number>' — not allowed."
exit 1
fi

echo "✅ Title format OK"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

mandatory-checks-section-exists:
if: >
(github.event.pull_request.head.repo.full_name != 'JabRef/jabref') && !(
(github.actor == 'dependabot[bot]') ||
(
startsWith(github.event.pull_request.title, '[Bot] ') ||
startsWith(github.event.pull_request.title, 'Bump ') ||
startsWith(github.event.pull_request.title, 'New Crowdin updates') ||
startsWith(github.event.pull_request.title, 'Update Gradle Wrapper from')
)
)
name: Mandatory Checks present
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v5
with:
submodules: 'false'
show-progress: 'false'

- name: Check for existence of Mandatory Checks section
id: check_mandatory_section
run: |
set -e

BODY=$(gh pr view "${{ github.event.number }}" --json body --template '{{.body}}')

if echo "$BODY" | grep -q "### Mandatory checks"; then
echo "✅ '### Mandatory checks' section found."
else
echo "❌ '### Mandatory checks' section is missing!"
exit 1
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

checklist-checked:
if: >
(github.event.pull_request.head.repo.full_name != 'JabRef/jabref') &&
!(
(github.actor == 'dependabot[bot]') ||
(
startsWith(github.event.pull_request.title, '[Bot] ') ||
startsWith(github.event.pull_request.title, 'Bump ') ||
startsWith(github.event.pull_request.title, 'New Crowdin updates') ||
startsWith(github.event.pull_request.title, 'Update Gradle Wrapper from')
)
)
name: PR checklist OK
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v5
with:
submodules: 'false'
show-progress: 'false'
- name: Check for PR checklist
id: check_changelog_modification
run: |
set -e

BODY=$(gh pr view "${{ github.event.number }}" --json body --template '{{.body}}' | grep -A5000 '### Mandatory checks')
echo "Found body: $BODY"

# Ensure the section exists
if ! printf '%s\n' "$BODY" | grep -q "### Mandatory checks"; then
echo "❌ '### Mandatory checks' section is missing!"
exit 1
fi

BOXES=$(printf '%s\n' "$BODY" | grep "^- \[")
echo "Found boxes: $BOXES"

while IFS= read -r line; do
if ! printf '%s\n' "$line" | grep -Eq "^- \[(x|/| )\] "; then
echo "❌ Found improperly formatted checkbox: '$line'"
exit 1
fi
done <<< "$BOXES"

LINE_COUNT=$(echo "$BOXES" | wc -l)

if [ "$LINE_COUNT" -ne 6 ]; then
echo "❌ Found $LINE_COUNT lines instead of 6 required lines"
exit 1
fi

echo "✅ All checkboxes are present and in the correct format."
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
117 changes: 1 addition & 116 deletions .github/workflows/tests-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: PR Tests

on:
pull_request:
types: [opened, reopened, synchronize]

concurrency:
group: "${{ github.workflow }}-${{ github.head_ref || github.ref }}"
Expand All @@ -21,122 +22,6 @@ jobs:
name: pr_number
path: pr_number.txt

check_title_format:
name: PR title must not contain "issue <number>"
if: github.actor != 'dependabot[bot]' && github.event.pull_request.head.repo.full_name != 'JabRef/jabref'
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v5
with:
submodules: 'false'
show-progress: 'false'
- name: Check PR title
run: |
TITLE=$(gh pr view "${{ github.event.number }}" --json title --template '{{.title}}')
echo "Title: $TITLE"

if echo "$TITLE" | grep -Eiq 'issue ?#?[0-9]+.+'; then
echo "❌ Title contains 'issue <number>' — not allowed."
exit 1
fi

echo "✅ Title format OK"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

mandatory-checks-section-exists:
if: >
(github.event.pull_request.head.repo.full_name != 'JabRef/jabref') && !(
(github.actor == 'dependabot[bot]') ||
(
startsWith(github.event.pull_request.title, '[Bot] ') ||
startsWith(github.event.pull_request.title, 'Bump ') ||
startsWith(github.event.pull_request.title, 'New Crowdin updates') ||
startsWith(github.event.pull_request.title, 'Update Gradle Wrapper from')
)
)
name: Mandatory Checks present
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v5
with:
submodules: 'false'
show-progress: 'false'

- name: Check for existence of Mandatory Checks section
id: check_mandatory_section
run: |
set -e

BODY=$(gh pr view "${{ github.event.number }}" --json body --template '{{.body}}')

if echo "$BODY" | grep -q "### Mandatory checks"; then
echo "✅ '### Mandatory checks' section found."
else
echo "❌ '### Mandatory checks' section is missing!"
exit 1
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

checklist-checked:
if: >
(github.event.pull_request.head.repo.full_name != 'JabRef/jabref') &&
!(
(github.actor == 'dependabot[bot]') ||
(
startsWith(github.event.pull_request.title, '[Bot] ') ||
startsWith(github.event.pull_request.title, 'Bump ') ||
startsWith(github.event.pull_request.title, 'New Crowdin updates') ||
startsWith(github.event.pull_request.title, 'Update Gradle Wrapper from')
)
)
name: PR checklist OK
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v5
with:
submodules: 'false'
show-progress: 'false'
- name: Check for PR checklist
id: check_changelog_modification
run: |
set -e

BODY=$(gh pr view "${{ github.event.number }}" --json body --template '{{.body}}' | grep -A5000 '### Mandatory checks')
echo "Found body: $BODY"

# Ensure the section exists
if ! printf '%s\n' "$BODY" | grep -q "### Mandatory checks"; then
echo "❌ '### Mandatory checks' section is missing!"
exit 1
fi

BOXES=$(printf '%s\n' "$BODY" | grep "^- \[")
echo "Found boxes: $BOXES"

while IFS= read -r line; do
if ! printf '%s\n' "$line" | grep -Eq "^- \[(x|/| )\] "; then
echo "❌ Found improperly formatted checkbox: '$line'"
exit 1
fi
done <<< "$BOXES"

LINE_COUNT=$(echo "$BOXES" | wc -l)

if [ "$LINE_COUNT" -ne 6 ]; then
echo "❌ Found $LINE_COUNT lines instead of 6 required lines"
exit 1
fi

echo "✅ All checkboxes are present and in the correct format."
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


changelog_modified:
name: CHANGELOG.md needs to be modified
if: github.actor != 'dependabot[bot]' && github.event.pull_request.head.repo.full_name != 'JabRef/jabref'
Expand Down
Loading