Spin up a dedicated server on github actions + add run tasks for test mods. ()

* Add test mod run tasks, add a very basic auto test server task

* License header

* Minor cleanup

* Fix bad depends
This commit is contained in:
modmuss50 2020-11-15 19:06:27 +00:00
parent fca1ef16e4
commit 1cd3aea3db
5 changed files with 78 additions and 0 deletions
.github/workflows
build.gradle
fabric-api-base
build.gradle
src/testmod
java/net/fabricmc/fabric/test/base
resources

View file

@ -13,6 +13,8 @@ jobs:
- uses: actions/checkout@v1
- uses: gradle/wrapper-validation-action@v1
- run: ./gradlew check build publishToMavenLocal --stacktrace --parallel
- run: mkdir run && echo "eula=true" >> run/eula.txt
- run: ./gradlew runAutoTestServer --stacktrace
- uses: actions/upload-artifact@v2
with:
name: Artifacts

View file

@ -28,6 +28,8 @@ version = Globals.baseVersion + "+" + (ENV.GITHUB_RUN_NUMBER ? "" : "local-") +
logger.lifecycle("Building Fabric: " + version)
import org.apache.commons.codec.digest.DigestUtils
import net.fabricmc.loom.task.RunClientTask
import net.fabricmc.loom.task.RunServerTask
def getSubprojectVersion(project, version) {
if (grgit == null) {
@ -83,6 +85,14 @@ allprojects {
}
}
task runTestmodClient(type: RunClientTask) {
classpath sourceSets.testmod.runtimeClasspath
}
task runTestmodServer(type: RunServerTask) {
classpath sourceSets.testmod.runtimeClasspath
}
dependencies {
minecraft "com.mojang:minecraft:$Globals.mcVersion"
mappings "net.fabricmc:yarn:${Globals.mcVersion}${Globals.yarnVersion}:v2"
@ -181,6 +191,15 @@ task javadocJar(type: Jar) {
build.dependsOn javadocJar
// Runs a dedicated headless server with all test mods that closes once complete.
task runAutoTestServer(type: RunServerTask) {
project.subprojects {
classpath it.sourceSets.testmod.runtimeClasspath
}
jvmArgs "-Dfabric.autoTest"
args "--nogui"
}
subprojects {
dependencies {
testmodCompile sourceSets.main.output

View file

@ -1,2 +1,6 @@
archivesBaseName = "fabric-api-base"
version = getSubprojectVersion(project, "0.2.0")
dependencies {
testmodCompile project(path: ':fabric-lifecycle-events-v1', configuration: 'dev')
}

View file

@ -0,0 +1,40 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.fabricmc.fabric.test.base;
import org.spongepowered.asm.mixin.MixinEnvironment;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
public class FabricApiBaseTestInit implements ModInitializer {
private int ticks = 0;
@Override
public void onInitialize() {
if (System.getProperty("fabric.autoTest") != null) {
ServerTickEvents.END_SERVER_TICK.register(server -> {
ticks++;
if (ticks == 50) {
MixinEnvironment.getCurrentEnvironment().audit();
server.stop(false);
}
});
}
}
}

View file

@ -0,0 +1,13 @@
{
"schemaVersion": 1,
"id": "fabric-api-base-testmod",
"name": "Fabric API Base Test Mod",
"version": "1.0.0",
"environment": "*",
"license": "Apache-2.0",
"entrypoints": {
"main": [
"net.fabricmc.fabric.test.base.FabricApiBaseTestInit"
]
}
}