mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-02-20 17:05:32 +01:00
Testing testing
- Use 2 spaces for indents yaml - Move setupTestMod to PlatformExtension - Allow specifying the sourceSet for the testMod artifact - Rename things to camelCase - Use rootCompile from transitiveSourceSets for the testMod source sets - Use a blanket remapTestModJar task in the gh actions build
This commit is contained in:
parent
cefc61a7d6
commit
491d134edf
10 changed files with 107 additions and 104 deletions
|
@ -9,6 +9,9 @@ charset = utf-8
|
|||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.yml]
|
||||
indent_size = 2
|
||||
|
||||
[*.json]
|
||||
indent_size = 2
|
||||
max_line_length = 500
|
||||
|
|
133
.github/workflows/build.yml
vendored
133
.github/workflows/build.yml
vendored
|
@ -3,80 +3,81 @@ name: Build
|
|||
on: [ pull_request, push ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Java
|
||||
run: echo "JAVA_HOME=$JAVA_HOME_17_X64" >> "$GITHUB_ENV"
|
||||
- name: Setup Java
|
||||
run: echo "JAVA_HOME=$JAVA_HOME_17_X64" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Loom Cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: "**/.gradle/loom-cache"
|
||||
key: "${{ runner.os }}-gradle-${{ hashFiles('**/libs.versions.*', '**/*.gradle*', '**/gradle-wrapper.properties') }}"
|
||||
restore-keys: "${{ runner.os }}-gradle-"
|
||||
- name: Loom Cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: "**/.gradle/loom-cache"
|
||||
key: "${{ runner.os }}-gradle-${{ hashFiles('**/libs.versions.*', '**/*.gradle*', '**/gradle-wrapper.properties') }}"
|
||||
restore-keys: "${{ runner.os }}-gradle-"
|
||||
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@v3
|
||||
with:
|
||||
gradle-home-cache-cleanup: true
|
||||
cache-read-only: ${{ !endsWith(github.ref_name, '/dev') }}
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@v3
|
||||
with:
|
||||
gradle-home-cache-cleanup: true
|
||||
cache-read-only: ${{ !endsWith(github.ref_name, '/dev') }}
|
||||
|
||||
- name: Validate Gradle Wrapper Integrity
|
||||
uses: gradle/wrapper-validation-action@v2
|
||||
- name: Validate Gradle Wrapper Integrity
|
||||
uses: gradle/wrapper-validation-action@v2
|
||||
|
||||
- name: Build
|
||||
# doesn't actually publish, as no secrets are passed in, just makes sure that publishing works
|
||||
run: ./gradlew :forge:remapTestmodJar :fabric:remapTestmodJar publish --no-daemon
|
||||
- name: Build
|
||||
# Doesn't actually publish, as no secrets are passed in, just makes sure that publishing works
|
||||
# Also generate the mod jars for the test job
|
||||
run: ./gradlew remapTestModJar publish --no-daemon
|
||||
|
||||
- name: Capture Build Artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: Artifacts
|
||||
path: |
|
||||
common/build/libs/
|
||||
fabric/build/libs/
|
||||
fabric/build/devlibs/
|
||||
forge/build/libs/
|
||||
forge/build/devlibs/
|
||||
- name: Capture Build Artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: Artifacts
|
||||
path: |
|
||||
common/build/libs/
|
||||
fabric/build/libs/
|
||||
fabric/build/devlibs/
|
||||
forge/build/libs/
|
||||
forge/build/devlibs/
|
||||
|
||||
test:
|
||||
strategy:
|
||||
matrix:
|
||||
loader: [ forge, fabric ]
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
test:
|
||||
strategy:
|
||||
matrix:
|
||||
loader: [ forge, fabric ]
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Download build artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: Artifacts
|
||||
- name: Download build artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: Artifacts
|
||||
|
||||
- name: Setup Environment Variables
|
||||
run: |
|
||||
echo "MOD_VERSION=$(grep '^mod_version =' gradle.properties | cut -d'=' -f2 | tr -d ' ')" >> "$GITHUB_ENV"
|
||||
echo "MINECRAFT_VERSION=$(grep '^minecraft_version =' gradle.properties | cut -d'=' -f2 | tr -d ' ')" >> "$GITHUB_ENV"
|
||||
echo "FABRIC_API_VERSION=$(grep '^fabric_api_version =' gradle.properties | cut -d'=' -f2 | tr -d ' ' | sed 's/+.*//')" >> "$GITHUB_ENV"
|
||||
- name: Setup Environment Variables
|
||||
run: |
|
||||
echo "MOD_VERSION=$(grep '^mod_version =' gradle.properties | cut -d'=' -f2 | tr -d ' ')" >> "$GITHUB_ENV"
|
||||
echo "MINECRAFT_VERSION=$(grep '^minecraft_version =' gradle.properties | cut -d'=' -f2 | tr -d ' ')" >> "$GITHUB_ENV"
|
||||
echo "FABRIC_API_VERSION=$(grep '^fabric_api_version =' gradle.properties | cut -d'=' -f2 | tr -d ' ' | sed 's/+.*//')" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Move Test Mod and Flywheel into run/mods
|
||||
run: |
|
||||
mkdir -p run/mods
|
||||
cp ${{ matrix.loader }}/build/libs/flywheel-${{ matrix.loader }}-${{ env.MINECRAFT_VERSION }}-${{ env.MOD_VERSION }}.jar run/mods
|
||||
cp ${{ matrix.loader }}/build/devlibs/flywheel-${{ matrix.loader }}-${{ env.MINECRAFT_VERSION }}-${{ env.MOD_VERSION }}-testmod.jar run/mods
|
||||
- name: Move Test Mod and Flywheel into run/mods
|
||||
run: |
|
||||
mkdir -p run/mods
|
||||
cp ${{ matrix.loader }}/build/libs/flywheel-${{ matrix.loader }}-${{ env.MINECRAFT_VERSION }}-${{ env.MOD_VERSION }}.jar run/mods
|
||||
cp ${{ matrix.loader }}/build/devlibs/flywheel-${{ matrix.loader }}-${{ env.MINECRAFT_VERSION }}-${{ env.MOD_VERSION }}-testmod.jar run/mods
|
||||
|
||||
# Lock to a specific commit, it would be bad if the tag is re-pushed with unwanted changes
|
||||
- name: Run the MC client
|
||||
uses: 3arthqu4ke/mc-runtime-test@e72f8fe1134aabf6fc749a2a8c09bb56dd7d283e
|
||||
with:
|
||||
mc: ${{ env.MINECRAFT_VERSION }}
|
||||
modloader: ${{ matrix.loader }}
|
||||
regex: .*${{ matrix.loader }}.*
|
||||
mc-runtime-test: none
|
||||
java: 17
|
||||
fabric-api: ${{ matrix.loader == 'fabric' && env.FABRIC_API_VERSION || 'none' }}
|
||||
# Lock to a specific commit, it would be bad if the tag is re-pushed with unwanted changes
|
||||
- name: Run the MC client
|
||||
uses: 3arthqu4ke/mc-runtime-test@e72f8fe1134aabf6fc749a2a8c09bb56dd7d283e
|
||||
with:
|
||||
mc: ${{ env.MINECRAFT_VERSION }}
|
||||
modloader: ${{ matrix.loader }}
|
||||
regex: .*${{ matrix.loader }}.*
|
||||
mc-runtime-test: none
|
||||
java: 17
|
||||
fabric-api: ${{ matrix.loader == 'fabric' && env.FABRIC_API_VERSION || 'none' }}
|
||||
|
|
|
@ -2,17 +2,17 @@ package dev.engine_room.gradle.platform
|
|||
|
||||
import dev.engine_room.gradle.jarset.JarTaskSet
|
||||
import net.fabricmc.loom.api.LoomGradleExtensionAPI
|
||||
import net.fabricmc.loom.task.RemapJarTask
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.Task
|
||||
import org.gradle.api.tasks.SourceSet
|
||||
import org.gradle.api.tasks.SourceSetContainer
|
||||
import org.gradle.api.tasks.compile.JavaCompile
|
||||
import org.gradle.api.tasks.javadoc.Javadoc
|
||||
import org.gradle.jvm.tasks.Jar
|
||||
import org.gradle.kotlin.dsl.named
|
||||
import org.gradle.kotlin.dsl.provideDelegate
|
||||
import org.gradle.kotlin.dsl.the
|
||||
import org.gradle.kotlin.dsl.withType
|
||||
import org.gradle.kotlin.dsl.*
|
||||
import org.gradle.language.jvm.tasks.ProcessResources
|
||||
import java.io.File
|
||||
import kotlin.properties.ReadWriteProperty
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
|
@ -102,6 +102,29 @@ open class PlatformExtension(val project: Project) {
|
|||
}
|
||||
}
|
||||
|
||||
fun setupTestMod(sourceSet: SourceSet) {
|
||||
project.tasks.apply {
|
||||
val testModJar = register<Jar>("testModJar") {
|
||||
from(sourceSet.output)
|
||||
val file = File(project.layout.buildDirectory.asFile.get(), "devlibs");
|
||||
destinationDirectory.set(file)
|
||||
archiveClassifier = "testmod"
|
||||
}
|
||||
|
||||
val remapTestModJar = register<RemapJarTask>("remapTestModJar") {
|
||||
dependsOn(testModJar)
|
||||
inputFile.set(testModJar.get().archiveFile)
|
||||
archiveClassifier = "testmod"
|
||||
addNestedDependencies = false
|
||||
classpath.from(sourceSet.compileClasspath)
|
||||
}
|
||||
|
||||
named<Task>("build").configure {
|
||||
dependsOn(remapTestModJar)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class DependentProject(private val thisProject: Project) : ReadWriteProperty<Any?, Project> {
|
||||
private var value: Project? = null
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import dev.engine_room.gradle.jarset.JarSetExtension
|
|||
import dev.engine_room.gradle.nullability.PackageInfosExtension
|
||||
import dev.engine_room.gradle.transitive.TransitiveSourceSetsExtension
|
||||
import net.fabricmc.loom.api.LoomGradleExtensionAPI
|
||||
import net.fabricmc.loom.task.RemapJarTask
|
||||
import org.gradle.api.JavaVersion
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
|
@ -12,7 +11,6 @@ import org.gradle.api.plugins.BasePluginExtension
|
|||
import org.gradle.api.plugins.JavaPluginExtension
|
||||
import org.gradle.api.publish.PublishingExtension
|
||||
import org.gradle.api.publish.tasks.GenerateModuleMetadata
|
||||
import org.gradle.api.tasks.SourceSetContainer
|
||||
import org.gradle.api.tasks.bundling.AbstractArchiveTask
|
||||
import org.gradle.api.tasks.compile.JavaCompile
|
||||
import org.gradle.api.tasks.javadoc.Javadoc
|
||||
|
@ -20,7 +18,6 @@ import org.gradle.jvm.tasks.Jar
|
|||
import org.gradle.jvm.toolchain.JavaLanguageVersion
|
||||
import org.gradle.kotlin.dsl.*
|
||||
import org.gradle.language.jvm.tasks.ProcessResources
|
||||
import java.io.File
|
||||
|
||||
class SubprojectPlugin: Plugin<Project> {
|
||||
override fun apply(project: Project) {
|
||||
|
@ -35,9 +32,6 @@ class SubprojectPlugin: Plugin<Project> {
|
|||
setupDependencies(project)
|
||||
configureTasks(project)
|
||||
setupPublishing(project)
|
||||
|
||||
if (project.path != ":common")
|
||||
setupTestMod(project)
|
||||
}
|
||||
|
||||
private fun setBaseProperties(project: Project) {
|
||||
|
@ -170,26 +164,6 @@ class SubprojectPlugin: Plugin<Project> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupTestMod(project: Project) {
|
||||
val sourceSets = project.extensions.getByName("sourceSets") as SourceSetContainer
|
||||
|
||||
val testmodJar = project.tasks.register<Jar>("testmodJar") {
|
||||
from (sourceSets["testmod"].output)
|
||||
val file = File(project.layout.buildDirectory.asFile.get(), "devlibs");
|
||||
destinationDirectory.set(file)
|
||||
archiveClassifier = "testmod"
|
||||
}
|
||||
|
||||
val remapTestmodJar = project.tasks.register<RemapJarTask>("remapTestmodJar") {
|
||||
dependsOn(testmodJar)
|
||||
inputFile.set(testmodJar.get().archiveFile)
|
||||
archiveClassifier = "testmod"
|
||||
addNestedDependencies = false
|
||||
classpath.from(sourceSets["testmod"].compileClasspath)
|
||||
}
|
||||
project.tasks["build"].dependsOn(remapTestmodJar)
|
||||
}
|
||||
}
|
||||
|
||||
val processResourcesExpandFiles = listOf("pack.mcmeta", "fabric.mod.json", "META-INF/mods.toml")
|
||||
|
|
|
@ -12,10 +12,7 @@ val lib = sourceSets.create("lib")
|
|||
val backend = sourceSets.create("backend")
|
||||
val stubs = sourceSets.create("stubs")
|
||||
val main = sourceSets.getByName("main")
|
||||
val testmod = sourceSets.create("testmod") {
|
||||
compileClasspath += main.compileClasspath
|
||||
runtimeClasspath += main.runtimeClasspath
|
||||
}
|
||||
val testMod = sourceSets.create("testMod")
|
||||
|
||||
transitiveSourceSets {
|
||||
compileClasspath = main.compileClasspath
|
||||
|
@ -39,6 +36,9 @@ transitiveSourceSets {
|
|||
compile(stubs)
|
||||
implementation(api, lib, backend)
|
||||
}
|
||||
sourceSet(testMod) {
|
||||
rootCompile()
|
||||
}
|
||||
|
||||
createCompileConfigurations()
|
||||
}
|
||||
|
@ -49,6 +49,7 @@ platform {
|
|||
setupLoomMod(api, lib, backend, main)
|
||||
setupLoomRuns()
|
||||
setupFatJar(api, lib, backend, main)
|
||||
setupTestMod(testMod)
|
||||
}
|
||||
|
||||
jarSets {
|
||||
|
|
|
@ -12,10 +12,7 @@ val lib = sourceSets.create("lib")
|
|||
val backend = sourceSets.create("backend")
|
||||
val stubs = sourceSets.create("stubs")
|
||||
val main = sourceSets.getByName("main")
|
||||
val testmod = sourceSets.create("testmod") {
|
||||
compileClasspath += main.compileClasspath
|
||||
runtimeClasspath += main.runtimeClasspath
|
||||
}
|
||||
val testMod = sourceSets.create("testMod")
|
||||
|
||||
transitiveSourceSets {
|
||||
compileClasspath = main.compileClasspath
|
||||
|
@ -37,6 +34,9 @@ transitiveSourceSets {
|
|||
sourceSet(main) {
|
||||
compile(api, lib, backend, stubs)
|
||||
}
|
||||
sourceSet(testMod) {
|
||||
rootCompile()
|
||||
}
|
||||
|
||||
createCompileConfigurations()
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ platform {
|
|||
setupLoomMod(api, lib, backend, main)
|
||||
setupLoomRuns()
|
||||
setupFatJar(api, lib, backend, main)
|
||||
setupTestMod(testMod)
|
||||
}
|
||||
|
||||
jarSets {
|
||||
|
|
Loading…
Add table
Reference in a new issue