Skip to content

Commit

Permalink
Merge branch 'ms5' into 'alpha'
Browse files Browse the repository at this point in the history
Various improvements and refactorings

See merge request Griefed/ServerPackCreator!516
  • Loading branch information
Griefed committed Aug 11, 2023
2 parents cca5573 + 22c485f commit 3367ca6
Show file tree
Hide file tree
Showing 71 changed files with 1,551 additions and 526 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/qodana.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Qodana Scan
on:
workflow_dispatch:
pull_request:
push:

jobs:
qodana:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
checks: write
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit
fetch-depth: 0 # a full history is required for pull request analysis
- name: 'Qodana Scan'
uses: JetBrains/[email protected]
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }} # read the steps about it below
26 changes: 13 additions & 13 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ variables:
GRADLE_USER_HOME: "$CI_PROJECT_DIR/.gradle"

services:
- name: ghcr.io/griefed/gitlab-ci-cd:2.2.9
- name: docker.griefed.dev/griefed/gitlab-ci-cd:2.2.9
alias: docker

workflow:
Expand All @@ -27,7 +27,7 @@ workflow:

Build Test:
stage: Tests
image: ghcr.io/griefed/baseimage-ubuntu-jdk17-kotlin:1.0.4
image: docker.griefed.dev/griefed/baseimage-ubuntu-jdk17-kotlin:1.0.4
before_script:
- echo "**** Running in $CI_JOB_ID ****"
- echo "**** Java location ****"
Expand Down Expand Up @@ -77,7 +77,7 @@ Build Test:
# TODO reactivate with milestone 6
#Docker Test:
# stage: Tests
# image: ghcr.io/griefed/gitlab-ci-cd:2.2.1
# image: docker.griefed.dev/griefed/gitlab-ci-cd:2.2.1
# needs:
# - job: Build Test
# artifacts: true
Expand All @@ -94,7 +94,7 @@ Build Test:

Generate Release:
stage: Release
image: ghcr.io/griefed/gitlab-ci-cd:2.2.9
image: docker.griefed.dev/griefed/gitlab-ci-cd:2.2.9
needs:
- job: Build Test
artifacts: false
Expand All @@ -109,7 +109,7 @@ Generate Release:

Build Release:
stage: Build Release
image: ghcr.io/griefed/baseimage-ubuntu-jdk17-kotlin:1.0.4
image: docker.griefed.dev/griefed/baseimage-ubuntu-jdk17-kotlin:1.0.4
needs:
- job: Build Test
artifacts: false
Expand Down Expand Up @@ -158,7 +158,7 @@ Build Release:

Sign Java Publication:
stage: Build Release
image: ghcr.io/griefed/baseimage-ubuntu-jdk17-kotlin:1.0.4
image: docker.griefed.dev/griefed/baseimage-ubuntu-jdk17-kotlin:1.0.4
needs:
- job: Build Release
artifacts: false
Expand Down Expand Up @@ -188,7 +188,7 @@ Sign Java Publication:

Publish GitHub:
stage: Build Release
image: ghcr.io/griefed/baseimage-ubuntu-jdk17-kotlin:1.0.4
image: docker.griefed.dev/griefed/baseimage-ubuntu-jdk17-kotlin:1.0.4
needs:
- job: Sign Java Publication
optional: false
Expand All @@ -210,7 +210,7 @@ Publish GitHub:

Publish GitLab:
stage: Build Release
image: ghcr.io/griefed/baseimage-ubuntu-jdk17-kotlin:1.0.4
image: docker.griefed.dev/griefed/baseimage-ubuntu-jdk17-kotlin:1.0.4
needs:
- job: Sign Java Publication
optional: false
Expand All @@ -232,7 +232,7 @@ Publish GitLab:

Publish GitGriefed:
stage: Build Release
image: ghcr.io/griefed/baseimage-ubuntu-jdk17-kotlin:1.0.4
image: docker.griefed.dev/griefed/baseimage-ubuntu-jdk17-kotlin:1.0.4
needs:
- job: Sign Java Publication
optional: false
Expand All @@ -254,7 +254,7 @@ Publish GitGriefed:

Publish OSSRH:
stage: Build Release
image: ghcr.io/griefed/baseimage-ubuntu-jdk17-kotlin:1.0.4
image: docker.griefed.dev/griefed/baseimage-ubuntu-jdk17-kotlin:1.0.4
needs:
- job: Sign Java Publication
optional: false
Expand All @@ -277,7 +277,7 @@ Publish OSSRH:
# TODO reactivate with milestone 6
#Build Docker Release:
# stage: Build Release
# image: ghcr.io/griefed/gitlab-ci-cd:2.2.1
# image: docker.griefed.dev/griefed/gitlab-ci-cd:2.2.1
# needs:
# - job: Build Test
# artifacts: true
Expand All @@ -301,7 +301,7 @@ Publish OSSRH:
# TODO reactivate with milestone 6
#Build Docker PreRelease:
# stage: Build Release
# image: ghcr.io/griefed/gitlab-ci-cd:2.2.1
# image: docker.griefed.dev/griefed/gitlab-ci-cd:2.2.1
# needs:
# - job: Build Test
# artifacts: true
Expand All @@ -322,7 +322,7 @@ Publish OSSRH:

