Commit 612ddbf4 authored by Laurent Peuch's avatar Laurent Peuch
Browse files

init

parents
#!/usr/bin/env python3
import os
import gitlab
import jinja2
gl = gitlab.Gitlab("https://forge.extranet.logilab.fr", oauth_token=os.environ.get("TOKEN"))
all_core_projects = [x for x in gl.projects.list(all=True) if "cw-core" in x.tag_list]
context = {"projects": {}, "cubes": {}}
for project in all_core_projects:
# grab the pipelines for default branch that hasn't been triggered from another pipeline
pipeline_for_default = None
for pipeline in project.pipelines.list(as_list=False):
if pipeline.ref != "branch/default":
continue
if "TRIGGERED_FROM_OTHER_PROJECT" in {x.key for x in pipeline.variables.list()}:
continue
pipeline_for_default = pipeline
break
assert pipeline_for_default is not None
context["projects"][project.name] = {
"project": project.attributes,
"pipeline": pipeline.attributes,
"jobs": [job.attributes for job in pipeline_for_default.jobs.list(all=True)],
}
os.system("mkdir -p build")
result = jinja2.Template(open("template/index.html", "r").read()).render(**context)
open("build/index.html", "w").write(result)
# reference:
# In [71]: project.attributes
# Out[71]:
# {'id': 385,
# 'description': 'https://cubicweb.readthedocs.io/',
# 'vcs_type': 'hg_git',
# 'name': 'cubicweb',
# 'name_with_namespace': 'cubicweb / cubicweb',
# 'path': 'cubicweb',
# 'path_with_namespace': 'cubicweb/cubicweb',
# 'created_at': '2020-04-10T13:39:55.623Z',
# 'default_branch': 'branch/default',
# 'tag_list': ['cw-core'],
# 'ssh_url_to_repo': 'ssh://git@forge.extranet.logilab.fr/cubicweb/cubicweb',
# 'http_url_to_repo': 'https://forge.extranet.logilab.fr/cubicweb/cubicweb',
# 'web_url': 'https://forge.extranet.logilab.fr/cubicweb/cubicweb',
# 'readme_url': 'https://forge.extranet.logilab.fr/cubicweb/cubicweb/-/blob/branch/default/README',
# 'avatar_url': 'https://forge.extranet.logilab.fr/uploads/-/system/project/avatar/385/cubicweb_logo.png',
# 'star_count': 2,
# 'forks_count': 0,
# 'last_activity_at': '2020-07-22T02:01:43.427Z',
# 'namespace': {'id': 23,
# 'name': 'cubicweb',
# 'path': 'cubicweb',
# 'kind': 'group',
# 'full_path': 'cubicweb',
# 'parent_id': None,
# 'avatar_url': '/uploads/-/system/group/avatar/23/cubicweb.png',
# 'web_url': 'https://forge.extranet.logilab.fr/groups/cubicweb'},
# '_links': {'self': 'https://forge.extranet.logilab.fr/api/v4/projects/385',
# 'issues': 'https://forge.extranet.logilab.fr/api/v4/projects/385/issues',
# 'merge_requests': 'https://forge.extranet.logilab.fr/api/v4/projects/385/merge_requests',
# 'repo_branches': 'https://forge.extranet.logilab.fr/api/v4/projects/385/repository/branches',
# 'labels': 'https://forge.extranet.logilab.fr/api/v4/projects/385/labels',
# 'events': 'https://forge.extranet.logilab.fr/api/v4/projects/385/events',
# 'members': 'https://forge.extranet.logilab.fr/api/v4/projects/385/members'},
# 'empty_repo': False,
# 'archived': False,
# 'visibility': 'public',
# 'resolve_outdated_diff_discussions': False,
# 'container_registry_enabled': True,
# 'issues_enabled': True,
# 'merge_requests_enabled': True,
# 'wiki_enabled': True,
# 'jobs_enabled': True,
# 'snippets_enabled': True,
# 'can_create_merge_request_in': True,
# 'issues_access_level': 'enabled',
# 'repository_access_level': 'enabled',
# 'merge_requests_access_level': 'enabled',
# 'forking_access_level': 'enabled',
# 'wiki_access_level': 'enabled',
# 'builds_access_level': 'enabled',
# 'snippets_access_level': 'enabled',
# 'pages_access_level': 'enabled',
# 'emails_disabled': False,
# 'shared_runners_enabled': True,
# 'lfs_enabled': True,
# 'creator_id': 19,
# 'import_status': 'none',
# 'open_issues_count': 38,
# 'ci_default_git_depth': 50,
# 'public_jobs': True,
# 'build_timeout': 14400,
# 'auto_cancel_pending_pipelines': 'enabled',
# 'build_coverage_regex': '',
# 'ci_config_path': '',
# 'shared_with_groups': [{'group_id': 21,
# 'group_name': 'logilab',
# 'group_full_path': 'logilab',
# 'group_access_level': 40,
# 'expires_at': None}],
# 'only_allow_merge_if_pipeline_succeeds': False,
# 'request_access_enabled': True,
# 'only_allow_merge_if_all_discussions_are_resolved': False,
# 'remove_source_branch_after_merge': None,
# 'printing_merge_request_link_enabled': True,
# 'merge_method': 'ff',
# 'suggestion_commit_message': None,
# 'auto_devops_enabled': False,
# 'auto_devops_deploy_strategy': 'continuous',
# 'autoclose_referenced_issues': True,
# 'permissions': {'project_access': {'access_level': 30,
# 'notification_level': 3},
# 'group_access': {'access_level': 40, 'notification_level': 2}}}
#
# In [73]: pipeline.attributes
# Out[73]:
# {'id': 10509,
# 'sha': 'cc394e8b84ebeb3e27ab7ddbc5c92746e975abdf',
# 'ref': 'branch/default',
# 'status': 'success',
# 'created_at': '2020-07-22T17:41:55.591Z',
# 'updated_at': '2020-07-22T18:11:24.533Z',
# 'web_url': 'https://forge.extranet.logilab.fr/cubicweb/cubicweb/pipelines/10509',
# 'project_id': 385}
#
# In [74]: job.attributes
# Out[74]:
# {'artifacts': [{'file_type': 'trace',
# 'size': 3770,
# 'filename': 'job.log',
# 'file_format': None}],
# 'id': 40326,
# 'status': 'success',
# 'stage': 'lint',
# 'name': 'lint_py',
# 'ref': 'branch/default',
# 'tag': False,
# 'coverage': None,
# 'allow_failure': False,
# 'created_at': '2020-07-22T17:41:55.614Z',
# 'started_at': '2020-07-22T17:42:25.406Z',
# 'finished_at': '2020-07-22T17:43:55.065Z',
# 'duration': 89.659301,
# 'user': {'id': 52,
# 'name': 'Laurent Peuch',
# 'username': 'bram',
# 'state': 'active',
# 'avatar_url': 'https://forge.extranet.logilab.fr/uploads/-/system/user/avatar/52/avatar.png',
# 'web_url': 'https://forge.extranet.logilab.fr/bram',
# 'created_at': '2019-08-07T15:08:00.657Z',
# 'bio': '',
# 'location': 'Brussels',
# 'public_email': '',
# 'skype': '',
# 'linkedin': '',
# 'twitter': '',
# 'website_url': '',
# 'organization': '',
# 'job_title': '',
# 'work_information': None},
# 'commit': {'id': 'cc394e8b84ebeb3e27ab7ddbc5c92746e975abdf',
# 'short_id': 'cc394e8b',
# 'created_at': '2020-07-10T16:40:36.000+02:00',
# 'parent_ids': ['5cd9e6f4133f0cef28e80b6bfb359a5d4166d28e'],
# 'title': 'docs(wip): refactoring in progress',
# 'message': 'docs(wip): refactoring in progress\n',
# 'author_name': 'Simon Chabot',
# 'author_email': 'simon.chabot@logilab.fr',
# 'authored_date': '2020-07-10T16:40:36.000+02:00',
# 'committer_name': 'Simon Chabot',
# 'committer_email': 'simon.chabot@logilab.fr',
# 'committed_date': '2020-07-10T16:40:36.000+02:00',
# 'web_url': 'https://forge.extranet.logilab.fr/cubicweb/cubicweb/-/commit/cc394e8b84ebeb3e27ab7ddbc5c92746e975abdf'},
# 'pipeline': {'id': 10509,
# 'sha': 'cc394e8b84ebeb3e27ab7ddbc5c92746e975abdf',
# 'ref': 'branch/default',
# 'status': 'success',
# 'created_at': '2020-07-22T17:41:55.591Z',
# 'updated_at': '2020-07-22T18:11:24.533Z',
# 'web_url': 'https://forge.extranet.logilab.fr/cubicweb/cubicweb/pipelines/10509'},
# 'web_url': 'https://forge.extranet.logilab.fr/cubicweb/cubicweb/-/jobs/40326',
# 'runner': {'id': 59,
# 'description': 'heptapod-runner-gitlab-runner-665c6d66bf-gxgxx',
# 'ip_address': '92.154.88.244',
# 'active': True,
# 'is_shared': True,
# 'name': 'gitlab-runner',
# 'online': True,
# 'status': 'online'},
# 'artifacts_expire_at': None,
# 'project_id': 385,
# 'pipeline_id': 10509}
body {
font-family: sans;
margin: auto;
padding-top: 10px;
max-width: 1200px;
line-height: 1.6;
color: #222;
background-color: #fefefe;
}
h1 {
text-align: center;
}
table.pipelines {
width: 100%;
border-collapse: collapse;
}
table.pipelines td {
padding: 5px;
white-space: nowrap;
text-align: center;
font-size: small;
}
table.pipelines th {
text-align: right;
}
div.job {
width: 28px;
height: 28px;
margin: auto;
border-radius: 10000000px;
text-align: center;
font-weight: bold;
border: solid 2px black;
}
div.job-success {
border-color: green;
background-color: lightgreen;
}
div.job-failed {
border-color: red;
background-color: orange;
}
div.job-warning {
border-color: yellow;
background-color: lightyellow;
color: orange;
}
\ No newline at end of file
<!doctype html>
<html>
<head>
<title>Latest Build status</title>
<link href="../style.css" rel="stylesheet" type="text/css">
</head>
<body>
<h1>Is everything green?</h1>
<h2>CubicWeb Core Projects</h2>
<table class="pipelines">
{% for project in projects.values() %}
<tr>
<th>{{ project["project"]["name"] }}</th>
{% for job in project["jobs"] %}
<td>
{% if job["status"] == "failed" and job["allow_failure"] %}
<div class="job job-warning">!</div>
{% else %}
<div class="job job-{{ job["status"] }}"> </div>
{% endif %}
{{ job["name"] }}
</td>
{% endfor %}
</tr>
{% endfor %}
</table>
</body>
</html>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment