This commit is contained in:
Maxim Prokhorov
2021-02-22 22:53:10 +03:00
parent 8081381e5a
commit 858c6aa446
+13 -16
View File
@@ -1,6 +1,8 @@
import json
from platformio.project.config import ProjectConfig
# This will select the same environments as tools/build_ESPeasy.sh
def get_jobs(cfg):
for env in cfg.envs():
platform = cfg.get("env:{}".format(env), "platform")
@@ -18,26 +20,21 @@ def filter_jobs(jobs, ignore=("spec_",)):
yield job
jobs = filter_jobs(get_jobs(ProjectConfig.get_instance()))
# XXX for testing
def get_one_of_each(jobs):
seen = set()
for job in jobs:
if not job["chip"] in seen:
seen.add(job["chip"])
yield job
# ref. https://github.blog/changelog/2020-04-15-github-actions-new-workflow-features/
# we need to echo something like this:
# ::set-output name=matrix::{"include": [{"chip": "esp8266", "env": "custom_ESP8266_4M1M"}, {"chip": "esp32", "env": "custom_ESP32_4M316k"}]}
fmt = "::set-output name=matrix::{}"
out = fmt.format(json.dumps({"include": list(get_one_of_each(jobs))}))
if __name__ == "__main__":
jobs = list(filter_jobs(get_jobs(ProjectConfig.get_instance())))
print(out)
sort = []
for job in jobs:
if job["chip"] == "esp8266":
sort.append(job["env"])
sort.sort(key=str.casefold)
# XXX for testing
for s in sort:
print(s)
# ... Normal run will dump the whole jobs list as-is ...
serialized = json.dumps({"include": jobs})
print("::set-output name=matrix::{}".format(serialized))