Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start GameTests #107

Merged
merged 9 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Disable autocrlf on generated files, they always generate with LF
# Add any extra files or paths here to make git stop saying they
# are changed when only line endings change.
src/generated/ linguist-generated=true text eol=lf
src/generated/ linguist-generated=true text eol=lf
src/main/generated_resources/ linguist-generated=true text eol=lf
48 changes: 25 additions & 23 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,28 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- uses: actions/cache@v4
with:
path: |
~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build --info
- name: Stop gradle daemon
run: ./gradlew --stop
- uses: actions/upload-artifact@v4
with:
name: Allomancy jar
path: build/libs/*.jar
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- uses: actions/cache@v4
with:
path: |
~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build --info
- name: Run gametests
run: ./gradlew runGameTestServer
- name: Stop gradle daemon
run: ./gradlew --stop
- uses: actions/upload-artifact@v4
with:
name: Allomancy jar
path: build/libs/*.jar
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
TODO.txt
/.vscode
/logs
/src/generated/resources/.cache/
/src/main/generated_resources/.cache/
47 changes: 29 additions & 18 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id 'java-library'
id 'maven-publish'
id 'net.neoforged.moddev' version '1.0.23'
id 'net.neoforged.moddev' version '2.0.72'
id 'idea'
}

Expand All @@ -26,7 +26,12 @@ base {
}

// Mojang ships Java 21 to end users starting in 1.20.5, so mods should target Java 21.
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
java {
toolchain.languageVersion = JavaLanguageVersion.of(21)
withSourcesJar()
}

def gametest_mod_id = mod_id + "_test"

neoForge {
version = project.neo_version
Expand All @@ -36,48 +41,47 @@ neoForge {
minecraftVersion = project.parchment_minecraft_version
}

addModdingDependenciesTo(sourceSets.test)

runs {
client {
client()
gameDirectory = project.file('runs/client')
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
sourceSet = sourceSets.test
}

client2 {
client()
gameDirectory = project.file('runs/client')
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
programArguments.addAll('--username', 'Dev2')
}

server {
server()
gameDirectory = project.file('runs/server')
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
}

// This run config launches GameTestServer and runs all registered gametests, then exits.
// By default, the server will crash when no gametests are provided.
gameTestServer {
type = "gameTestServer"
gameDirectory = project.file('runs/gameTestServer')
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
sourceSet = sourceSets.test
}

clientData {
clientData()
gameDirectory = project.file('runs/clientData')
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/main/generated_resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
}

// applies to all the run configs above
configureEach {
// Recommended logging data for a userdev environment
systemProperty 'forge.logging.markers', 'REGISTRIES'

systemProperty 'neoforge.enableGameTest', 'true'
systemProperty 'neoforge.enabledGameTestNamespaces', "${project.mod_id},${gametest_mod_id}"
gameDirectory = project.file('runs/' + name)
// Recommended logging level for the console
logLevel = org.slf4j.event.Level.DEBUG

jvmArguments.addAll '-Xmx4G'
}
}

Expand All @@ -86,11 +90,14 @@ neoForge {
"${mod_id}" {
sourceSet(sourceSets.main)
}
"${gametest_mod_id}" {
sourceSet(sourceSets.test)
}
}
}

// Include resources generated by data generators.
sourceSets.main.resources { srcDir 'src/generated/resources' }
sourceSets.main.resources { srcDir 'src/main/generated_resources' }

// Sets up a dependency configuration called 'localRuntime'.
// This configuration should be used instead of 'runtimeOnly' to declare
Expand All @@ -116,10 +123,10 @@ repositories {


dependencies {
dependencies {
implementation "curse.maven:jade-324717:${jade_id}"
// api "curse.maven:jade-324717:${jade_api}"
}
implementation "curse.maven:jade-324717:${jade_id}"
// api "curse.maven:jade-324717:${jade_api}"

localRuntime(testImplementation("net.neoforged:testframework:${neo_version}"))
}

// This block of code expands all declared replace properties in the specified resource targets.
Expand Down Expand Up @@ -197,6 +204,10 @@ artifacts {
archives deobfJar
}

test {
enabled = false
}


////////////////
// IntelliJ Project Import
Expand Down
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ mod_name=Allomancy
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=GPL v3
# The mod version. See https://semver.org/
mod_version=5.2.0b1
mod_version=5.2.0b2
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
Expand All @@ -45,3 +45,5 @@ mod_authors=legobmw99
# The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list.
mod_description=Adds Brandon Sanderson's Allomancy to Minecraft!

# Prevent NG attempting to make the test sourceset a junit one
neogradle.subsystems.conventions.sourcesets.automatic-inclusion=false
Loading
Loading