Skip to content

Commit

Permalink
Merge branch 'hannibal002:beta' into feature/snake
Browse files Browse the repository at this point in the history
  • Loading branch information
j10a1n15 authored Sep 26, 2024
2 parents 2ba2b9a + 092a29d commit 6cd5bee
Show file tree
Hide file tree
Showing 159 changed files with 2,581 additions and 772 deletions.
13 changes: 13 additions & 0 deletions .github/actions/setup-normal-workspace/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: 'Setup Java, Gradle and check out the source code'

runs:
using: composite
steps:
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 21
cache: gradle
- name: Setup gradle
uses: gradle/actions/setup-gradle@v4
37 changes: 37 additions & 0 deletions .github/scripts/process_detekt_sarif.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

# This script processes the Detekt SARIF file and outputs results in a format
# suitable for annotation in CI/CD systems.

SARIF_FILE="$1"

# Check if SARIF file exists
if [ ! -f "$SARIF_FILE" ]; then
echo "SARIF file not found: $SARIF_FILE"
exit 1
fi

# Define jq command to parse SARIF file
read -r -d '' jq_command <<'EOF'
.runs[].results[] |
{
"full_path": .locations[].physicalLocation.artifactLocation.uri | sub("file://$(pwd)/"; ""),
"file_name": (.locations[].physicalLocation.artifactLocation.uri | split("/") | last),
"l": .locations[].physicalLocation,
"level": .level,
"message": .message.text,
"ruleId": .ruleId
} |
(
"::" + (.level) +
" file=" + (.full_path) +
",line=" + (.l.region.startLine|tostring) +
",title=" + (.ruleId) +
",col=" + (.l.region.startColumn|tostring) +
",endColumn=" + (.l.region.endColumn|tostring) +
"::" + (.message.text)
)
EOF

# Run jq command to format the output
jq -r "$jq_command" < "$SARIF_FILE"
42 changes: 24 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,9 @@ jobs:
runs-on: ubuntu-latest
name: "Build and test"
steps:
- uses: actions/checkout@v3
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: 21
distribution: temurin
cache: gradle
- name: Setup gradle
uses: gradle/gradle-build-action@v2
- name: Checkout code
uses: actions/checkout@v4
- uses: ./.github/actions/setup-normal-workspace
- name: Build with Gradle
run: ./gradlew assemble -x test --stacktrace
- uses: actions/upload-artifact@v3
Expand All @@ -42,19 +36,31 @@ jobs:
with:
name: "Test Results"
path: versions/1.8.9/build/reports/tests/test/
#detekt:
# name: Run detekt
# runs-on: ubuntu-latest

# steps:
# - name: Checkout code
# uses: actions/checkout@v4
# - uses: ./.github/actions/setup-normal-workspace
# - name: Run detekt
# run: |
# ./gradlew detekt --stacktrace
# - name: Annotate detekt failures
# if: ${{ !cancelled() }}
# run: |
# chmod +x .github/scripts/process_detekt_sarif.sh
# ./.github/scripts/process_detekt_sarif.sh versions/1.8.9/build/reports/detekt/detekt.sarif


preprocess:
runs-on: ubuntu-latest
name: "Build multi version"
steps:
- uses: actions/checkout@v3
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: 21
distribution: temurin
cache: gradle
- name: Setup gradle
uses: gradle/gradle-build-action@v2
- name: Checkout code
uses: actions/checkout@v4
- uses: ./.github/actions/setup-normal-workspace
- name: Enable preprocessor
run: |
mkdir -p .gradle
Expand Down
16 changes: 0 additions & 16 deletions .github/workflows/check-style.yaml.disabled

This file was deleted.

3 changes: 2 additions & 1 deletion .github/workflows/illegal-imports.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

at/hannibal2/skyhanni/ scala.
at/hannibal2/skyhanni/ jline.
at/hannibal2/skyhanni/ io.github.moulberry.notenoughupdates.util.Constants
at/hannibal2/skyhanni/ io.github.moulberry.notenoughupdates.events.SlotClickEvent
at/hannibal2/skyhanni/ io.github.moulberry.notenoughupdates.events.ReplaceItemEvent
at/hannibal2/skyhanni/ io.github.moulberry.notenoughupdates.util.Constants
at/hannibal2/skyhanni/ io.github.moulberry.notenoughupdates.util.Utils
at/hannibal2/skyhanni/ java.util.function.Supplier
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
!.idea/icon.svg
!.idea/dictionaries/default_user.xml
!.idea/scopes/Mixins.xml
!.idea/liveTemplates/SkyHanni.xml
.vscode/
run/
build/
Expand Down
3 changes: 2 additions & 1 deletion .idea/dictionaries/default_user.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

