forked from JabRef/jabref
-
Notifications
You must be signed in to change notification settings - Fork 0
124 lines (114 loc) · 4.19 KB
/
tests-pr.yml
File metadata and controls
124 lines (114 loc) · 4.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
name: PR Tests
on:
pull_request:
types: [opened, reopened, synchronize]
concurrency:
group: "${{ github.workflow }}-${{ github.head_ref || github.ref }}"
cancel-in-progress: true
permissions:
pull-requests: write
jobs:
upload-pr-number:
runs-on: ubuntu-latest
steps:
- name: Create pr_number.txt
run: echo "${{ github.event.number }}" > pr_number.txt
- uses: actions/upload-artifact@v4
with:
name: pr_number
path: pr_number.txt
changelog_modified:
name: CHANGELOG.md needs to be modified
if: github.actor != 'dependabot[bot]' && github.event.pull_request.head.repo.full_name != 'JabRef/jabref'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Check PR body for changelog note
id: changelog_check
run: |
BODY=$(gh pr view "${{ github.event.number }}" --json body --template '{{.body}}')
echo "Body: $BODY"
if echo "$BODY" | grep -q '\- \[x\] Change in `CHANGELOG.md`'; then
echo "found"
echo "found=yes" >> $GITHUB_OUTPUT
else
echo "not found"
echo "found=no" >> $GITHUB_OUTPUT
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check for CHANGELOG.md modifications
id: check_changelog_modification
if: steps.changelog_check.outputs.found == 'yes'
run: |
git fetch origin ${{ github.base_ref }}
if git diff --name-only origin/${{ github.base_ref }}...HEAD | grep -q '^CHANGELOG\.md$'; then
echo "✅ CHANGELOG.md was modified"
else
echo "❌ CHANGELOG.md was NOT modified"
exit 1
fi
# This ensures that no git merge conflict markers (<<<, ...) are contained
merge_conflict_job:
name: Find merge conflicts
if: github.actor != 'dependabot[bot]' && github.event.pull_request.head.repo.full_name != 'JabRef/jabref'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
show-progress: 'false'
- name: Merge Conflict finder
uses: olivernybroe/action-conflict-finder@v4.1
no-force-push:
if: github.actor != 'dependabot[bot]' && github.event.pull_request.head.repo.full_name != 'JabRef/jabref'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Check force push
id: force_push_check
run: |
if [[ -z "${{ github.event.before }}" ]]; then
echo "✅ New PR created."
exit 0
fi
if git cat-file -e ${{ github.event.before }} 2>/dev/null; then
echo "✅ Regular push detected."
exit 0
else
echo "❌ Force push detected"
exit 1
fi
unmodified_submodules:
name: Submodules not modified
if: github.actor != 'dependabot[bot]' && github.event.pull_request.head.repo.full_name != 'JabRef/jabref'
runs-on: ubuntu-latest
steps:
# No checkout -> the action uses GitHub's API (which is more reliable for submodule changes due to our submodule settings)
- name: Get all submodule changes
id: changes
uses: tj-actions/changed-files@v46
with:
files: |
jablib/src/main/abbrv.jabref.org
jablib/src/main/resources/csl-styles
jablib/src/main/resources/csl-locales
- name: Submodules modified
if: steps.changes.outputs.any_changed == 'true'
run: |
echo "❌ Submodule modifications detected"
exit 1
other_than_main:
name: Source branch is other than "main"
if: github.actor != 'dependabot[bot]' && github.event.pull_request.head.repo.full_name != 'JabRef/jabref'
runs-on: ubuntu-latest
steps:
- if: github.head_ref == 'main'
uses: actions/github-script@v7
with:
script: |
core.setFailed('Pull requests should come from a branch other than "main"\n\n👉 Please read [the CONTRIBUTING guide](https://github.com/JabRef/jabref/blob/main/CONTRIBUTING.md#contributing) carefully again. 👈')