-
-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'beta' into CakeTracker
- Loading branch information
Showing
280 changed files
with
3,635 additions
and
2,230 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: "PR Changelog Verification" | ||
|
||
on: | ||
pull_request_target: | ||
types: [ opened, edited ] | ||
|
||
jobs: | ||
verify-changelog: | ||
if: github.event.pull_request.state == 'open' && '511310721' == github.repository_id | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- uses: ./.github/actions/setup-normal-workspace | ||
|
||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
|
||
- name: Run ChangeLog verification | ||
env: | ||
PR_TITLE: ${{ github.event.pull_request.title }} | ||
PR_BODY: ${{ github.event.pull_request.body }} | ||
run: | | ||
./gradlew checkPrDescription -PprTitle="${PR_TITLE}" -PprBody="${PR_BODY}" | ||
- name: Add label if changelog verification fails | ||
if: failure() | ||
uses: actions-ecosystem/action-add-labels@v1 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
labels: 'Wrong Title/Changelog' | ||
|
||
- name: Remove label if changelog verification passes | ||
if: success() | ||
uses: actions-ecosystem/action-remove-labels@v1 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
labels: 'Wrong Title/Changelog' | ||
|
||
- name: Add comment to PR if changelog verification fails | ||
if: failure() | ||
uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const fs = require('fs'); | ||
const test = fs.readFileSync('versions/1.8.9/build/changelog_errors.txt', 'utf8'); | ||
const commentBody = `${test}` | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: commentBody | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
maven("https://jitpack.io") { | ||
content { | ||
includeGroupByRegex("com\\.github\\..*") | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation("org.jetbrains.kotlin:kotlin-stdlib") | ||
implementation("com.github.SkyHanniStudios:SkyHanniChangelogBuilder:1.0.1") | ||
} |
64 changes: 64 additions & 0 deletions
64
buildSrc/src/main/kotlin/skyhannibuildsystem/ChangelogVerification.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package skyhannibuildsystem | ||
|
||
import at.hannibal2.changelog.SkyHanniChangelogBuilder | ||
import org.gradle.api.DefaultTask | ||
import org.gradle.api.GradleException | ||
import org.gradle.api.file.DirectoryProperty | ||
import org.gradle.api.tasks.Input | ||
import org.gradle.api.tasks.Internal | ||
import org.gradle.api.tasks.OutputDirectory | ||
import org.gradle.api.tasks.TaskAction | ||
import java.io.File | ||
|
||
abstract class ChangelogVerification : DefaultTask() { | ||
|
||
@get:OutputDirectory | ||
abstract val outputDirectory: DirectoryProperty | ||
|
||
@Input | ||
var prTitle: String = "" | ||
|
||
@Input | ||
var prBody: String = "" | ||
|
||
@get:Internal | ||
val prBodyLines get() = prBody.lines() | ||
|
||
private val prLink = "ignored" | ||
private val templateLocation = "https://github.com/hannibal002/SkyHanni/blob/beta/pull_request_template.md" | ||
|
||
@TaskAction | ||
fun scanChangelog() { | ||
if (prBodyLines.contains("exclude_from_changelog")) { | ||
println("PR is excluded from changelog verification") | ||
return | ||
} | ||
|
||
val (changes, bodyErrors) = SkyHanniChangelogBuilder.findChanges(prBodyLines, prLink) | ||
val titleErrors = SkyHanniChangelogBuilder.findPullRequestNameErrors(prTitle, changes) | ||
|
||
if (bodyErrors.isEmpty() && titleErrors.isEmpty()) { | ||
println("Changelog and title verification successful") | ||
} else { | ||
bodyErrors.forEach { println(it.message) } | ||
titleErrors.forEach { println(it.message) } | ||
|
||
// Export errors so that they can be listed in the PR comment | ||
val errorFile = File(outputDirectory.get().asFile, "changelog_errors.txt") | ||
println("saved error file to: ${errorFile.path}") | ||
|
||
errorFile.appendText("I have detected some issues with your pull request:\n\n") | ||
|
||
if (bodyErrors.isNotEmpty()) { | ||
errorFile.appendText("Body issues:\n${bodyErrors.joinToString("\n") { it.formatLine() }}\n\n") | ||
} | ||
if (titleErrors.isNotEmpty()) { | ||
errorFile.appendText("Title issues:\n${titleErrors.joinToString("\n") { it.message }}\n\n") | ||
} | ||
|
||
errorFile.appendText("Please fix these issues. For the correct format, refer to the [pull request template]($templateLocation).") | ||
|
||
throw GradleException("Changelog verification failed") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.