From 0dbbf5a3588ced5a2030e001712576b78e281209 Mon Sep 17 00:00:00 2001 From: Yetkin Timocin Date: Mon, 22 Jul 2024 15:52:52 -0700 Subject: [PATCH] Reformatting the files in the scripts folder (#7755) # Description Reformatting the files in the scripts folder ## Type of change - This pull request is a minor refactor, code cleanup, test improvement, or other maintenance task and doesn't change the functionality of Radius (issue link optional). Signed-off-by: ytimocin --- .github/scripts/cleanup-cluster.sh | 4 ++-- .github/scripts/curl-with-retries.sh | 2 +- .github/scripts/get_release_version.py | 10 ++++++---- .github/scripts/release-create-tag-and-branch.sh | 2 +- .github/scripts/release-get-version.sh | 9 ++++----- .github/scripts/release-verification.sh | 4 ++-- .github/scripts/transform_test_results.py | 12 +++++++----- .github/scripts/validate_semver.py | 4 +++- 8 files changed, 26 insertions(+), 21 deletions(-) diff --git a/.github/scripts/cleanup-cluster.sh b/.github/scripts/cleanup-cluster.sh index 32150caba9..e7268f146d 100755 --- a/.github/scripts/cleanup-cluster.sh +++ b/.github/scripts/cleanup-cluster.sh @@ -21,7 +21,7 @@ set -e echo "cleaning up cluster" # Delete all test resources in queuemessages. -if kubectl get crd queuemessages.ucp.dev > /dev/null 2>&1; then +if kubectl get crd queuemessages.ucp.dev >/dev/null 2>&1; then echo "delete all resources in queuemessages.ucp.dev" kubectl delete queuemessages.ucp.dev -n radius-system --all fi @@ -29,7 +29,7 @@ fi # Testing deletion of deployment.apps. # Delete all test resources in resources without proxy resource. -if kubectl get crd resources.ucp.dev > /dev/null 2>&1; then +if kubectl get crd resources.ucp.dev >/dev/null 2>&1; then echo "delete all resources in resources.ucp.dev" resources=$(kubectl get resources.ucp.dev -n radius-system --no-headers -o custom-columns=":metadata.name") for r in $resources; do diff --git a/.github/scripts/curl-with-retries.sh b/.github/scripts/curl-with-retries.sh index f47ddc72d2..a1eb8535fe 100755 --- a/.github/scripts/curl-with-retries.sh +++ b/.github/scripts/curl-with-retries.sh @@ -6,7 +6,7 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software diff --git a/.github/scripts/get_release_version.py b/.github/scripts/get_release_version.py index 4f87ee0afc..b545bb44ef 100644 --- a/.github/scripts/get_release_version.py +++ b/.github/scripts/get_release_version.py @@ -4,7 +4,7 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software @@ -62,7 +62,8 @@ with open(os.getenv("GITHUB_ENV"), "a") as githubEnv: if gitRef is None: - print("This is not running in github, GITHUB_REF is null. Assuming a local build...") + print( + "This is not running in github, GITHUB_REF is null. Assuming a local build...") version = "REL_VERSION=edge" print("Setting: {}".format(version)) @@ -111,7 +112,8 @@ print("Setting: {}".format(chart)) githubEnv.write(chart + "\n") - channel = "REL_CHANNEL={}.{}".format(match.group("major"), match.group("minor")) + channel = "REL_CHANNEL={}.{}".format( + match.group("major"), match.group("minor")) print("Setting: {}".format(channel)) githubEnv.write(channel + "\n") @@ -121,7 +123,7 @@ else: print("This is a prerelease...") - + version = "REL_VERSION={}".format(match.group("version")) print("Setting: {}".format(version)) githubEnv.write(version + "\n") diff --git a/.github/scripts/release-create-tag-and-branch.sh b/.github/scripts/release-create-tag-and-branch.sh index 8691ba5fcd..8589ff1306 100755 --- a/.github/scripts/release-create-tag-and-branch.sh +++ b/.github/scripts/release-create-tag-and-branch.sh @@ -6,7 +6,7 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software diff --git a/.github/scripts/release-get-version.sh b/.github/scripts/release-get-version.sh index d96ac6f31e..64c2a61a7b 100755 --- a/.github/scripts/release-get-version.sh +++ b/.github/scripts/release-get-version.sh @@ -6,7 +6,7 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software @@ -48,8 +48,7 @@ RELEASE_VERSION="" RELEASE_BRANCH_NAME="" pushd $REPOSITORY -for VERSION in $(echo $VERSIONS | sed "s/,/ /g") -do +for VERSION in $(echo $VERSIONS | sed "s/,/ /g"); do # VERSION_NUMBER is the version number without the 'v' prefix (e.g. 0.1.0) VERSION_NUMBER=$(echo $VERSION | cut -d 'v' -f 2) @@ -80,5 +79,5 @@ fi echo "Release version: ${RELEASE_VERSION}" echo "Release branch name: ${RELEASE_BRANCH_NAME}" -echo "release-version=$RELEASE_VERSION" >> $GITHUB_OUTPUT -echo "release-branch-name=$RELEASE_BRANCH_NAME" >> $GITHUB_OUTPUT +echo "release-version=$RELEASE_VERSION" >>$GITHUB_OUTPUT +echo "release-branch-name=$RELEASE_BRANCH_NAME" >>$GITHUB_OUTPUT diff --git a/.github/scripts/release-verification.sh b/.github/scripts/release-verification.sh index 5f91f93672..ca0b404f65 100755 --- a/.github/scripts/release-verification.sh +++ b/.github/scripts/release-verification.sh @@ -4,7 +4,7 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software @@ -38,7 +38,7 @@ EXPECTED_CLI_VERSION=$RELEASE_VERSION_NUMBER EXPECTED_TAG_VERSION=$RELEASE_VERSION_NUMBER # if RELEASE_VERSION_NUMBER contains -rc, then it is a prerelease. -# In that case, we need to set expected tag version to the major.minor of the +# In that case, we need to set expected tag version to the major.minor of the # release version number if [[ $RELEASE_VERSION_NUMBER != *"rc"* ]]; then EXPECTED_TAG_VERSION=$(echo $RELEASE_VERSION_NUMBER | cut -d '.' -f 1,2) diff --git a/.github/scripts/transform_test_results.py b/.github/scripts/transform_test_results.py index 1e37b0e933..8ebaab3cdc 100644 --- a/.github/scripts/transform_test_results.py +++ b/.github/scripts/transform_test_results.py @@ -4,7 +4,7 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software @@ -22,9 +22,11 @@ import sys import xml.etree.ElementTree + def main(): if len(sys.argv) != 4: - print("Usage: transform-test-results.py ") + print( + "Usage: transform-test-results.py ") sys.exit(1) repository_root = sys.argv[1] @@ -38,7 +40,7 @@ def main(): failure = testcase.find('./failure') if failure is None: continue - + # Extract file name by matching regex pattern in the text # it will look like \tError Trace:\tfilename:line match = pattern.search(failure.text) @@ -55,16 +57,16 @@ def main(): continue file = file[len(repository_root) + 1:] - + testcase.attrib["file"] = file testcase.attrib["line"] = line failure.attrib["file"] = file failure.attrib["line"] = line - # Write back to file print(f"Writing {output_file}") et.write(output_file) + if __name__ == "__main__": main() diff --git a/.github/scripts/validate_semver.py b/.github/scripts/validate_semver.py index 7f182606b4..8598647775 100755 --- a/.github/scripts/validate_semver.py +++ b/.github/scripts/validate_semver.py @@ -4,7 +4,7 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software @@ -20,6 +20,7 @@ import re import sys + def main(): if len(sys.argv) != 2: print("Usage: validate_semver.py ") @@ -41,5 +42,6 @@ def main(): print("Provided version is valid semver") sys.exit(0) + if __name__ == "__main__": main()