Skip to content

Commit

Permalink
Fix for Github action setup-java new required parameter (distribution…
Browse files Browse the repository at this point in the history
…) and Python script error handling
  • Loading branch information
gricher-crto authored Oct 29, 2024
1 parent 437066a commit 1b5f23d
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/generate_java_sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
uses: actions/setup-java@v4
with:
java-version: 1.8
distribution: temurin

- name: Set up Python
uses: actions/setup-python@v5
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/generate_php_sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
uses: actions/setup-java@v4
with:
java-version: 1.8
distribution: temurin

- name: Set up Python
uses: actions/setup-python@v5
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/generate_python_sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
uses: actions/setup-java@v4
with:
java-version: 1.8
distribution: temurin

- name: Set up Python
uses: actions/setup-python@v5
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test_java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
uses: actions/setup-java@v4
with:
java-version: 1.8
distribution: temurin

- name: Set up Python
uses: actions/setup-python@v5
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test_php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
uses: actions/setup-java@v4
with:
java-version: 1.8
distribution: temurin

- name: Set up Python
uses: actions/setup-python@v5
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
uses: actions/setup-java@v4
with:
java-version: 1.8
distribution: temurin

- name: Set up Python
uses: actions/setup-python@v5
Expand Down
12 changes: 6 additions & 6 deletions scripts/push_postman_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def update_collection(uid_to_update, collection_name_to_update, file):
JSON_collection_wrapper = prepare_collection_data(read_collection_data, collection_name_to_update)
collections_response = requests.put(COLLECTIONS_UPDATE_URL_CURR, headers=HEADER, data=JSON_collection_wrapper)
if collections_response.status_code != 200:
raise ValueError("Could not update Postman collections: " + collections_response.status_code)
raise ValueError(f"Could not update Postman collections: {collections_response.status_code}")
f.close()

def create_collection(collection_name_to_update, file):
Expand All @@ -81,7 +81,7 @@ def create_collection(collection_name_to_update, file):
collections_response = requests.post(COLLECTIONS_UPDATE_URL_CURR, headers=HEADER, data=JSON_collection_wrapper)
if collections_response.status_code != 200:
collections_response.json()
raise ValueError("Could not create Postman collections: "+str(collections_response.status_code))
raise ValueError(f"Could not create Postman collections: {collections_response.status_code}")
f.close()

#OpenApiToPostman can't work with absolute paths which is why we have to pass the root dir to the class
Expand Down Expand Up @@ -116,21 +116,21 @@ def main():
workspace_response_json = get_workspace_data()
for file in postman_specification_files:
create_flag = False
print('Updating/Creating collection: '+file)
print(f"Updating/Creating collection: {file}")
solution, version = os.path.basename(file).split('.')[0].split('_')
collection_name_to_update = f'{solutions_naming_map[solution]} {version}'
print(collection_name_to_update)
collection_id_to_update_list = [collection['uid'] for collection in workspace_response_json['collections'] if collection['name'].upper() == collection_name_to_update.upper()]
if len(collection_id_to_update_list) > 1:
raise ValueError("More than 1 collection with the identical name. Please make sure collection names are unique")
raise ValueError("More than 1 collection with an identical name. Please make sure collection names are unique")
elif len(collection_id_to_update_list) == 0:
create_flag = True
else:
uid_to_update = collection_id_to_update_list[0]
if create_flag == False:
update_collection(uid_to_update,collection_name_to_update,file)
else:
create_collection(collection_name_to_update,file)
create_collection(collection_name_to_update, file)

except OSError as err:
print("File manipulation error:", err)
Expand All @@ -141,7 +141,7 @@ def main():
except requests.exceptions.HTTPError as err:
print("Invalid HTTP response", err)
sys.exit(0)
except Exception as e:
except Exception as err:
print("Generic error or a network error:", err)
sys.exit(0)

Expand Down

0 comments on commit 1b5f23d

Please sign in to comment.