Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
AlejandroCabeza committed Mar 5, 2024
1 parent e0f70b7 commit 9e5c335
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/maxver.yml
Original file line number Diff line number Diff line change
@@ -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']"
Empty file added .github/workflows/minver.yml
Empty file.
11 changes: 11 additions & 0 deletions asd.min
Original file line number Diff line number Diff line change
@@ -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
59 changes: 59 additions & 0 deletions scripts/build_libp2p_minver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import re
from itertools import groupby

requires_pattern = r"(?P<requires>requires *)(?P<dependencies>(?P<dependecy>(?P<specification>\".*\")(?P<separators>,? *\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)
34 changes: 34 additions & 0 deletions scripts/build_libp2p_minver.sh
Original file line number Diff line number Diff line change
@@ -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[@]}"

0 comments on commit 9e5c335

Please sign in to comment.