Skip to content

Commit 4ce4b89

Browse files
committed
feat: Improvements
1 parent 45fcbf1 commit 4ce4b89

File tree

4 files changed

+26
-21
lines changed

4 files changed

+26
-21
lines changed

scripts/download-oas.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ fi
3333
# Move oas to root level
3434
mkdir ${ROOT_DIR}/oas
3535
cd ${work_dir}
36-
git clone ${OAS_REPO}
36+
git clone ${OAS_REPO} --quiet
3737

3838
for service_dir in ${work_dir}/${OAS_REPO_NAME}/services/*; do
3939
max_version_dir=""

scripts/generate-sdk/generate-sdk.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,21 @@ fi
7474
# Generate SDK for the specified language
7575
case "${LANGUAGE}" in
7676
go)
77-
echo -e "\nGenerating the Go SDK...\n"
77+
echo -e "\n>> Generating the Go SDK...\n"
7878

7979
source ${LANGUAGE_GENERATORS_FOLDER_PATH}/${LANGUAGE}.sh
8080
# Usage: generate_go_sdk GENERATOR_PATH GIT_HOST GIT_USER_ID [GIT_REPO_ID] [SDK_REPO_URL]
8181
generate_go_sdk ${jar_path} ${GIT_HOST} ${GIT_USER_ID} ${GIT_REPO_ID} ${SDK_REPO_URL}
8282
;;
8383
python)
84-
echo -e "\nGenerating the Python SDK...\n"
84+
echo -e "\n>> Generating the Python SDK...\n"
8585

8686
source ${LANGUAGE_GENERATORS_FOLDER_PATH}/${LANGUAGE}.sh
8787
# Usage: generate_python_sdk GENERATOR_PATH GIT_HOST GIT_USER_ID [GIT_REPO_ID] [SDK_REPO_URL]
8888
generate_python_sdk ${jar_path} ${GIT_HOST} ${GIT_USER_ID} ${GIT_REPO_ID} ${SDK_REPO_URL}
8989
;;
9090
*)
91-
echo "SDK language not supported."
91+
echo "! SDK language not supported."
9292
exit 1
9393
;;
9494
esac

scripts/generate-sdk/languages/go.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,5 +215,4 @@ generate_go_sdk() {
215215
cd ${SDK_REPO_LOCAL_PATH}
216216
goimports -w ${SERVICES_FOLDER}/
217217
make sync-tidy
218-
219218
}

scripts/sdk-create-pr.sh

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,16 @@ else
4141
fi
4242

4343
# Create temp directory to work on
44-
work_dir=$(mktemp -d)
44+
# work_dir=$(mktemp -d)
45+
work_dir="temp-dir" # TODO: For testing only
46+
mkdir -p ${work_dir} # TODO: For testing only
4547
if [[ ! ${work_dir} || -d {work_dir} ]]; then
4648
echo "Unable to create temporary directory"
4749
exit 1
4850
fi
4951

5052
# Delete temp directory on exit
51-
trap "rm -rf ${work_dir}" EXIT
53+
# trap "rm -rf ${work_dir}" EXIT
5254

5355
mkdir ${work_dir}/git_repo # Where the git repo will be created
5456
mkdir ${work_dir}/sdk_backup # Backup of the SDK to check for new modules
@@ -60,11 +62,12 @@ rm -rf ${work_dir}/sdk_to_push/.git
6062

6163
# Initialize git repo
6264
cd ${work_dir}/git_repo
63-
git clone ${REPO_URL_SSH} ./
65+
git clone ${REPO_URL_SSH} ./ --quiet
6466
git config user.name "${COMMIT_NAME}"
6567
git config user.email "${COMMIT_EMAIL}"
6668

67-
cp -a . ${work_dir}/sdk_backup
69+
# cp -a . ${work_dir}/sdk_backup
70+
cp -a . ../${work_dir}/sdk_backup
6871

6972
# Create PR for each new SDK module if there are changes
7073
for service_path in ${work_dir}/sdk_to_push/services/*; do
@@ -74,7 +77,7 @@ for service_path in ${work_dir}/sdk_to_push/services/*; do
7477
# Removal of pulled data is necessary because the old version may have files
7578
# that were deleted in the new version
7679
rm -rf ./services/$service/*
77-
cp -a ${work_dir}/sdk_to_push/services/$service/. ./services/$service
80+
cp -a ../${work_dir}/sdk_to_push/services/$service/. ./services/$service
7881

7982
# Check for changes in the specific folder compared to main
8083
service_changes=$(git status --porcelain "services/$service")
@@ -89,13 +92,12 @@ for service_path in ${work_dir}/sdk_to_push/services/*; do
8992
fi
9093

9194
git add services/${service}/
92-
if [ "${LANGUAGE}" == "go" ] && [ ! -d "${work_dir}/sdk_backup/services/${service}/" ]; then # Check if it is a newly added SDK module
93-
# 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
94-
# the -r flag examines subdirectories of dir recursively
95-
# this prevents errors if there is more than one new module in the SDK generation
96-
go work use -r .
97-
git add go.work
98-
fi
95+
96+
# 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
97+
# The -r flag examines subdirectories of dir recursively
98+
# This prevents errors if there is more than one new module in the SDK generation
99+
go work use -r services
100+
git add go.work
99101

100102
if [[ "$branch" != "main" ]]; then
101103
echo ">> Creating PR for $service"
@@ -108,16 +110,20 @@ for service_path in ${work_dir}/sdk_to_push/services/*; do
108110

109111
# If lint or test fails for a service, we skip it and continue to the next one
110112
make lint skip-non-generated-files=true service=$service || {
111-
echo "! Linting failed for $service"
113+
echo "! Linting failed for $service. THE UPDATE OF THIS SERVICE WILL BE SKIPPED."
112114
continue
113115
}
116+
117+
echo ">> Adding $service to go.work..."
118+
go work use -r services/$service
114119
make test skip-non-generated-files=true service=$service || {
115-
echo "! Testing failed for $service"
120+
echo "! Testing failed for $service. THE UPDATE OF THIS SERVICE WILL BE SKIPPED."
116121
continue
117122
}
118123

119-
git commit -m "Generate $service: $COMMIT_INFO"
120-
git push origin "$branch"
124+
echo ">> Actually pushing changes to main for $service service..."
125+
# git commit -m "Generate $service: $COMMIT_INFO"
126+
# git push origin "$branch"
121127
fi
122128
fi
123129
done

0 commit comments

Comments
 (0)