Skip to content

Test the Minecraft client inside your CI

License

Notifications You must be signed in to change notification settings

headlesshq/mc-runtime-test

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

MC-Runtime-Test

Run the Minecraft client inside your CI/CD pipeline.

MC-Runtime-Test | HMC | HMC-Specifics | HMC-Optimizations

CodeFactor GitHub All Releases GitHub License GitHub Last Commit

Note

This is not an official Minecraft product. It is not approved by or associated with Mojang or Microsoft.


MC-Runtime-Test enables you to run the Minecraft client within your CI/CD pipelines, simplifying the testing of runtime bugs in Minecraft mods. Manual testing for different Minecraft versions and modloaders can be time-consuming, especially when bugs occur only in runtime environments launched via a Minecraft launcher. This project helps streamline that process by automating the client launch and basic test execution.

Features

  • Utilizes HeadlessMC for headless Minecraft launches.
  • Employs Xvfb for virtual framebuffer support.
  • Includes a lightweight mod that:
    • Join a single-player world.
    • Wait for chunks to load.
    • Quit the game after a few seconds.
  • Supports Minecraft’s GameTest Framework to run registered tests for newer versions.

Supported Minecraft Versions and Modloaders

Version Forge Fabric NeoForge
1.21 - 1.21.3 ✔️ ✔️ ✔️
1.20.2 - 1.20.6 ✔️ ✔️ ✔️
1.20.1 ✔️ ✔️ ⚠️
1.19 - 1.19.4 ✔️ ✔️
1.18.2 ✔️ ✔️
1.17.1 ✔️ ✔️
1.16.5 ✔️ ✔️
1.12.2 ✔️ ⚠️
1.8.9 ✔️ ⚠️
1.7.10 ✔️ ⚠️

⚠️ Versions marked with a warning symbol have limited or untested support.


Quickstart Example

Below is a basic workflow example to run the Minecraft client using MC-Runtime-Test.

---
name: Run Minecraft Client

on:
  workflow_dispatch:

env:
  java_version: 21

jobs:
  run:
    runs-on: ubuntu-latest
    steps:
      - name: Install Java
        uses: actions/setup-java@v4
        with:
          java-version: ${{ env.java_version }}
          distribution: "temurin"

      - name: [Example] Build mod
        run: ./gradlew build

      - name: [Example] Stage mod for test client
        run: |
          mkdir -p run/mods
          cp build/libs/.jar run/mods

      - name: Run MC test client
        uses: headlesshq/[email protected] 
        with:
          mc: 1.21.4
          modloader: fabric
          regex: .*fabric.*
          mc-runtime-test: fabric
          java: ${{ env.java_version }}

More examples:


Inputs

The following table summarizes the available inputs for customization:

Input Description Required Example
mc Minecraft version to run Yes 1.20.4
modloader Modloader to install Yes forge, neoforge, fabric
regex Regex to match the modloader jar Yes .*fabric.*
java Java version to use Yes 8, 16, 17, 21
mc-runtime-test MC-Runtime-Test jar to download Yes none, lexforge, neoforge, fabric
dummy-assets Use dummy assets during testing true, false
xvfb Runs the game with Xvfb true, false
headlessmc-command Command-line arguments for HeadlessMC --jvm "-Djava.awt.headless=true"
fabric-api Fabric API version to download or none 0.97.0, none
fabric-gametest-api Fabric GameTest API version or none 1.3.5+85d85a934f, none
download-hmc Download HeadlessMC true, false
hmc-version HeadlessMC version 2.4.1, 1.5.0
cache-mc Cache .minecraft true, false

Running Your Own Tests

MC-Runtime-Test supports Minecraft’s Game-Test Framework. It executes /test runall upon joining a world.

Tip

Currently, Forge and NeoForge GameTest discovery may require additional setup, hacks, or other modifications to register structure templates correctly. We expect to simplify this for future releases.

You can also use the headlessmc-command input to specify a JVM argument to enforce the minimum number of GameTests you expect to be executed:

-DMcRuntimeGameTestMinExpectedGameTests=1

Acknowledgments

Special thanks to wagyourtail for the unimined Gradle plugin, which enabled multi-modloader support and accelerated development of this project.