Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependency versions (released+1) #51

Merged
merged 3 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@ name: CI
on:
workflow_dispatch:
push:
# Only run when there are changes under proto dir
# Only run when there are changes under relevant dirs
paths:
- "proto/**"
- ".github/workflows/**"
- "scripts/**"
branches:
- c4t
- dev
pull_request:
# Only run when there are changes under proto dir
# Only run when there are changes under relevant dirs
paths:
- "proto/**"
- ".github/workflows/**"
- "scripts/**"

jobs:
# Run buf's lint to check for errros
Expand Down
26 changes: 21 additions & 5 deletions scripts/dependency_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,14 @@ def getC4TFiles():

# Get the proto files in the c4t branch by calling an external script
c4t_files = []
c4t_folders = {}
try:
c4t_files = os.popen("scripts/create_c4t_file_listing.sh").read().splitlines()

for file in c4t_files:
folder = os.path.dirname(file)
if folder not in c4t_folders:
c4t_folders[folder] = 1
except:
print("⛔ [FATAL] Unable to get c4t files. Exiting")
sys.exit(1)
Expand All @@ -69,7 +75,7 @@ def getC4TFiles():
print("⛔ [FATAL] No files found in c4t branch. Exiting")
sys.exit(1)

return c4t_files
return c4t_files, c4t_folders

def extract_command_line_args():
# Create an ArgumentParser object
Expand Down Expand Up @@ -241,7 +247,7 @@ def print_dependency_graph(dep_dict):
print()
print("🔧 Trying to fix the dependencies...")

c4tfiles = getC4TFiles()
c4tfiles, c4tfolders = getC4TFiles()

max_iterations=20

Expand Down Expand Up @@ -294,9 +300,19 @@ def print_dependency_graph(dep_dict):
match = file_pattern.match(file)
if match:
prefix, version, proto_filename = match.groups()
version_number = int(version[1:]) + 1
new_path = f"{prefix}/v{version_number}"
new_filename = f"{new_path}/{proto_filename}"
# We have to make sure that the directory does not exist already in the c4t branch because we always want to
# add new files into the released + 1 version!
vnr_add = 1
while True:
version_number = int(version[1:]) + vnr_add
new_path = f"{prefix}/v{version_number}"
# now we need to check whether this path does already exist in the c4t branch.
# If yes, skip to the next version
# If no we found the right version!
if new_path not in c4tfolders:
new_filename = f"{new_path}/{proto_filename}"
break
vnr_add += 1

print(f"✳️ Creating a new file: {new_filename}")
ensure_directory_exists(directory_path + new_path)
Expand Down
28 changes: 26 additions & 2 deletions scripts/diff_against_branch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,37 @@ function check_added_file {
FILE=$1

FILE_VERSION=$(echo $FILE | grep -oP "/v[0-9]+/" | cut -d"v" -f2 | cut -d"/" -f1)
DIRNAME=$(dirname $FILE)

# check whether this folder does already exist in the origin branch
if git show origin/$ORIGIN:$DIRNAME > /dev/null 2>&1 ; then
# This does already exist!
echo -e "❌ ${RED}[FAIL] ERROR${NC}: The folder ${PURPLE}$DIRNAME${NC} is already present the origin branch. The newly added file ${PURPLE}$FILE${NC} should be in a new version folder not present in the origin branch!"
ERROR_FILES+=("$FILE")
return
fi

if [[ "$FILE_VERSION" == "1" ]] ; then
# Skip it as it's newly introduced
return
fi

OTHER_FILE=$(echo $FILE | sed -e "s#/v$FILE_VERSION/#/v$(( FILE_VERSION - 1))/#")

SEARCH_VERSION=$FILE_VERSION
FOUND_PREV_VERSION=false

while [[ $SEARCH_VERSION > 0 ]] ; do
SEARCH_VERSION=$(( SEARCH_VERSION - 1 ))
OTHER_FILE=$(echo $FILE | sed -e "s#/v${FILE_VERSION}/#/v${SEARCH_VERSION}/#")
if git show origin/$ORIGIN:$OTHER_FILE > /dev/null 2>&1 ; then
FOUND_PREV_VERSION=true
break
fi
done

if [[ "$FOUND_PREV_VERSION" == "false" ]] ; then
echo -e "✅ ${GREEN}[PASS] INFO${NC}: Skipping the newly introduced file ${PURPLE}$FILE${NC} as there is no previous version found in the origin branch"
return
fi

echo
echo -e "🆕 Detected newly added file: ${PURPLE}$FILE${NC}"
Expand Down
Loading