Skip to content

Commit

Permalink
ci: add check-all scripts
Browse files Browse the repository at this point in the history
Signed-off-by: peefy <[email protected]>
  • Loading branch information
Peefy committed Apr 23, 2024
1 parent 9853360 commit a7e714a
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
test:
./scripts/test.sh

check-all:
python3 ./scripts/check-all.py
48 changes: 48 additions & 0 deletions scripts/check-all.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import os
import subprocess
from concurrent.futures import ThreadPoolExecutor


def run_kcl_command(path):
"""
Executes the kcl run command
"""
print(f"Running 'kcl run' in {path}...")
result = subprocess.run(["kcl", "run"], cwd=path, capture_output=True, text=True)
if result.stderr:
print(f"Error running 'kcl run' in {path}: {result.stderr}")
else:
print(f"Output from running 'kcl run' in {path}: {result.stdout}")


def find_and_run_kcl(paths_list):
"""
Concurrently executes the kcl run command in paths containing kcl.mod
"""
with ThreadPoolExecutor() as executor:
executor.map(run_kcl_command, paths_list)


def find_kcl_mod_files(directory):
"""
Recursively searches for paths containing the kcl.mod file
"""
paths_with_kcl_mod = []
for root, dirs, files in os.walk(directory):
if "kcl.mod" in files:
paths_with_kcl_mod.append(root)
return paths_with_kcl_mod


def main():
examples_dir = "examples" # Set the path of the examples folder
paths_with_kcl_mod = find_kcl_mod_files(examples_dir)
if paths_with_kcl_mod:
print(f"Found {len(paths_with_kcl_mod)} paths with 'kcl.mod'.")
find_and_run_kcl(paths_with_kcl_mod)
else:
print("No 'kcl.mod' files found in the directory.")


if __name__ == "__main__":
main()

0 comments on commit a7e714a

Please sign in to comment.