From 9e5c335b8a21cadd09c6d3e3d1aaa3f2dff35ab8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lex=20Cabeza=20Romero?= Date: Tue, 5 Mar 2024 18:14:01 +0100 Subject: [PATCH] wip --- .github/workflows/maxver.yml | 14 ++++++++ .github/workflows/minver.yml | 0 asd.min | 11 +++++++ scripts/build_libp2p_minver.py | 59 ++++++++++++++++++++++++++++++++++ scripts/build_libp2p_minver.sh | 34 ++++++++++++++++++++ 5 files changed, 118 insertions(+) create mode 100644 .github/workflows/maxver.yml create mode 100644 .github/workflows/minver.yml create mode 100644 asd.min create mode 100644 scripts/build_libp2p_minver.py create mode 100755 scripts/build_libp2p_minver.sh diff --git a/.github/workflows/maxver.yml b/.github/workflows/maxver.yml new file mode 100644 index 0000000000..6e916c7f6b --- /dev/null +++ b/.github/workflows/maxver.yml @@ -0,0 +1,14 @@ +name: Daily (maxver) +on: + # schedule: + # - cron: "0 6 * * *" + push: + branches: + - maxver-minver + +jobs: + call-multi-nim-common: + uses: ./.github/workflows/daily_common.yml + with: + nim-branch: "['version-1-6', 'devel']" + cpu: "['i386']" diff --git a/.github/workflows/minver.yml b/.github/workflows/minver.yml new file mode 100644 index 0000000000..e69de29bb2 diff --git a/asd.min b/asd.min new file mode 100644 index 0000000000..9755551912 --- /dev/null +++ b/asd.min @@ -0,0 +1,11 @@ +nim==1.6.0 +nimcrypto==0.4.1 +dnsclient==0.3.0 +bearssl==0.1.4 +chronicles==0.10.2 +chronos==3.0.6 +metrics +secp256k1 +stew#head +websock +unittest2 diff --git a/scripts/build_libp2p_minver.py b/scripts/build_libp2p_minver.py new file mode 100644 index 0000000000..ceca63abba --- /dev/null +++ b/scripts/build_libp2p_minver.py @@ -0,0 +1,59 @@ +import re +from itertools import groupby + +requires_pattern = r"(?Prequires *)(?P(?P(?P\".*\")(?P,? *\n? *))*)" +file_path: str = "libp2p.nimble" + + +def get_dependencies_group(path: str) -> str: + with open(path, "r") as file: + match = re.search(requires_pattern, file.read()) + return match.group("dependencies") + + +def parse_group(_group: str) -> list[str]: + return _group.replace(" ", "").replace("\n", "").split(",") + + +def clean_dependency(_dependency: str) -> str: + return _dependency.replace("\"", "") + + +# Nimble symbols: <, <=, >, >=, ==, ~=, ^=, # +eq_symbols = ("#", "==") +def contains_eq_symbol(_dependency: str) -> bool: + return any((eq_symbol in _dependency for eq_symbol in eq_symbols)) + + +def classify_dependency(_dependency: str) -> str: + if contains_eq_symbol(_dependency): + return "eq" + elif ">" in _dependency: + return "gt" + else: + return "" + + +def classify_dependencies(_dependencies: list[str]) -> dict[str, list[str]]: + d = { + "eq": [], + "gt": [], + "": [], + } + for _dependency in _dependencies: + d[classify_dependency(_dependency)].append(_dependency) + return d + + +def parse_versions(_classified_dependencies: dict[str, list[str]]): + eq, gt, nothing = _classified_dependencies["eq"], _classified_dependencies["gt"], _classified_dependencies[""] + eq = [re.sub(r"#", "", eq_) for eq_ in eq] + print(eq) + + +dependencies_group: str = get_dependencies_group(file_path) +dependencies: list[str] = [clean_dependency(dependency) for dependency in parse_group(dependencies_group)] +classified_dependencies: dict[str, list[str]] = classify_dependencies(dependencies) +asd = parse_versions(classified_dependencies) # No classifier needed, just replace >= with ==, and remove second part if there is + +print(asd) diff --git a/scripts/build_libp2p_minver.sh b/scripts/build_libp2p_minver.sh new file mode 100755 index 0000000000..4cc60d0197 --- /dev/null +++ b/scripts/build_libp2p_minver.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +requires_pattern="requires *(((\".*\")(,? *\n? *))*)" +file_path="libp2p.nimble" + +get_dependencies_group() { + dependencies=$(grep -Pzo "$requires_pattern" $1 | tr -d '\0') + dependencies=$(sed 's/.*requires *//p' <<< "$dependencies") + echo $dependencies +} + +parse_group() { + group=$(echo $1 | tr -d ' ' | tr -d '\n' | tr ',' ' ' | tr -d '\0') + echo $group +} + +clean_dependency() { + dependency=$(echo $1 | tr -d '"') + echo $dependency +} + +dependencies_group=$(get_dependencies_group $file_path) +dependencies=$(parse_group "$dependencies_group") +var=() +for dependency in $dependencies; do + var+=($(clean_dependency $dependency)) +done + +# print all elements in var +# +for i in "${var[@]}"; do + echo "'"$i"'" +done +# echo "${var[@]}"