Skip to content

Commit

Permalink
Try fixing the matrix creator in the github runner.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivorforce committed Nov 8, 2024
1 parent 90ec091 commit 214b7a4
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 35 deletions.
55 changes: 20 additions & 35 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,30 @@ on:
workflow_dispatch:

jobs:
define-matrix:
runs-on: ubuntu-latest

outputs:
matrix-include: ${{ steps.make_matrix.outputs.include }}

steps:
- name: Set up Python 3.x
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Checkout
uses: actions/checkout@v4
- name: Load Matrix
id: make_matrix
run: |
echo 'include='$(python3 make_github_runner_config.py) >> "$GITHUB_OUTPUT"
build:
needs: define-matrix
strategy:
fail-fast: false
matrix:
# Double float precision builds are not needed by default;
# whoever needs them can recompile, but it would blow up our release zip to include them.
float-precision: [single]
build-target-type: [template_debug, template_release]
include:
- platform: linux
arch: x86_64
os: ubuntu-20.04
- platform: windows
arch: x86_32
os: windows-latest
- platform: windows
arch: x86_64
os: windows-latest
- platform: macos
arch: universal
os: macos-latest
- platform: android
arch: arm64
os: ubuntu-20.04
- platform: android
arch: arm32
os: ubuntu-20.04
- platform: android
arch: x86_64
os: ubuntu-20.04
- platform: android
arch: x86_32
os: ubuntu-20.04
- platform: ios
arch: arm64
os: macos-latest
- platform: web
arch: wasm32
os: ubuntu-20.04
include: ${{ fromJSON(needs.define-matrix.outputs.matrix-include) }}

runs-on: ${{ matrix.os }}
steps:
Expand Down
74 changes: 74 additions & 0 deletions make_github_runner_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import json

# Ah, imagine if github matrix interpreters could just have this little function...
def unroll_config(cfg: dict):
configs = [{}]

for key, value in cfg.items():
if key == "combine":
# List of configs
configs = [
{**cfg_base, **cfg_combine}
for cfg_base in configs
for combine_template in cfg["combine"]
for cfg_combine in unroll_config(combine_template)
]
elif isinstance(value, list):
# Value list
configs = [
{**config, key: value}
for value in value
for config in configs
]
else:
# Single value
configs = [
{**config, key: value}
for config in configs
]

return configs


config = dict(
# Could build with double, but that would double (hah) our build count.
# Doubles are custom builds, so let somebody else do that.
float_precision=["single"],
build_target_type=["template_debug", "template_release"],
combine=[
dict(
platform="macos",
os="macos-latest",
arch="universal",
),
dict(
platform="ios",
os="macos-latest",
arch="arm64",
),
dict(
platform="linux",
os="ubuntu-20.04",
arch=["x86_64", "arm64", "rv64"],
),
dict(
platform="windows",
os="windows-latest",
arch=["x86_32", "x86_64"],
),
dict(
platform="android",
os="ubuntu-20.04",
arch=["x86_64", "arm64"],
),
dict(
platform="web",
os="ubuntu-20.04",
arch="wasm32",
),
]
)

includes = unroll_config(config)

print(json.dumps(includes))

0 comments on commit 214b7a4

Please sign in to comment.