Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement/Automate Update the manifest refs to tags #4190

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/update_release_refs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import os
import sys

import yaml

folder_path = sys.argv[1]
# Define the folder where YAML files are located
# folder_path = f"/manifests/{new_version}" # Replace with the actual folder path

# Get the folder name and use it as the new version
new_version = os.path.basename(folder_path)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this, you should allow users to enter the manifest full path and retrieve the version from the actual yml file like in any other workflow in this repo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was one of the possible workflow solutions in the issue discussions.
#2546 (comment)


# Define a list of component names that should have the same version as 'OpenSearch' and 'common-utils'
same_version_components = ['OpenSearch', 'common-utils']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only OpenSearch/OpenSearch-Dashboards/functionaltestrepo has same 3 digit version number, others will have 4 digit numbers with 0 as the 4th digit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will check this out and update the code accordingly.


# Iterate through YAML files in the folder and update the 'ref' in each file
for filename in os.listdir(folder_path):
if filename.endswith('.yml'):
yaml_file = os.path.join(folder_path, filename)
with open(yaml_file, 'r') as file:
data = yaml.safe_load(file)
for component in data.get('components', []):
if component['name'] in same_version_components:
ref = component.get('ref', 'Not found')
component['ref'] = f'tags/{new_version}'
else:
component['ref'] = f'tags/{new_version}.0'

with open(yaml_file, 'w') as file:
yaml.dump(data, file)
Comment on lines +16 to +30
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only care about the input manifest with this and we dont care about the test manifest and others for now.
You could consider only working on the yml user pointed to you instead of the folder approach as there might be outliers or make the scope too complicated.


print(f"Ref values updated in the specified YAML files in the folder. New version: {new_version}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should consider using the logging instead of using plain printf.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay sure