Skip to content

Commit

Permalink
[ci] Separate check for HAL support matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
salkinium committed Apr 1, 2021
1 parent a85c0ab commit 253100b
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 30 deletions.
37 changes: 21 additions & 16 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
uses: actions/checkout@v2
- name: Update submodules and install lbuild
run: |
(git submodule sync && git submodule update --init --jobs 8) & pip3 install -U lbuild & wait
(git submodule sync && git submodule update --init --jobs 8) & pip3 install --upgrade --upgrade-strategy=eager modm & wait
- name: Check environment
run: |
env
Expand All @@ -29,6 +29,25 @@ jobs:
arm-none-eabi-g++ --version
which lbuild
lbuild --version
- name: Check for Trailing Whitespace
if: always()
run: |
python3 tools/scripts/rm_whitespace.py
- name: Synchronize Documentation
if: always()
run: |
git checkout .
python3 tools/scripts/synchronize_docs.py -d
- name: Synchronize HAL Support Matrix
if: always()
run: |
git checkout .
python3 tools/scripts/generate_hal_matrix.py -d
- name: Check Examples
if: always()
run: |
git checkout .
python3 tools/scripts/examples_check.py
- name: Hosted Unittests
if: always()
run: |
Expand Down Expand Up @@ -57,20 +76,6 @@ jobs:
run: |
python3 tools/scripts/authors.py --handles --count --shoutout --since 2017-01-01
python3 tools/xpcc_generator/builder/system_layout.py examples/xpcc/xml/communication.xml -o /tmp
- name: Check for Trailing Whitespace
if: always()
run: |
python3 tools/scripts/rm_whitespace.py
git checkout .
- name: Synchronize Documentation
if: always()
run: |
python3 tools/scripts/synchronize_docs.py -d
git checkout .
- name: Check Examples
if: always()
run: |
python3 tools/scripts/examples_check.py
stm32-examples:
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -275,7 +280,7 @@ jobs:
uses: actions/checkout@v2
- name: Update submodules and install lbuild
run: |
(git submodule sync && git submodule update --init --jobs 8) & pip3 install -U lbuild & wait
(git submodule sync && git submodule update --init --jobs 8) & pip3 --upgrade --upgrade-strategy=eager modm & wait
- name: Test run of docs.modm.io-generator-script
if: always()
run: |
Expand Down
28 changes: 21 additions & 7 deletions tools/scripts/generate_hal_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# -----------------------------------------------------------------------------

import lbuild, re, functools
import lbuild, re, functools, sys, subprocess
from collections import defaultdict
from jinja2 import Environment
from pathlib import Path
Expand Down Expand Up @@ -209,9 +209,23 @@ def hal_format_tables():

return tables

# if __name__ == "__main__":
# output = hal_format_tables()
# print(output["avr"])
# print(output["stm32_all"])
# print(output["stm32"])
# print(output["sam"])

hal_tables = hal_format_tables()
readme = repopath("README.md")
readme.write_text(re.sub(
r"<!--alltable-->.*?<!--/alltable-->",
"<!--alltable-->{}<!--/alltable-->".format(hal_tables["all"]),
readme.read_text(), flags=re.DOTALL | re.MULTILINE))

# Check git differences and fail
if "-d" in sys.argv:
differences = subprocess.run("git diff", shell=True, cwd=repopath("."),
stdout=subprocess.PIPE).stdout.decode("utf-8").strip(" \n")
if len(differences):
subprocess.run("git --no-pager diff", shell=True, cwd=repopath("."))
print("\nPlease synchronize the HAL implementation table:\n\n"
" $ python3 tools/scripts/generate_hal_matrix.py\n\n"
"and then commit the results!")
exit(1)

exit(0)
8 changes: 1 addition & 7 deletions tools/scripts/synchronize_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@
"""

def repopath(path):
return (Path(os.path.abspath(__file__)).parents[2] / path)

with open(repopath("tools/scripts/generate_hal_matrix.py")) as hal_tables:
exec(hal_tables.read())
repopath = lambda path: Path(__file__).parents[2] / path

def run(where, command, stdin=None):
print(command)
Expand Down Expand Up @@ -152,15 +148,13 @@ def get_lbuild(root, target=None):
driver_table = format_table(drivers, 6)

# Read the repo README.md and replace these keys
hal_tables = hal_format_tables()
readme = readme_path.read_text()
readme = replace(readme, "authorcount", author_count - 7)
readme = replace(readme, "avrcount", avr_count)
readme = replace(readme, "samcount", sam_count)
readme = replace(readme, "stmcount", stm_count)
readme = replace(readme, "allcount", all_count)
readme = replace(readme, "bsptable", bsp_table)
readme = replace(readme, "alltable", hal_tables["all"])
readme = replace(readme, "drivertable", driver_table)
readme_path.write_text(readme)

Expand Down

0 comments on commit 253100b

Please sign in to comment.