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

Build and test Workflow #14

Merged
merged 2 commits into from
Jul 12, 2024
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: build

on:
push:
branches:
- "*"
pull_request:
branches:
- "*"
workflow_dispatch:

permissions: write-all

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 21
cache: gradle
- uses: gradle/actions/setup-gradle@v3
- name: Run Build
run: ./gradlew clean build -x test
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: "Built Mod"
path: build/libs/*.jar
- name: Run Tests
run: ./gradlew test
- name: Upload Test Results
uses: actions/upload-artifact@v3
with:
name: "Test Results"
path: build/reports/tests/test

20 changes: 15 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,16 @@ neoForge {
}

mods {
register("techarium") {
register(modId) {
sourceSet(sourceSets.main.get())
}
}

unitTest {
enable()

testedMod = mods[modId]
}
}

repositories {
Expand All @@ -62,16 +68,16 @@ dependencies {

"jarJar"(libs.resourcefullibkt)
"jarJar"(libs.resourcefulconfigkt)

testImplementation(libs.junit)
testImplementation(libs.testframework)
testRuntimeOnly(libs.junitplatform)
}

java {
withSourcesJar()
}

tasks.jar {
archiveClassifier.set("dev")
}

tasks.processResources {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
filesMatching(listOf("META-INF/neoforge.mods.toml")) {
Expand All @@ -86,6 +92,10 @@ kotlin {
}
}

tasks.withType<Test> {
useJUnitPlatform()
}

publishing {
publications {
create<MavenPublication>("maven") {
Expand Down
11 changes: 7 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ resourcefulLib = "3.0.9"
resourcefulLibKt = "2.0.1"
resourcefulConfig = "3.0.2"
resourcefulConfigKt = "3.0.2"

# Needed for Resourceful Lib because Neo doesn't import them
bytecodecs = "1.1.2"
yabn = "1.0.3"

geckolib = "4.5.6"
kotlinForForge = "5.3.0"

# Test Dependencies
junit = "5.7.1"

[libraries]

resourcefullib = { module = "com.teamresourceful.resourcefullib:resourcefullib-neoforge-1.21", version.ref = "resourcefulLib" }
Expand All @@ -30,10 +30,13 @@ resourcefulconfig = { module = "com.teamresourceful.resourcefulconfig:resourcefu
resourcefulconfigkt = { module = "com.teamresourceful.resourcefulconfigkt:resourcefulconfigkt-neoforge-1.21", version.ref = "resourcefulConfigKt" }
bytecodecs = { module = "com.teamresourceful:bytecodecs", version.ref = "bytecodecs" }
yabn = { module = "com.teamresourceful:yabn", version.ref = "yabn" }

geckolib = { module = "software.bernie.geckolib:geckolib-neoforge-1.21", version.ref = "geckolib" }
kotlinforforge = { module = "thedarkcolour:kotlinforforge-neoforge", version.ref = "kotlinForForge" }

junit = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit" }
junitplatform = { module = "org.junit.platform:junit-platform-launcher" }
testframework = { module = "net.neoforged:testframework", version.ref = "neoforge" }

[plugins]

moddev = { id = "net.neoforged.moddev", version.ref = "moddev" }
Expand Down
16 changes: 16 additions & 0 deletions src/test/kotlin/earth/terrarium/techarium/ExampleTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package earth.terrarium.techarium

import net.minecraft.network.chat.Component
import net.minecraft.server.MinecraftServer
import net.neoforged.testframework.junit.EphemeralTestServerProvider
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith

@ExtendWith(EphemeralTestServerProvider::class)
class ExampleTest {

@Test
fun `example test`(server: MinecraftServer) {
server.sendSystemMessage(Component.literal("Hello, world!"))
}
}
Loading