Skip to content

Commit

Permalink
Source from the correct branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Hubert-Heijkers committed May 9, 2024
1 parent dc8b0e3 commit fe53a79
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/model_validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ jobs:
pip install requests
- name: Run Model validation script
run: python ./.scripts/validate_model.py ${{ github.event.number }} ${{ github.sha }}
run: python ./.scripts/validate_model.py ${{ github.head_ref }} ${{ github.event.number }} ${{ github.sha }}
14 changes: 9 additions & 5 deletions .scripts/validate_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@
from common import *

tm1_database_name = "MiniSData"
branch_name = "main"
if len(sys.argv) > 1:
pr_number = sys.argv[1]
branch_name = sys.argv[1]
if len(sys.argv) > 2:
pr_number = sys.argv[2]
print(f"Pull Request: #{pr_number}")
tm1_database_name = f"{tm1_database_name}-{pr_number}"
if len(sys.argv) > 2:
commit_hash = sys.argv[2]
if len(sys.argv) > 3:
commit_hash = sys.argv[3]
print(f"Commit Hash: {commit_hash}")
tm1_database_name = f"{tm1_database_name}-{commit_hash[:7]}"
print(f"Datbase name: {tm1_database_name}")
print(f"Sourcing from branch: {branch_name}")

tm1_service_root_url = "http://cwc-tm1-v12-demo.tm1-code.io:4444/tm1/api/v1"
tm1_service_username = "[email protected]"
Expand Down Expand Up @@ -62,7 +66,7 @@ def dump_file_content(file_endpoint):

# Pull the latest version of the sources from the main branch
git_pull_payload = {
"Branch": "main"
"Branch": f"{branch_name}"
}
status_code, response = send_post_request(session, tm1_service_root_url, f"{database_endpoint}/GitPull", git_pull_payload)
if status_code != 201:
Expand All @@ -82,7 +86,7 @@ def dump_file_content(file_endpoint):

# Execute the create_Y2Ksales_cube process to validate that it works
process_name = "create_Y2Ksales_cube"
status_code, response = send_post_request(session, tm1_service_root_url, f"{database_endpoint}/Processes('{process_name}')/tm1.ExecuteWithReturn?$expand=*", git_pull_payload)
status_code, response = send_post_request(session, tm1_service_root_url, f"{database_endpoint}/Processes('{process_name}')/tm1.ExecuteWithReturn?$expand=*", {})
if status_code != 201:
log_output(f"The request to execute the {process_name} process failed!", status_code, response)
cleanup()
Expand Down

0 comments on commit fe53a79

Please sign in to comment.