Skip to content

Commit 22133a1

Browse files
committed
!fixup [ci] Always upload all HAL job logs
1 parent fe9bc9e commit 22133a1

File tree

3 files changed

+103
-103
lines changed

3 files changed

+103
-103
lines changed

.github/workflows/linux.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ jobs:
6767
run: |
6868
python3 tools/scripts/synchronize_docs.py -d
6969
git checkout .
70+
- name: Synchronize HAL support table
71+
if: always()
72+
run: |
7073
python3 tools/scripts/generate_hal_matrix.py -d
7174
git checkout .
7275
- name: Check Examples

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,6 @@ We have out-of-box support for many development boards including documentation.
499499
<td align="center"><a href="https://modm.io/reference/module/modm-board-samd21-mini">SAMD21-MINI</a></td>
500500
<td align="center"><a href="https://modm.io/reference/module/modm-board-stm32_f4ve">STM32-F4VE</a></td>
501501
<td align="center"><a href="https://modm.io/reference/module/modm-board-stm32f030_demo">STM32F030-DEMO</a></td>
502-
</tr><tr>
503502
</tr>
504503
</table>
505504
<!--/bsptable-->

tools/scripts/synchronize_docs.py

Lines changed: 100 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,6 @@
1515
from os import listdir
1616
from os.path import isfile, join, abspath
1717

18-
TABLE_TEMPLATE = \
19-
r"""
20-
<table>
21-
<tr>
22-
{%- for item in items %}
23-
<td align="{% if align is defined %}{{align}}{% else %}center{% endif %}">{% if item.url %}<a href="{{item.url}}">{% endif %}{{item.name}}{% if item.url %}</a>{% endif %}</td>{%- if loop.index % width == 0 %}
24-
</tr><tr>{%- endif -%}
25-
{%- endfor %}
26-
</tr>
27-
</table>
28-
29-
"""
30-
3118
repopath = lambda path: Path(__file__).parents[2] / path
3219

3320
def run(where, command, stdin=None):
@@ -84,8 +71,18 @@ def extract(text, key):
8471
return re.search(r"<!--{0}-->(.*?)<!--/{0}-->".format(key), text, flags=re.DOTALL | re.MULTILINE).group(1)
8572

8673
def format_table(items, width, align=None):
87-
subs = {"items": items, "width": width}
88-
if align: subs["align"] = align;
74+
subs = {"items": items, "width": width,
75+
"align": "center" if align is None else align}
76+
TABLE_TEMPLATE = r"""
77+
<table>
78+
{% for bitems in items | batch(width) %}<tr>
79+
{%- for item in bitems %}
80+
<td align="{{ align }}">{% if item.url %}<a href="{{item.url}}">{% endif %}{{item.name}}{% if item.url %}</a>{% endif %}</td>
81+
{%- endfor %}
82+
</tr>{%- endfor %}
83+
</table>
84+
85+
"""
8986
return Environment().from_string(TABLE_TEMPLATE).render(subs)
9087

9188
def get_lbuild(root, target=None):
@@ -97,90 +94,91 @@ def get_lbuild(root, target=None):
9794
return builder.parser
9895

9996

