Skip to content

Commit

Permalink
add gam_run_url to metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
riprasad committed Jan 5, 2025
1 parent a4041b1 commit 28ed3d6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/gated-auto-merger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ jobs:
echo "GAM_EXECUTION_ID=$(date +"%d%m%y%H%M%S%6N")" | tee -a $GITHUB_ENV
fi
echo "THIS_WORKFLOW_RUN_URL=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" | tee -a $GITHUB_ENV
- name: Print Trigger Workflow Details
run: |
echo "This workflow was triggered by https://github.com/${{ env.GAM_TRIGGER_REPOSITORY }}/actions/runs/${{ env.GAM_TRIGGER_RUN_ID }}"
Expand Down Expand Up @@ -75,7 +77,7 @@ jobs:
id: trigger_gam
run: |
cd main
pipenv run python src/main.py --component ${{ inputs.component }} --execution_id ${{ env.GAM_EXECUTION_ID }}
pipenv run python src/main.py --component ${{ inputs.component }} --execution_id ${{ env.GAM_EXECUTION_ID }} --gam_run_url ${{ env.THIS_WORKFLOW_RUN_URL }}
- uses: actions/create-github-app-token@v1
id: app-token
Expand Down
2 changes: 1 addition & 1 deletion config/gam-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ components:
dest:
url: https://github.com/red-hat-data-services/odh-dashboard-sync.git
branch: main
ignore_files: ".env, .env.test"
ignore_files: [".env", ".env.test"]
- name: odh-operator
src:
url: https://github.com/opendatahub-io/opendatahub-operator.git
Expand Down
16 changes: 10 additions & 6 deletions src/gam_controller.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from datetime import datetime
import json
import os
import yaml
Expand All @@ -9,11 +10,12 @@
HYDRA_PAYLOAD_TEMPLATE = 'data/hydra_payload_template.json'

class GamController:
def __init__(self, business_component: str, execution_id: str):
def __init__(self, business_component: str, execution_id: str, gam_run_url: str):
self.business_component = business_component
self.gam_config = self.read_gam_config()
self.component_config = self.read_component_config()
self.execution_id = execution_id
self.execution_id = execution_id if execution_id else self.generate_execution_id()
self.gam_run_url = gam_run_url
self.execution_metadata = self.generate_execution_metadata()
self.hydra_payload = self.generate_hydra_payload()

Expand All @@ -26,8 +28,8 @@ def read_component_config(self):
except IndexError:
raise ValueError(f"Component '{self.business_component}' not found in the configuration '{GAM_CONFIG}'.")

# def generate_execution_id(self):
# return datetime.now().strftime('%d%m%y%H%M%S%f')
def generate_execution_id(self):
return datetime.now().strftime('%d%m%y%H%M%S%f')

def generate_execution_metadata(self):
# Initialize the execution metadata template
Expand All @@ -36,9 +38,11 @@ def generate_execution_metadata(self):
'metadata': {
'execution_id': self.execution_id,
'git': None,
'job_run_url': None,
'nvr': None,
'trigger_automerge': None,
'gam_run_url': self.gam_run_url,
'auto_merge_url': None,
'test_run_url': None,
'test_result': None,
'status': None
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--component', required=True, help='Name of the Business Component', dest='component')
parser.add_argument('--execution_id', required=True, help='A Unique ID for The GAM Execution', dest='execution_id')
parser.add_argument('--execution_id', required=False, help='A Unique ID for The GAM Execution', dest='execution_id')
parser.add_argument('--gam_run_url', required=False, help='Github Action Job run URL for GAM', dest='gam_run_url')
args = parser.parse_args()

gc = GamController(args.component, args.execution_id)
gc = GamController(args.component, args.execution_id, args.gam_run_url)
print("====================================================")
print(" Component Config ")
print("====================================================")
Expand Down

0 comments on commit 28ed3d6

Please sign in to comment.