pages:
stage: Documentation
image: ghcr.io/griefed/baseimage-ubuntu-jdk17-kotlin:1.0.4
image: docker.griefed.dev/griefed/baseimage-ubuntu-jdk17-kotlin:1.0.4
allow_failure: true
before_script:
- which java
Expand Down
35 changes: 35 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Security Policy

## Supported Versions

Only releases of the latest major-minor-release-line are supported.

For example, if the latest major-release-line is 4.1.x, then the following matrix would apply:

| Version | Supported |
|---------|--------------------|
| 4.1.x | :white_check_mark: |
| 4.0.x | :x: |
| < 4.0 | :x: |
| 3.x.x | :x: |
| 2.x.x | :x: |
| 1.x.x | :x: |

Similarly, if the latest major-minor-release-line is 5.3.x, then the following matrix would apply:

| Version | Supported |
|---------|--------------------|
| 5.3.x | :white_check_mark: |
| 5.0.x | :x: |
| < 5.0 | :x: |
| 4.x.x | :x: |
| 3.x.x | :x: |
| 2.x.x | :x: |
| 1.x.x | :x: |

If a newer major-minor-line is released, keeping with the examples above, i.e. 4.2.x or 5.4.x, then the matrices above
should help you to determine which versions will receive security-updates.

## Reporting a Vulnerability

