Skip to content

Commit 1754020

Browse files
authored
Add PR validations to improve maintainability (#143)
Resolves #26
1 parent 46832ce commit 1754020

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

.github/workflows/pull_request.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,19 @@ jobs:
5656
upload-code-coverage: true
5757
secrets:
5858
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
59+
danger-check:
60+
runs-on: ubuntu-latest
61+
permissions:
62+
pull-requests: write
63+
statuses: write
64+
steps:
65+
- name: 'Checkout Repository'
66+
uses: actions/checkout@v4
67+
- name: Danger
68+
uses: danger/[email protected]
69+
with:
70+
run-mode: ci
71+
dangerfile: Dangerfile.df.kts
72+
env:
73+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
74+

Dangerfile.df.kts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
@file:Suppress("ktlint:standard:no-wildcard-imports")
2+
3+
import systems.danger.kotlin.*
4+
5+
danger(args) {
6+
onGitHub {
7+
val prLabels = issue.labels
8+
when (prLabels.size) {
9+
0 -> fail("PR must have labels")
10+
1 ->
11+
prLabels.find { it.name.equals("ignore", ignoreCase = true) }?.let {
12+
warn("PR must have labels other then '[${it.name}](${it.url})'")
13+
}
14+
else -> {}
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)