From b337f795d3b43ed724873f2fdca1c87cb2bc9713 Mon Sep 17 00:00:00 2001 From: Trent Hauck Date: Sat, 20 Jul 2024 13:59:14 -0700 Subject: [PATCH 1/2] fix: make bootstrap check names earlier --- scripts/bootstrap-template.py | 95 ++++++++++++++++++++--------------- 1 file changed, 55 insertions(+), 40 deletions(-) diff --git a/scripts/bootstrap-template.py b/scripts/bootstrap-template.py index 9d3dca3..d759b52 100755 --- a/scripts/bootstrap-template.py +++ b/scripts/bootstrap-template.py @@ -3,18 +3,10 @@ import sys, os, shutil, re from pathlib import Path -shutil.copyfile(f'docs/NEXT_README.md', f'README.md') -os.remove(f'docs/NEXT_README.md') -os.remove(f'docs/README.md') - -if (len(sys.argv) != 2): - raise Exception('usage: python3 bootstrap-template.py ') - -name_extension = sys.argv[1] def is_snake_case(s): # Define the regex pattern for snake case with numbers - pattern = r'^[a-z0-9]+(_[a-z0-9]+)*$' + pattern = r"^[a-z0-9]+(_[a-z0-9]+)*$" # Use re.match to check if the string matches the pattern if re.match(pattern, s): @@ -22,36 +14,25 @@ def is_snake_case(s): else: return False -if name_extension[0].isdigit(): - raise Exception('Please dont start your extension name with a number.') - -if not is_snake_case(name_extension): - raise Exception('Please enter the name of your extension in valid snake_case containing only lower case letters and numbers') def to_camel_case(snake_str): return "".join(x.capitalize() for x in snake_str.lower().split("_")) + def replace(file_name, to_find, to_replace): - with open(file_name, 'r', encoding="utf8") as file : + with open(file_name, "r", encoding="utf8") as file: filedata = file.read() filedata = filedata.replace(to_find, to_replace) - with open(file_name, 'w', encoding="utf8") as file: + with open(file_name, "w", encoding="utf8") as file: file.write(filedata) -files_to_search = [] -files_to_search.extend(Path('./.github').rglob('./**/*.yml')) -files_to_search.extend(Path('./test').rglob('./**/*.test')) -files_to_search.extend(Path('./src').rglob('./**/*.hpp')) -files_to_search.extend(Path('./src').rglob('./**/*.cpp')) -files_to_search.extend(Path('./src').rglob('./**/*.txt')) -files_to_search.extend(Path('./src').rglob('./*.md')) def replace_everywhere(to_find, to_replace): for path in files_to_search: replace(path, to_find, to_replace) replace(path, to_find.capitalize(), to_camel_case(to_replace)) replace(path, to_find.upper(), to_replace.upper()) - + replace("./CMakeLists.txt", to_find, to_replace) replace("./Makefile", to_find, to_replace) replace("./Makefile", to_find.capitalize(), to_camel_case(to_replace)) @@ -59,20 +40,54 @@ def replace_everywhere(to_find, to_replace): replace("./README.md", to_find, to_replace) replace("./extension_config.cmake", to_find, to_replace) -replace_everywhere("quack", name_extension) -replace_everywhere("Quack", name_extension.capitalize()) -replace_everywhere("", name_extension) - -string_to_replace = name_extension -string_to_find = "quack" - -# rename files -os.rename(f'test/sql/{string_to_find}.test', f'test/sql/{string_to_replace}.test') -os.rename(f'src/{string_to_find}_extension.cpp', f'src/{string_to_replace}_extension.cpp') -os.rename(f'src/include/{string_to_find}_extension.hpp', f'src/include/{string_to_replace}_extension.hpp') - -# remove template-specific files -os.remove('.github/workflows/ExtensionTemplate.yml') -# finally, remove this bootstrap file -os.remove(__file__) \ No newline at end of file +if __name__ == "__main__": + if len(sys.argv) != 2: + raise Exception( + "usage: python3 bootstrap-template.py " + ) + + name_extension = sys.argv[1] + + if name_extension[0].isdigit(): + raise Exception("Please dont start your extension name with a number.") + + if not is_snake_case(name_extension): + raise Exception( + "Please enter the name of your extension in valid snake_case containing only lower case letters and numbers" + ) + + shutil.copyfile("docs/NEXT_README.md", "README.md") + os.remove("docs/NEXT_README.md") + os.remove("docs/README.md") + + files_to_search = [] + files_to_search.extend(Path("./.github").rglob("./**/*.yml")) + files_to_search.extend(Path("./test").rglob("./**/*.test")) + files_to_search.extend(Path("./src").rglob("./**/*.hpp")) + files_to_search.extend(Path("./src").rglob("./**/*.cpp")) + files_to_search.extend(Path("./src").rglob("./**/*.txt")) + files_to_search.extend(Path("./src").rglob("./*.md")) + + replace_everywhere("quack", name_extension) + replace_everywhere("Quack", name_extension.capitalize()) + replace_everywhere("", name_extension) + + string_to_replace = name_extension + string_to_find = "quack" + + # rename files + os.rename(f"test/sql/{string_to_find}.test", f"test/sql/{string_to_replace}.test") + os.rename( + f"src/{string_to_find}_extension.cpp", f"src/{string_to_replace}_extension.cpp" + ) + os.rename( + f"src/include/{string_to_find}_extension.hpp", + f"src/include/{string_to_replace}_extension.hpp", + ) + + # remove template-specific files + os.remove(".github/workflows/ExtensionTemplate.yml") + + # finally, remove this bootstrap file + os.remove(__file__) From 4aeeb235b1e9817c76cc0637595dd75dc2e0f08f Mon Sep 17 00:00:00 2001 From: Sam Ansmink Date: Mon, 22 Jul 2024 10:38:20 +0200 Subject: [PATCH 2/2] add workaround for linux ci --- .github/workflows/ExtensionTemplate.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ExtensionTemplate.yml b/.github/workflows/ExtensionTemplate.yml index 43a162a..0b2c52c 100644 --- a/.github/workflows/ExtensionTemplate.yml +++ b/.github/workflows/ExtensionTemplate.yml @@ -22,6 +22,7 @@ jobs: VCPKG_TOOLCHAIN_PATH: ${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake VCPKG_TARGET_TRIPLET: 'x64-linux' GEN: ninja + ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true defaults: run: shell: bash