Vulnerabilities should always be reported on GitHub, at https://github.com/Griefed/ServerPackCreator/issues
3 changes: 3 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ idea {

allprojects {
repositories {
maven {
url = uri("https://nexus.griefed.dev/repository/maven-public/")
}
gradlePluginPortal()
google()
mavenCentral()
Expand Down
3 changes: 3 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ plugins {
}

repositories {
maven {
url = uri("https://nexus.griefed.dev/repository/maven-public/")
}
gradlePluginPortal()
google()
mavenCentral()
Expand Down
7 changes: 3 additions & 4 deletions qodana.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
version: "1.0"
linter: jetbrains/qodana-jvm-community:2022.2
projectJDK: 17
profile:
name: qodana.recommended
include:
- name: CheckDependencyLicenses
exclude:
- name: FieldMayBeStatic
- name: KotlinAnnotator
- name: KotlinRedundantDiagnosticSuppress
- name: SystemOutErr
- name: All
paths:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ configuration.log.error.checkcopydirs.read=No read-permission for {0}
configuration.log.error.checkcopydirs.checkforregex=Invalid regex entry: {0}
configuration.log.error.checkcopydirs.checkforregex.invalid=Entry must contain, or start with, ==
configuration.log.error.checkcopydirs.checkforregex.invalid.regex=Invalid regex specified: {0}. Error near regex-index {1}.
configuration.log.error.checkmodloader=Invalid modloader specified. Modloader must be either Forge, Fabric or Quilt.
configuration.log.error.checkmodloader=Invalid modloader specified. Modloader must be either Forge, NeoForge, Fabric, Quilt or LegacyFabric.
configuration.log.error.checkmodloaderversion=Specified incorrect modloader version. Please check your modpack for the correct version and enter again.
configuration.log.error.checkmodloaderandversion=Minecraft {0} and {1} {2} are not compatible.
configuration.log.error.isdir.copydir=There's something wrong with your setting of directories to include in your server pack.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import mu.KotlinLogging
abstract class Configuration<F, P> {
protected val log = KotlinLogging.logger {}
protected val forge = "^forge$".toRegex()
protected val neoForge = "^neoforge$".toRegex()

Check notice on line 36 in serverpackcreator-api/src/commonMain/kotlin/de/griefed/serverpackcreator/api/Configuration.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Class member can have 'private' visibility

Property 'neoForge' could be private
protected val fabric = "^fabric$".toRegex()
protected val quilt = "^quilt$".toRegex()
protected val legacyFabric = "^legacyfabric$".toRegex()
Expand Down Expand Up @@ -160,6 +161,7 @@ abstract class Configuration<F, P> {
*/
fun checkModloader(modloader: String) =
if (modloader.lowercase().matches(forge)
|| modloader.lowercase().matches(neoForge)
|| modloader.lowercase().matches(fabric)
|| modloader.lowercase().matches(quilt)
|| modloader.lowercase().matches(legacyFabric)
Expand Down Expand Up @@ -223,9 +225,7 @@ abstract class Configuration<F, P> {
* @author Griefed
*/
fun printEncounteredErrors(encounteredErrors: List<String>) {
log.error(
"Encountered ${encounteredErrors.size} errors during the configuration check."
)
log.error("Encountered ${encounteredErrors.size} errors during the configuration check.")
var encounteredErrorNumber: Int
for (i in encounteredErrors.indices) {
encounteredErrorNumber = i + 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import de.griefed.serverpackcreator.api.utilities.CommentedConfig
@Suppress("MemberVisibilityCanBePrivate")
abstract class Pack<F, J, out P> {
protected val forge = "^forge$".toRegex()
protected val neoForge = "^neoforge$".toRegex()
protected val fabric = "^fabric$".toRegex()
protected val quilt = "^quilt$".toRegex()
protected val legacyFabric = "^legacyfabric$".toRegex()
Expand All @@ -49,6 +50,8 @@ abstract class Pack<F, J, out P> {
set(newModLoader) {
if (newModLoader.lowercase().matches(forge)) {
field = "Forge"
} else if (newModLoader.lowercase().matches(neoForge)) {
field = "NeoForge"
} else if (newModLoader.lowercase().matches(fabric)) {
field = "Fabric"
} else if (newModLoader.lowercase().matches(quilt)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,8 @@ abstract class ServerPack<F, TS, TF> {
* file, a singular [ServerPackFile] is returned. If the source is a directory, then all
* files in said directory are returned.
*
* @param combination Array containing a source-file/directory;destination-file/directory
* combination.
* @param source source-file/directory
* @param destination destination-file/directory
* @param modpackDir The modpack-directory.
* @param serverPackDestination The destination, normally the server pack-directory.
* @return List of [ServerPackFile].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
*
* The full license can be found at https:github.com/Griefed/ServerPackCreator/blob/main/LICENSE
*/
@file:Suppress("DuplicatedCode")
@file:Suppress("DuplicatedCode", "unused")

package de.griefed.serverpackcreator.api.utilities.common

import kotlinx.coroutines.*
import mu.KotlinLogging
import kotlin.coroutines.CoroutineContext

/**
* Utility-class revolving around Lists.
Expand Down Expand Up @@ -229,11 +230,12 @@ fun <T> MutableCollection<T>.removeIf(filter: Affirm<in T>): Boolean {
*
* @author Griefed
*/
@OptIn(DelicateCoroutinesApi::class)
inline fun <A, B> List<A>.parallelMap(
dispatcher: CoroutineDispatcher = Dispatchers.Default,
context: CoroutineContext = newSingleThreadContext("parallelMap"),
crossinline function: suspend (A) -> B
): List<B> = runBlocking(dispatcher) {
map { async(dispatcher) { function(it) } }.awaitAll()
): List<B> = runBlocking(context) {
map { async { function(it) } }.awaitAll()
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ enum class Type {
*/
FORGE,

/**
* Indicates this operation concerns NeoForge.
*/
NEO_FORGE,

/**
* Indicates this operation concerns Fabric.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ package de.griefed.serverpackcreator.api.versionmeta
import de.griefed.serverpackcreator.api.utilities.URL
import de.griefed.serverpackcreator.api.versionmeta.fabric.FabricMeta
import de.griefed.serverpackcreator.api.versionmeta.forge.ForgeMeta
import de.griefed.serverpackcreator.api.versionmeta.neoforge.NeoForgeMeta
import de.griefed.serverpackcreator.api.versionmeta.legacyfabric.LegacyFabricMeta
import de.griefed.serverpackcreator.api.versionmeta.minecraft.MinecraftMeta
import de.griefed.serverpackcreator.api.versionmeta.quilt.QuiltMeta
Expand All @@ -48,6 +49,9 @@ expect class VersionMeta {
@Suppress("MemberVisibilityCanBePrivate")
val forgeUrlManifest: URL

@Suppress("MemberVisibilityCanBePrivate")
val neoForgeUrlManifest: URL

@Suppress("MemberVisibilityCanBePrivate")
val fabricUrlManifest: URL

Expand Down Expand Up @@ -81,6 +85,12 @@ expect class VersionMeta {
@Suppress("MemberVisibilityCanBePrivate")
val forge: ForgeMeta

/**
* The NeoForgeMeta-instance for working with NeoForge versions and information about them.
*/
@Suppress("MemberVisibilityCanBePrivate")
val neoForge: NeoForgeMeta

/**
* The QuiltMeta-instance for working with Quilt versions and information about them.
*/
Expand All @@ -92,5 +102,4 @@ expect class VersionMeta {
*/
@Suppress("MemberVisibilityCanBePrivate")
val legacyFabric: LegacyFabricMeta

}
Loading

0 comments on commit 3367ca6

Please sign in to comment.