|
17 | 17 | import github_integration as gh
|
18 | 18 | import source_branch_finder as source_branch
|
19 | 19 |
|
| 20 | + |
| 21 | +def find_pr(branch, prs): |
| 22 | + match = re.search(r'(.*)_PR_([a-zA-Z0-9](?:[a-zA-Z0-9]|[-_](?=[a-zA-Z0-9])){0,38})', branch) |
| 23 | + if match: |
| 24 | + label = f'{match.group(2)}:{match.group(1)}' |
| 25 | + for pr in prs: |
| 26 | + if label == pr['head']['label']: |
| 27 | + return pr |
| 28 | + return None |
| 29 | + |
20 | 30 | # arguments: inputdir outputfile
|
21 | 31 |
|
22 | 32 | cwd = os.getcwd()
|
|
47 | 57 | cvv_sha = os.environ['CORE_V_VERIF_HASH'].strip('\'\"')
|
48 | 58 | cva6_branch = os.environ['CVA6_BRANCH'].strip('\'\"')
|
49 | 59 | cva6_sha = os.environ['CVA6_HASH'].strip('\'\"')
|
| 60 | + source_branch = source_branch.find(cva6_branch) |
50 | 61 | else: # gitlab
|
51 | 62 | workflow_uid = os.environ['CI_PIPELINE_ID'].strip('\'\"')
|
52 | 63 | cvv_branch = 'none'
|
|
56 | 67 | cva6_sha = os.environ['CI_COMMIT_SHA'].strip('\'\"')
|
57 | 68 | workflow_commit_subject = os.environ['CI_COMMIT_MESSAGE'].strip('\'\"')
|
58 | 69 | workflow_commit_author = os.environ['CI_COMMIT_AUTHOR'].strip('\'\"')
|
59 |
| - |
60 |
| -source_branch = source_branch.find(cva6_branch) |
| 70 | + source_branch = "master" |
61 | 71 |
|
62 | 72 | if len(workflow_commit_subject) > 60:
|
63 | 73 | title = workflow_commit_subject[0:60] + '...'
|
|
118 | 128 | filename = re.sub('[^\w\.]', '', sys.argv[2])
|
119 | 129 | print(filename)
|
120 | 130 |
|
| 131 | +pipeline_report_dir = "cva6" if source_branch == "master" else source_branch |
| 132 | + |
121 | 133 | with open(f'{sys.argv[1]}/{filename}', 'w+') as f:
|
122 | 134 | yaml.dump(pipeline, f)
|
123 | 135 |
|
|
126 | 138 | print(subprocess.check_output(f'''
|
127 | 139 | rm -r .gitlab-ci/dashboard_tmp || echo "nothing to do"
|
128 | 140 | git clone {dashboard_url} .gitlab-ci/dashboard_tmp
|
129 |
| -mkdir -p .gitlab-ci/dashboard_tmp/pipelines_{source_branch} |
| 141 | +mkdir -p .gitlab-ci/dashboard_tmp/pipelines_{pipeline_report_dir} |
130 | 142 | ls -al {sys.argv[1]}
|
131 |
| -cp {sys.argv[1]}/{filename} .gitlab-ci/dashboard_tmp/pipelines_{source_branch}/ |
| 143 | +cp {sys.argv[1]}/{filename} .gitlab-ci/dashboard_tmp/pipelines_{pipeline_report_dir}/ |
132 | 144 | cd .gitlab-ci/dashboard_tmp
|
133 | 145 | git config user.email {git_email}
|
134 | 146 | git config user.name {git_name}
|
135 |
| -git add pipelines_{source_branch}/{filename} |
136 |
| -git commit -m '{source_branch}: '{quoted_title} || echo "commit fail" |
| 147 | +git add pipelines_{pipeline_report_dir}/{filename} |
| 148 | +git commit -m '{pipeline_report_dir}: '{quoted_title} || echo "commit fail" |
137 | 149 | git push
|
138 | 150 | cd -
|
139 | 151 | ''', shell=True))
|
140 | 152 | except subprocess.CalledProcessError as e:
|
141 | 153 | print(f"Error: {e.output}")
|
142 | 154 |
|
143 |
| -def find_pr(branch, prs): |
144 |
| - match = re.search(r'(.*)_PR_([a-zA-Z0-9](?:[a-zA-Z0-9]|[-_](?=[a-zA-Z0-9])){0,38})', branch) |
145 |
| - if match: |
146 |
| - label = f'{match.group(2)}:{match.group(1)}' |
147 |
| - for pr in prs: |
148 |
| - if label == pr['head']['label']: |
149 |
| - return pr |
150 |
| - return None |
| 155 | +if workflow_type == "github": |
| 156 | + pulls = gh.pulls('openhwgroup', workflow_repo) |
| 157 | + pr = find_pr(workflow_commit_ref_name, pulls) |
| 158 | +else: |
| 159 | + pr = None |
151 | 160 |
|
152 |
| -pulls = gh.pulls('openhwgroup', workflow_repo) |
153 |
| -pr = find_pr(workflow_commit_ref_name, pulls) |
154 | 161 | if pr is not None:
|
155 | 162 | ref_branch = pr['base']['ref']
|
156 | 163 | wf = gh.DashboardDone('openhwgroup', workflow_repo, ref_branch)
|
157 |
| - response = wf.send(pr['number'], success, source_branch) |
| 164 | + response = wf.send(pr['number'], success, pipeline_report_dir) |
158 | 165 | print(response.text)
|
0 commit comments