mirror of
https://github.com/mpusz/mp-units.git
synced 2025-07-31 19:04:27 +02:00
fix boolean conan options in dynamic CI matrix
This commit is contained in:
12
.github/generate-job-matrix.py
vendored
12
.github/generate-job-matrix.py
vendored
@@ -4,7 +4,7 @@ import random
|
|||||||
import typing
|
import typing
|
||||||
from types import SimpleNamespace
|
from types import SimpleNamespace
|
||||||
|
|
||||||
from job_matrix import CombinationCollector, Compiler, Configuration, dataclass_to_json
|
from job_matrix import CombinationCollector, Compiler, Configuration
|
||||||
|
|
||||||
|
|
||||||
def make_gcc_config(version: int) -> Configuration:
|
def make_gcc_config(version: int) -> Configuration:
|
||||||
@@ -155,20 +155,20 @@ def main():
|
|||||||
|
|
||||||
data = sorted(collector.combinations)
|
data = sorted(collector.combinations)
|
||||||
|
|
||||||
|
json_data = [e.as_json() for e in data]
|
||||||
|
|
||||||
if not args.suppress_output:
|
if not args.suppress_output:
|
||||||
print(
|
print(f"::set-output name=matrix::{json.dumps(json_data)}")
|
||||||
f"::set-output name=matrix::{json.dumps(data, default=dataclass_to_json)}"
|
|
||||||
)
|
|
||||||
|
|
||||||
for dbg in args.debug:
|
for dbg in args.debug:
|
||||||
match dbg:
|
match dbg:
|
||||||
case "yaml":
|
case "yaml":
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
json_data = json.loads(json.dumps(data, default=dataclass_to_json))
|
json_data = json.loads(json.dumps(json_data))
|
||||||
print(yaml.safe_dump(json_data))
|
print(yaml.safe_dump(json_data))
|
||||||
case "json":
|
case "json":
|
||||||
print(json.dumps(data, default=dataclass_to_json, indent=4))
|
print(json.dumps(json_data, indent=4))
|
||||||
case "combinations":
|
case "combinations":
|
||||||
for e in data:
|
for e in data:
|
||||||
print(
|
print(
|
||||||
|
19
.github/job_matrix.py
vendored
19
.github/job_matrix.py
vendored
@@ -35,12 +35,21 @@ class MatrixElement:
|
|||||||
contracts: typing.Literal["none", "gsl-lite", "ms-gsl"]
|
contracts: typing.Literal["none", "gsl-lite", "ms-gsl"]
|
||||||
build_type: typing.Literal["Release", "Debug"]
|
build_type: typing.Literal["Release", "Debug"]
|
||||||
|
|
||||||
|
def as_json(self):
|
||||||
|
def dataclass_to_json(obj):
|
||||||
|
"""Convert dataclasses to something json-serialisable"""
|
||||||
|
if dataclasses.is_dataclass(obj):
|
||||||
|
return {
|
||||||
|
k: dataclass_to_json(v) for k, v in dataclasses.asdict(obj).items()
|
||||||
|
}
|
||||||
|
return obj
|
||||||
|
|
||||||
def dataclass_to_json(obj):
|
ret = dataclass_to_json(self)
|
||||||
"""Convert dataclasses to something json-serialisable"""
|
# patch boolean conan configuration options
|
||||||
if dataclasses.is_dataclass(obj):
|
config = ret["config"]
|
||||||
return dataclasses.asdict(obj)
|
for k in ["cxx_modules"]:
|
||||||
raise TypeError(f"Unknown object of type {type(obj).__name__}")
|
config[k] = "True" if config[k] else "False"
|
||||||
|
return ret
|
||||||
|
|
||||||
|
|
||||||
class CombinationCollector:
|
class CombinationCollector:
|
||||||
|
Reference in New Issue
Block a user