101 changes: 101 additions & 0 deletions .idea/liveTemplates/SkyHanni.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ format like "- #821" to illustrate the dependency.
- Follow the [Hypixel Rules](https://hypixel.net/rules).
- Use the coding conventions for [Kotlin](https://kotlinlang.org/docs/coding-conventions.html)
and [Java](https://www.oracle.com/java/technologies/javase/codeconventions-contents.html).
- **My build is failing due to `detekt`, what do I do?**
- `detekt` is our code quality tool. It checks for code smells and style issues.
- If you have a build failure stating `Analysis failed with ... weighted issues.`, you can check `versions/[target version]/build/reports/detekt/` for a comprehensive list of issues.
- **There are valid reasons to deviate from the norm**
- If you have such a case, either use `@Supress("rule_name")`, or re-build the `baseline.xml` file, using `./gradlew detektBaseline`.
- Do not copy features from other mods. Exceptions:
- Mods that are paid to use.
- Mods that have reached their end of life. (Rip SBA, Dulkir and Soopy).
Expand Down
69 changes: 44 additions & 25 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import at.skyhanni.sharedvariables.MultiVersionStage
import at.skyhanni.sharedvariables.ProjectTarget
import at.skyhanni.sharedvariables.SHVersionInfo
import at.skyhanni.sharedvariables.versionString
import io.gitlab.arturbosch.detekt.Detekt
import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask
import net.fabricmc.loom.task.RunGameTask
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
Expand All @@ -18,31 +20,12 @@ plugins {
kotlin("plugin.power-assert")
`maven-publish`
id("moe.nea.shot") version "1.0.0"
id("io.gitlab.arturbosch.detekt")
id("net.kyori.blossom")
}

val target = ProjectTarget.values().find { it.projectPath == project.path }!!

repositories {
mavenCentral()
mavenLocal()
maven("https://maven.minecraftforge.net") {
metadataSources {
artifact() // We love missing POMs
}
}
maven("https://repo.spongepowered.org/maven/") // mixin
maven("https://pkgs.dev.azure.com/djtheredstoner/DevAuth/_packaging/public/maven/v1") // DevAuth
maven("https://jitpack.io") { // NotEnoughUpdates (compiled against)
content {
includeGroupByRegex("(com|io)\\.github\\..*")
}
}
maven("https://repo.nea.moe/releases") // libautoupdate
maven("https://maven.notenoughupdates.org/releases") // NotEnoughUpdates (dev env)
maven("https://repo.hypixel.net/repository/Hypixel/") // mod-api
maven("https://maven.teamresourceful.com/repository/thatgravyboat/") // DiscordIPC
}

// Toolchains:
java {
toolchain.languageVersion.set(target.minecraftVersion.javaLanguageVersion)
Expand Down Expand Up @@ -159,9 +142,9 @@ dependencies {
exclude(module = "unspecified")
isTransitive = false
}
// June 3, 2024, 9:30 PM AEST
// https://github.com/NotEnoughUpdates/NotEnoughUpdates/tree/2.3.0
devenvMod("com.github.NotEnoughUpdates:NotEnoughUpdates:2.3.0:all") {
// August 27, 2024, 4:30 PM AEST
// https://github.com/NotEnoughUpdates/NotEnoughUpdates/tree/2.3.3
devenvMod("com.github.NotEnoughUpdates:NotEnoughUpdates:2.3.3:all") {
exclude(module = "unspecified")
isTransitive = false
}
Expand All @@ -177,10 +160,14 @@ dependencies {
exclude(module = "unspecified")
isTransitive = false
}
testImplementation("org.junit.jupiter:junit-jupiter:5.10.0")
testImplementation("org.junit.jupiter:junit-jupiter:5.11.0")
testImplementation("io.mockk:mockk:1.12.5")

implementation("net.hypixel:mod-api:0.3.1")

detektPlugins("org.notenoughupdates:detektrules:1.0.0")
detektPlugins(project(":detekt"))
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.7")
}

afterEvaluate {
Expand Down Expand Up @@ -312,12 +299,18 @@ if (!MultiVersionStage.activeState.shouldCompile(target)) {
onlyIf { false }
}
}

preprocess {
vars.put("MC", target.minecraftVersion.versionNumber)
vars.put("FORGE", if (target.forgeDep != null) 1 else 0)
vars.put("JAVA", target.minecraftVersion.javaVersion)
patternAnnotation.set("at.hannibal2.skyhanni.utils.compat.Pattern")
}

blossom {
replaceToken("@MOD_VERSION@", version)
}

val sourcesJar by tasks.creating(Jar::class) {
destinationDirectory.set(layout.buildDirectory.dir("badjars"))
archiveClassifier.set("src")
Expand All @@ -343,3 +336,29 @@ publishing.publications {
}
}
}

// Detekt: TODO: Uncomment this when we're ready to enforce
/*detekt {
buildUponDefaultConfig = true // preconfigure defaults
config.setFrom(rootProject.layout.projectDirectory.file("detekt/detekt.yml")) // point to your custom config defining rules to run, overwriting default behavior
baseline = file(layout.projectDirectory.file("detekt/baseline.xml")) // a way of suppressing issues before introducing detekt
source.setFrom(project.sourceSets.named("main").map { it.allSource })
}
tasks.withType<Detekt>().configureEach {
reports {
html.required.set(true) // observe findings in your browser with structure and code snippets
xml.required.set(true) // checkstyle like format mainly for integrations like Jenkins
sarif.required.set(true) // standardized SARIF format (https://sarifweb.azurewebsites.net/) to support integrations with GitHub Code Scanning
md.required.set(true) // simple Markdown format
}
}
tasks.withType<Detekt>().configureEach {
jvmTarget = target.minecraftVersion.formattedJavaLanguageVersion
outputs.cacheIf { false } // Custom rules won't work if cached
}
tasks.withType<DetektCreateBaselineTask>().configureEach {
jvmTarget = target.minecraftVersion.formattedJavaLanguageVersion
outputs.cacheIf { false } // Custom rules won't work if cached
}*/
Loading

0 comments on commit 6cd5bee

Please sign in to comment.