100-
# All the paths
101-
root = repopath(".")
102-
board_path = root / "src/modm/board"
103-
example_path = root / "examples"
104-
ignored_path = root / "test/all/ignored.txt"
105-
examples_readme_in_path = root / "examples/README.md"
106-
examples_readme_path = root / "docs/src/guide/examples.md"
107-
readme_path = root / "README.md"
108-
index_in_path = root / "docs/index.md.in"
109-
index_path = root / "docs/src/index.md"
110-
whoweare_in_path = root / "docs/who-we-are.md.in"
111-
whoweare_path = root / "docs/src/who-we-are.md"
112-
modules_in_path = root / "docs/modules.md.in"
113-
modules_path = root / "docs/src/reference/modules.md"
114-
115-
# We cannot use lbuild to enumerate the boards since they only make themselves available for certain devices
116-
boards = [re.search(r"<module>modm:board:(.*?)</module>", config.read_text()).group(1)
117-
for config in Path(repopath("src/modm/board")).glob("*/board.xml")]
118-
boards = [{"name": name(b), "url": board_url(b)} for b in boards]
119-
boards.sort(key=lambda b: b["name"])
120-
bsp_table = format_table(boards, 4)
121-
122-
# Get all the example directory paths
123-
examples = [e.relative_to(example_path) for e in example_path.glob('**/project.xml')]
124-
examples = [{"name": "{}: {}".format(name(str(e.parts[0])), e.parent.relative_to(e.parts[0])),
125-
"url": github_url(Path("examples") / e.parent / "main.cpp")} for e in examples]
126-
examples.sort(key=lambda b: b["name"])
127-
example_table = format_table(examples, 2, "left")
128-
129-
# Get all supported targets
130-
targets = set(get_lbuild(root).find_option("modm:target").values)
131-
ignored_devices = set(d for d in ignored_path.read_text().strip().splitlines() if "#" not in d)
132-
targets -= ignored_devices
133-
avr_count = len([t for t in targets if t.startswith("at")])
134-
stm_count = len([t for t in targets if t.startswith("stm32")])
135-
sam_count = len([t for t in targets if t.startswith("sam")])
136-
all_count = avr_count + stm_count + sam_count
137-
138-
# get the author count
139-
from authors import author_handles
140-
author_count = len(author_handles)
141-
142-
# Get all the modules that are available for the STM32
143-
# Get all drivers, we assume they are available for all devices
144-
drivers = (get_lbuild(root, t).modules for t in {"avr", "stm32", "hosted"})
145-
drivers = {m for mg in drivers for m in mg if m.startswith("modm:driver:")}
146-
drivers = sorted(m.replace("modm:driver:", "") for m in drivers)
147-
drivers = [{"name": name(d), "url": driver_url(d)} for d in drivers if name(d)]
148-
driver_table = format_table(drivers, 6)
149-
150-
# Read the repo README.md and replace these keys
151-
readme = readme_path.read_text()
152-
readme = replace(readme, "authorcount", author_count - 7)
153-
readme = replace(readme, "avrcount", avr_count)
154-
readme = replace(readme, "samcount", sam_count)
155-
readme = replace(readme, "stmcount", stm_count)
156-
readme = replace(readme, "allcount", all_count)
157-
readme = replace(readme, "bsptable", bsp_table)
158-
readme = replace(readme, "drivertable", driver_table)
159-
readme_path.write_text(readme)
160-
161-
# extract these keys
162-
links = extract(readme, "links")
163-
authors = extract(readme, "authors").replace("\\@", "@")
164-
# remove
165-
readme = re.sub(r"((<!--webignore-->.*?<!--/webignore-->)|(<!--links-->.*?<!--/links-->)|(<!--/?bsptable-->))\n", "", readme, flags=re.DOTALL | re.MULTILINE)
166-
167-
index = Environment().from_string(index_in_path.read_text()).render({"content": readme, "links": links, "example_table": example_table})
168-
index_path.write_text(index)
169-
170-
whoweare = Environment().from_string(whoweare_in_path.read_text()).render({"authors": authors, "links": links})
171-
whoweare_path.write_text(whoweare)
172-
173-
# Copy the example readme over
174-
shutil.copy(examples_readme_in_path, examples_readme_path)
175-
176-
# Check git differences and fail
177-
if "-d" in sys.argv:
178-
differences = run(repopath("."), r"git diff")[1]
179-
if len(differences):
180-
subprocess.run("git --no-pager diff", shell=True, cwd=repopath("."))
181-
print("\nPlease synchronize the modm documentation:\n\n"
182-
" $ python3 tools/scripts/synchronize_docs.py\n\n"
183-
"and then commit the results!")
184-
exit(1)
185-
186-
exit(0)
97+
if __name__ == "__main__":
98+
# All the paths
99+
root = repopath(".")
100+
board_path = root / "src/modm/board"
101+
example_path = root / "examples"
102+
ignored_path = root / "test/all/ignored.txt"
103+
examples_readme_in_path = root / "examples/README.md"
104+
examples_readme_path = root / "docs/src/guide/examples.md"
105+
readme_path = root / "README.md"
106+
index_in_path = root / "docs/index.md.in"
107+
index_path = root / "docs/src/index.md"
108+
whoweare_in_path = root / "docs/who-we-are.md.in"
109+
whoweare_path = root / "docs/src/who-we-are.md"
110+
modules_in_path = root / "docs/modules.md.in"
111+
modules_path = root / "docs/src/reference/modules.md"
112+
113+
# We cannot use lbuild to enumerate the boards since they only make themselves available for certain devices
114+
boards = [re.search(r"<module>modm:board:(.*?)</module>", config.read_text()).group(1)
115+
for config in Path(repopath("src/modm/board")).glob("*/board.xml")]
116+
boards = [{"name": name(b), "url": board_url(b)} for b in boards]
117+
boards.sort(key=lambda b: b["name"])
118+
bsp_table = format_table(boards, 4)
119+
120+
# Get all the example directory paths
121+
examples = [e.relative_to(example_path) for e in example_path.glob('**/project.xml')]
122+
examples = [{"name": "{}: {}".format(name(str(e.parts[0])), e.parent.relative_to(e.parts[0])),
123+
"url": github_url(Path("examples") / e.parent / "main.cpp")} for e in examples]
124+
examples.sort(key=lambda b: b["name"])
125+
example_table = format_table(examples, 2, "left")
126+
127+
# Get all supported targets
128+
targets = set(get_lbuild(root).find_option("modm:target").values)
129+
ignored_devices = set(d for d in ignored_path.read_text().strip().splitlines() if "#" not in d)
130+
targets -= ignored_devices
131+
avr_count = len([t for t in targets if t.startswith("at")])
132+
stm_count = len([t for t in targets if t.startswith("stm32")])
133+
sam_count = len([t for t in targets if t.startswith("sam")])
134+
all_count = avr_count + stm_count + sam_count
135+
136+
# get the author count
137+
from authors import author_handles
138+
author_count = len(author_handles)
139+
140+
# Get all the modules that are available for the STM32
141+
# Get all drivers, we assume they are available for all devices
142+
drivers = (get_lbuild(root, t).modules for t in {"avr", "stm32", "hosted"})
143+
drivers = {m for mg in drivers for m in mg if m.startswith("modm:driver:")}
144+
drivers = sorted(m.replace("modm:driver:", "") for m in drivers)
145+
drivers = [{"name": name(d), "url": driver_url(d)} for d in drivers if name(d)]
146+
driver_table = format_table(drivers, 6)
147+
148+
# Read the repo README.md and replace these keys
149+
readme = readme_path.read_text()
150+
readme = replace(readme, "authorcount", author_count - 7)
151+
readme = replace(readme, "avrcount", avr_count)
152+
readme = replace(readme, "samcount", sam_count)
153+
readme = replace(readme, "stmcount", stm_count)
154+
readme = replace(readme, "allcount", all_count)
155+
readme = replace(readme, "bsptable", bsp_table)
156+
readme = replace(readme, "drivertable", driver_table)
157+
readme_path.write_text(readme)
158+
159+
# extract these keys
160+
links = extract(readme, "links")
161+
authors = extract(readme, "authors").replace("\\@", "@")
162+
# remove
163+
readme = re.sub(r"((<!--webignore-->.*?<!--/webignore-->)|(<!--links-->.*?<!--/links-->)|(<!--/?bsptable-->))\n", "", readme, flags=re.DOTALL | re.MULTILINE)
164+
165+
index = Environment().from_string(index_in_path.read_text()).render({"content": readme, "links": links, "example_table": example_table})
166+
index_path.write_text(index)
167+
168+
whoweare = Environment().from_string(whoweare_in_path.read_text()).render({"authors": authors, "links": links})
169+
whoweare_path.write_text(whoweare)
170+
171+
# Copy the example readme over
172+
shutil.copy(examples_readme_in_path, examples_readme_path)
173+
174+
# Check git differences and fail
175+
if "-d" in sys.argv:
176+
differences = run(repopath("."), r"git diff")[1]
177+
if len(differences):
178+
subprocess.run("git --no-pager diff", shell=True, cwd=repopath("."))
179+
print("\nPlease synchronize the modm documentation:\n\n"
180+
" $ python3 tools/scripts/synchronize_docs.py\n\n"
181+
"and then commit the results!")
182+
exit(1)
183+
184+
exit(0)

0 commit comments

Comments
 (0)