5151trap " rm -rf ${work_dir} " EXIT
5252
5353mkdir ${work_dir} /git_repo # Where the git repo will be created
54- mkdir ${work_dir} /sdk_backup # Backup of the SDK to check for new modules
54+ mkdir ${work_dir} /sdk_backup # Backup of the SDK to check for new modules
5555mkdir ${work_dir} /sdk_to_push # Copy of SDK to push
5656
5757# Prepare SDK to push
@@ -74,37 +74,47 @@ for service_path in ${work_dir}/sdk_to_push/services/*; do
7474 # Removal of pulled data is necessary because the old version may have files
7575 # that were deleted in the new version
7676 rm -rf ./services/$service /*
77- cp -a ${work_dir} /sdk_to_push/services/$service /. ./services/$service
77+ cp -a ${work_dir} /sdk_to_push/services/$service /. ./services/$service
7878
7979 # Check for changes in the specific folder compared to main
8080 service_changes=$( git status --porcelain " services/$service " )
8181
8282 if [[ -n " $service_changes " ]]; then
83- echo " Committing changes for $service "
83+ echo " Committing changes for $service "
8484 if [[ " $BRANCH_PREFIX " != " main" ]]; then
8585 git switch main # This is needed to create a new branch for the service without including the previously committed files
8686 branch=" $BRANCH_PREFIX /$service "
8787 git switch -c " $branch "
8888 else
8989 branch=$BRANCH_PREFIX
90- fi
91-
90+ fi
91+
9292 git add services/${service} /
9393 if [ " ${LANGUAGE} " == " go" ] && [ ! -d " ${work_dir} /sdk_backup/services/${service} /" ]; then # Check if it is a newly added SDK module
9494 # go work use -r adds a use directive to the go.work file for dir, if it exists, and removes the use directory if the argument directory doesn’t exist
9595 # the -r flag examines subdirectories of dir recursively
9696 # this prevents errors if there is more than one new module in the SDK generation
97- go work use -r .
97+ go work use -r .
9898 git add go.work
9999 fi
100-
100+
101101 if [[ " $branch " != " main" ]]; then
102102 git commit -m " Generate $service "
103103 git push origin " $branch "
104104 gh pr create --title " Generator: Update SDK /services/$service " --body " $COMMIT_INFO " --head " $branch " --base " main"
105105 else
106+ # If lint or test fails for a service, we skip it and continue to the next one
107+ make lint skip-non-generated-files=true service=$service || {
108+ echo " Linting failed for service: $service "
109+ continue
110+ }
111+ make test skip-non-generated-files=true service=$service || {
112+ echo " Testing failed for service: $service "
113+ continue
114+ }
115+
106116 git commit -m " Generate $service : $COMMIT_INFO "
107117 git push origin " $branch "
108- fi
118+ fi
109119 fi
110- done
120+ done
0 commit comments