|
| 1 | +name: Patched-JAR Tests |
| 2 | + |
| 3 | +# End-to-end coverage for the Forge/NeoForge patched-Minecraft pipeline added |
| 4 | +# under issue #9. Generates a real patched MC JAR per matrix entry (NeoForge via |
| 5 | +# NeoFormRuntime, Forge via a tiny ForgeGradle fixture project) and runs the |
| 6 | +# patched-jar test suite against it. |
| 7 | +# |
| 8 | +# Manually triggered + on push to main when relevant code changes — patched-JAR |
| 9 | +# generation downloads vanilla MC + applies patches and is too heavy for every PR. |
| 10 | + |
| 11 | +on: |
| 12 | + workflow_dispatch: |
| 13 | + inputs: |
| 14 | + matrix_filter: |
| 15 | + description: 'Optional matrix filter (substring match on `name` field)' |
| 16 | + required: false |
| 17 | + default: '' |
| 18 | + push: |
| 19 | + branches: [main] |
| 20 | + paths: |
| 21 | + - 'src/services/decompile-service.ts' |
| 22 | + - 'src/services/mapping-service.ts' |
| 23 | + - 'src/utils/jar-inspector.ts' |
| 24 | + - 'src/server/tools.ts' |
| 25 | + - '__tests__/manual/patched/**' |
| 26 | + - '.github/workflows/patched-jars.yml' |
| 27 | + |
| 28 | +jobs: |
| 29 | + neoforge: |
| 30 | + name: NeoForge ${{ matrix.mc }} / ${{ matrix.neoforge }} |
| 31 | + runs-on: ubuntu-latest |
| 32 | + strategy: |
| 33 | + fail-fast: false |
| 34 | + matrix: |
| 35 | + include: |
| 36 | + - name: neoforge-1.20.4 |
| 37 | + mc: '1.20.4' |
| 38 | + neoforge: '20.4.248' |
| 39 | + - name: neoforge-1.21.1 |
| 40 | + mc: '1.21.1' |
| 41 | + neoforge: '21.1.72' |
| 42 | + - name: neoforge-1.21.4 |
| 43 | + mc: '1.21.4' |
| 44 | + neoforge: '21.4.30' |
| 45 | + steps: |
| 46 | + - uses: actions/checkout@v4 |
| 47 | + |
| 48 | + - name: Setup Node.js |
| 49 | + uses: actions/setup-node@v4 |
| 50 | + with: |
| 51 | + node-version: '22.x' |
| 52 | + cache: 'npm' |
| 53 | + |
| 54 | + - name: Setup Java |
| 55 | + uses: actions/setup-java@v4 |
| 56 | + with: |
| 57 | + distribution: 'temurin' |
| 58 | + java-version: '21' |
| 59 | + |
| 60 | + - name: Install dependencies |
| 61 | + run: npm ci |
| 62 | + |
| 63 | + - name: Build |
| 64 | + run: npm run build |
| 65 | + |
| 66 | + - name: Cache NeoFormRuntime working dir + produced JAR |
| 67 | + uses: actions/cache@v4 |
| 68 | + with: |
| 69 | + path: | |
| 70 | + ~/.neoformruntime |
| 71 | + nfrt-out |
| 72 | + key: nfrt-${{ matrix.mc }}-${{ matrix.neoforge }}-v1 |
| 73 | + |
| 74 | + - name: Resolve NeoFormRuntime |
| 75 | + # Releases: https://maven.neoforged.net/releases/net/neoforged/neoform-runtime/ |
| 76 | + env: |
| 77 | + NFRT_VERSION: '1.0.30' |
| 78 | + run: | |
| 79 | + set -euo pipefail |
| 80 | + mkdir -p tools |
| 81 | + NFRT_URL="https://maven.neoforged.net/releases/net/neoforged/neoform-runtime/${NFRT_VERSION}/neoform-runtime-${NFRT_VERSION}-all.jar" |
| 82 | + if [ ! -f tools/nfrt.jar ]; then |
| 83 | + curl -fL --retry 3 -o tools/nfrt.jar "$NFRT_URL" |
| 84 | + fi |
| 85 | + java -jar tools/nfrt.jar --version |
| 86 | +
|
| 87 | + - name: Generate patched MC JAR via NFRT |
| 88 | + run: | |
| 89 | + set -euo pipefail |
| 90 | + mkdir -p nfrt-out |
| 91 | + OUT="$(pwd)/nfrt-out/${{ matrix.name }}.jar" |
| 92 | + if [ ! -f "$OUT" ]; then |
| 93 | + java -jar tools/nfrt.jar run \ |
| 94 | + --neoforge "net.neoforged:neoforge:${{ matrix.neoforge }}:userdev" \ |
| 95 | + --write-result "compiledWithNeoForge:$OUT" |
| 96 | + fi |
| 97 | + test -s "$OUT" |
| 98 | + echo "PATCHED_JAR_PATH=$OUT" >> "$GITHUB_ENV" |
| 99 | + echo "PATCHED_VERSION=${{ matrix.mc }}-neoforge-${{ matrix.neoforge }}" >> "$GITHUB_ENV" |
| 100 | + echo "PATCHED_MC_VERSION=${{ matrix.mc }}" >> "$GITHUB_ENV" |
| 101 | + echo "PATCHED_LOADER=neoforge" >> "$GITHUB_ENV" |
| 102 | +
|
| 103 | + - name: Run patched-JAR test suite |
| 104 | + run: npm run test:manual:patched |
| 105 | + |
| 106 | + forge: |
| 107 | + name: Forge 1.20.1 / 47.4.0 |
| 108 | + runs-on: ubuntu-latest |
| 109 | + steps: |
| 110 | + - uses: actions/checkout@v4 |
| 111 | + |
| 112 | + - name: Setup Node.js |
| 113 | + uses: actions/setup-node@v4 |
| 114 | + with: |
| 115 | + node-version: '22.x' |
| 116 | + cache: 'npm' |
| 117 | + |
| 118 | + - name: Setup Java |
| 119 | + uses: actions/setup-java@v4 |
| 120 | + with: |
| 121 | + distribution: 'temurin' |
| 122 | + java-version: '17' |
| 123 | + |
| 124 | + - name: Install dependencies |
| 125 | + run: npm ci |
| 126 | + |
| 127 | + - name: Build |
| 128 | + run: npm run build |
| 129 | + |
| 130 | + - name: Setup Gradle |
| 131 | + uses: gradle/actions/setup-gradle@v3 |
| 132 | + with: |
| 133 | + # Gradle 8.5 is the last 8.x line that ForgeGradle 6.0.+ tracks |
| 134 | + # cleanly against the 1.20.1 toolchain. |
| 135 | + gradle-version: '8.5' |
| 136 | + |
| 137 | + - name: Cache ForgeGradle artifact cache |
| 138 | + uses: actions/cache@v4 |
| 139 | + with: |
| 140 | + path: | |
| 141 | + ~/.gradle/caches/forge_gradle |
| 142 | + __tests__/fixtures/forge-1.20.1/build |
| 143 | + key: forge-1.20.1-47.4.0-v1 |
| 144 | + |
| 145 | + - name: Build patched Forge MC via ForgeGradle fixture |
| 146 | + working-directory: __tests__/fixtures/forge-1.20.1 |
| 147 | + run: | |
| 148 | + set -euo pipefail |
| 149 | + # `setupDecompWorkspace` materializes the patched MC JAR into the |
| 150 | + # ForgeGradle cache. We then copy it into a stable location. |
| 151 | + gradle --no-daemon setupDecompWorkspace |
| 152 | + OUT="$(pwd)/build/forge-patched.jar" |
| 153 | + mkdir -p "$(dirname "$OUT")" |
| 154 | + # ForgeGradle 6 stores the patched, mapped MC JAR here: |
| 155 | + PATCHED="$(find ~/.gradle/caches/forge_gradle/minecraft_user_repo \ |
| 156 | + -path '*1.20.1-47.4.0_mapped_official_1.20.1*' -name '*.jar' \ |
| 157 | + ! -name '*sources*' ! -name '*-slim*' | head -n1)" |
| 158 | + test -n "$PATCHED" -a -s "$PATCHED" |
| 159 | + cp "$PATCHED" "$OUT" |
| 160 | + echo "PATCHED_JAR_PATH=$OUT" >> "$GITHUB_ENV" |
| 161 | + echo "PATCHED_VERSION=1.20.1-forge-47.4.0" >> "$GITHUB_ENV" |
| 162 | + echo "PATCHED_MC_VERSION=1.20.1" >> "$GITHUB_ENV" |
| 163 | + echo "PATCHED_LOADER=forge" >> "$GITHUB_ENV" |
| 164 | +
|
| 165 | + - name: Run patched-JAR test suite |
| 166 | + run: npm run test:manual:patched |
0 commit comments