Skip to content

Commit 1533607

Browse files
committed
feat: Lint and test service before pushing to main
1 parent b67c0d0 commit 1533607

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

scripts/generate-sdk/generate-sdk.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ jar_path="${GENERATOR_PATH}/openapi-generator-cli.jar"
6565
if [ -e ${jar_path} ] && [ $(java -jar ${jar_path} version) == ${GENERATOR_VERSION_NUMBER} ]; then
6666
:
6767
else
68-
echo "Downloading OpenAPI generator (version ${GENERATOR_VERSION}) to ${GENERATOR_PATH}..."
68+
echo "Downloading OpenAPI generator (version ${GENERATOR_VERSION})..."
6969
mkdir -p ${GENERATOR_PATH}
70-
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/${GENERATOR_VERSION_NUMBER}/openapi-generator-cli-${GENERATOR_VERSION_NUMBER}.jar -O ${jar_path}
70+
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/${GENERATOR_VERSION_NUMBER}/openapi-generator-cli-${GENERATOR_VERSION_NUMBER}.jar -O ${jar_path} --quiet
7171
echo "Download done."
7272
fi
7373

scripts/sdk-create-pr.sh

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fi
5151
trap "rm -rf ${work_dir}" EXIT
5252

5353
mkdir ${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
5555
mkdir ${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

Comments
 (0)