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
|
||||
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:
|
||||
@@ -155,20 +155,20 @@ def main():
|
||||
|
||||
data = sorted(collector.combinations)
|
||||
|
||||
json_data = [e.as_json() for e in data]
|
||||
|
||||
if not args.suppress_output:
|
||||
print(
|
||||
f"::set-output name=matrix::{json.dumps(data, default=dataclass_to_json)}"
|
||||
)
|
||||
print(f"::set-output name=matrix::{json.dumps(json_data)}")
|
||||
|
||||
for dbg in args.debug:
|
||||
match dbg:
|
||||
case "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))
|
||||
case "json":
|
||||
print(json.dumps(data, default=dataclass_to_json, indent=4))
|
||||
print(json.dumps(json_data, indent=4))
|
||||
case "combinations":
|
||||
for e in data:
|
||||
print(
|
||||
|
17
.github/job_matrix.py
vendored
17
.github/job_matrix.py
vendored
@@ -35,12 +35,21 @@ class MatrixElement:
|
||||
contracts: typing.Literal["none", "gsl-lite", "ms-gsl"]
|
||||
build_type: typing.Literal["Release", "Debug"]
|
||||
|
||||
|
||||
def dataclass_to_json(obj):
|
||||
def as_json(self):
|
||||
def dataclass_to_json(obj):
|
||||
"""Convert dataclasses to something json-serialisable"""
|
||||
if dataclasses.is_dataclass(obj):
|
||||
return dataclasses.asdict(obj)
|
||||
raise TypeError(f"Unknown object of type {type(obj).__name__}")
|
||||
return {
|
||||
k: dataclass_to_json(v) for k, v in dataclasses.asdict(obj).items()
|
||||
}
|
||||
return obj
|
||||
|
||||
ret = dataclass_to_json(self)
|
||||
# patch boolean conan configuration options
|
||||
config = ret["config"]
|
||||
for k in ["cxx_modules"]:
|
||||
config[k] = "True" if config[k] else "False"
|
||||
return ret
|
||||
|
||||
|
||||
class CombinationCollector:
|
||||
|
Reference in New Issue
Block a user