mirror of
https://github.com/FabricMC/fabric.git
synced 2025-04-21 03:10:54 -04:00
Spin up a dedicated server on github actions + add run tasks for test mods. (#1163)
* Add test mod run tasks, add a very basic auto test server task
* License header
* Minor cleanup
* Fix bad depends
(cherry picked from commit ba858fb8b7
)
This commit is contained in:
parent
40401c2d9d
commit
96cce223bd
5 changed files with 78 additions and 0 deletions
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
|
@ -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
|
||||
|
|
19
build.gradle
19
build.gradle
|
@ -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) {
|
||||
|
@ -81,6 +83,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"
|
||||
|
@ -179,6 +189,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
|
||||
|
|
|
@ -1,2 +1,6 @@
|
|||
archivesBaseName = "fabric-api-base"
|
||||
version = getSubprojectVersion(project, "0.1.2")
|
||||
|
||||
dependencies {
|
||||
testmodCompile project(path: ':fabric-lifecycle-events-v1', configuration: 'dev')
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
13
fabric-api-base/src/testmod/resources/fabric.mod.json
Normal file
13
fabric-api-base/src/testmod/resources/fabric.mod.json
Normal 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"
|
||||
]
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue