diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index bca25b4530..8a7761f098 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -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 @@ -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: | @@ -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 @@ -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: | diff --git a/tools/scripts/generate_hal_matrix.py b/tools/scripts/generate_hal_matrix.py index bc1e1e4564..21717079d7 100755 --- a/tools/scripts/generate_hal_matrix.py +++ b/tools/scripts/generate_hal_matrix.py @@ -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 @@ -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".*?", + "{}".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) diff --git a/tools/scripts/synchronize_docs.py b/tools/scripts/synchronize_docs.py index 57ea33263d..c20880249b 100755 --- a/tools/scripts/synchronize_docs.py +++ b/tools/scripts/synchronize_docs.py @@ -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) @@ -152,7 +148,6 @@ 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) @@ -160,7 +155,6 @@ def get_lbuild(root, target=None): 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)