@@ -82,12 +82,10 @@ jobs:
8282
8383 - id : matrices # TODO: build origin matrices dynamically, consider collapsing this into a .py
8484 name : Construct matrices
85- env :
86- PR_COMMENT_BODY : ${{ github.event.pull_request.body }}
8785 run : |
8886 import os
8987 import json
90- import re
88+ import copy
9189
9290 build_matrix = {"include": []}
9391 run_matrix = {"version": []}
@@ -106,17 +104,6 @@ jobs:
106104 if "${{ steps.filter.outcome }}" == "success":
107105 # Filter matrices based on the detected changes
108106 dirs_to_filter = json.loads('${{ steps.filter.outputs.changes }}')
109- comment_body = os.getenv('PR_COMMENT_BODY')
110- print("PR-comment:", comment_body)
111- if comment_body:
112- pattern = r'Automatic commit: build and run ([0-9\.]*[0-9]*) in ([0-9_]*[0-9]*)'
113- match = re.search(pattern, comment_body)
114- if match:
115- mc_versions = [ match.group(1) ]
116- dirs_to_filter = [ match.group(2) ]
117- print('Matched PR body', mc_versions, dirs_to_filter)
118- else:
119- print('PR body did not match')
120107
121108 case 'workflow_dispatch':
122109 input_dirs = '${{ github.event.inputs.dirs }}'
@@ -136,10 +123,30 @@ jobs:
136123 build_matrix['include'], run_matrix['version'] = build_data, run_data
137124
138125 if dirs_to_filter:
139- build_matrix['include'].extend([item for item in build_data if item["dir"] in dirs_to_filter and (item["mc"] in mc_versions or not mc_versions)])
126+ build_matrix['include'].extend([item for item in build_data if item["dir"] in dirs_to_filter and ("mc" not in item or (item ["mc"] in mc_versions or not mc_versions) )])
140127 mc_versions = mc_versions if mc_versions else [item.get("mc") for item in build_matrix["include"] if "mc" in item]
141128 run_matrix['version'].extend([item for item in run_data if item["mc"] in mc_versions])
142129
130+ for entry in run_matrix['version']:
131+ entry['runner'] = 'ubuntu-latest' #'blacksmith-2vcpu-ubuntu-2204'
132+ entry['cache'] = 'github' #'blacksmith'
133+ entry['xvfb'] = True
134+
135+ additional_runs = []
136+ for item in run_matrix['version']:
137+ #runners = [ ('blacksmith-2vcpu-ubuntu-2204', 'blacksmith') ] # also add non-xvfb runs for ubuntu
138+ runners = [ ('ubuntu-latest', 'github') ] # also add non-xvfb runs for ubuntu
139+ if len(additional_runs) < 9: # add other runners only for the latest version * 3 modloaders * 3 runners
140+ runners += [ ('windows-latest', 'github'), ('macos-latest', 'github') ]
141+ for runner, cache in runners:
142+ entry = copy.deepcopy(item)
143+ entry['runner'] = runner
144+ entry['cache'] = cache
145+ entry['xvfb'] = False
146+ additional_runs.append(entry)
147+
148+ run_matrix['version'] += additional_runs
149+
143150 with open(os.environ['GITHUB_OUTPUT'], 'a') as fh:
144151 print(json.dumps(build_matrix, indent=2))
145152 fh.write(f'build-matrix={json.dumps(build_matrix)}\n')
@@ -164,17 +171,16 @@ jobs:
164171 java : ${{ matrix.java }}
165172
166173 run :
167- if : github.event_name != 'push'
174+ if : github.event_name != 'push' && fromJSON(needs.matrices.outputs.run-matrix).version[0] != null
168175 name : Run tests
169176 needs :
170177 - matrices
171178 - build
172- runs-on : ubuntu-latest
179+ runs-on : ${{ matrix.version.runner }}
173180 strategy :
174181 fail-fast : false
175182 matrix :
176183 ${{ insert }} : ${{ fromJSON(needs.matrices.outputs.run-matrix) }}
177- xvfb : [true, false]
178184 steps :
179185 - name : Checkout # TODO: simplify away this step, currently needed for `uses: ./`
180186 uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
@@ -191,24 +197,32 @@ jobs:
191197 mkdir -p run/mods
192198 cp mc-runtime-test-*-${{ matrix.version.type }}-release.jar run/mods
193199
194- - name : Setup Java temurin-${{ matrix.version.java }}
200+ - name : Setup Github Java temurin-${{ matrix.version.java }}
201+ if : matrix.version.cache == 'github'
195202 uses : actions/setup-java@v5
196203 with :
197204 java-version : ${{ matrix.version.java }}
198205 distribution : temurin
199206
207+ - name : Setup Blacksmith Java temurin-${{ matrix.version.java }}
208+ if : matrix.version.cache == 'blacksmith'
209+ uses : useblacksmith/setup-java@4ef812391eff6e9737ba13bf0356d0f702877a64 # v5
210+ with :
211+ java-version : ${{ matrix.version.java }}
212+ distribution : temurin
213+
200214 - name : Run game
201215 timeout-minutes : 3
202216 uses : ./
203217 with :
204- cache-mc : " github "
218+ cache-mc : ${{ matrix.version.cache }}
205219 mc : ${{ matrix.version.mc }}
206220 mc-runtime-test : none
207221 modloader : ${{ matrix.version.modloader }}
208222 regex : ${{ matrix.version.regex }}
209223 java : ${{ matrix.version.java }}
210- xvfb : ${{ matrix.xvfb }}
211- headlessmc-command : ${{ !matrix.xvfb && '-lwjgl' || '' }} --retries 3 --jvm -Djava.awt.headless=true
224+ xvfb : ${{ matrix.version. xvfb }}
225+ headlessmc-command : ${{ !matrix.version. xvfb && '-lwjgl' || '' }} --retries 3 --jvm -Djava.awt.headless=true
212226
213227 release :
214228 if : needs.release-please.outputs.release_created == 'true'
0 commit comments