Commit a48cd1b3 authored by Maximilian Dolling's avatar Maximilian Dolling

Merge branch '4-prettify-report' into 'dev'

Resolve "prettify report"

See merge request hifis/software-services/fair/ci-services!7
parents d4e7f293 cd814d9e
......@@ -22,8 +22,8 @@ build-dep-image:
- docker push "${CI_REGISTRY_IMAGE}/$DOCKER_DST_IMAGE_NAME:latest-dep"
only:
changes:
- "build/dependencies/**"
- "build/docker/dep/**"
- "build/dependencies/**/*"
- "build/docker/dep/**/*"
- ".gitlab-ci.yml"
build-dev-image:
......@@ -44,12 +44,11 @@ build-dev-image:
- master
only:
changes:
- "build/docker/dep/**"
- "build/dependencies/**"
- "build/docker/dev/**"
- "build/services/**"
- "src/**"
- "build/dependencies/**/*"
- "build/docker/dep/**/*"
- ".gitlab-ci.yml"
- "build/docker/dev/**/*"
- "src/**/*"
test-dev-image:
stage: test
......@@ -74,6 +73,11 @@ test-dev-image:
fi
except:
- master
only:
changes:
- "build/**/*"
- "src/**/*"
- ".gitlab-ci.yml"
artifacts:
paths:
- meta
......@@ -100,6 +104,6 @@ build-ci-service-image:
refs:
- master
changes:
- "build/**"
- "src/**"
- "build/**/*"
- "src/**/*"
- ".gitlab-ci.yml"
......@@ -9,15 +9,26 @@ working_dir = repo_dir + ARGV[1]
# curate report data
project_name = `basename $(git remote get-url origin)`
project_name = project_name[0, project_name.length - 5]
project_location = `echo $CI_PROJECT_URL`
project_location = project_location[0, project_location.length - 1]
last_commit_ref = `git rev-parse HEAD`
last_commit_ref = last_commit_ref[0, 40]
report_time = Time.now.strftime("%d/%m/%Y %H:%M:%S")
# language detection
repo = Rugged::Repository.new(repo_dir)
project = Linguist::Repository.new(repo, repo.head.target_id)
# assemble report
report = {'last commit hash' => last_commit_ref, 'name' => project_name, 'report time' => report_time, 'language_detection' => project.languages}
report = {'last commit hash' => last_commit_ref,
'name' => project_name,
'report time' => report_time,
'location' => project_location,
'Programming Language Detection' => {'description' => 'Detects used programming languages. Output values are bytes of code.',
'result' => project.languages}}
# assure filepath exists
FileUtils.mkdir_p(working_dir) unless File.exists?(working_dir)
......
......@@ -45,17 +45,49 @@ for root, dirs, files in os.walk(working_dir, topdown=False):
# changes to report to match test output, if test is running
# delete timestamp, last commit hash and set language values to 0 due to frequent changes
if test:
del report_dict['report time']
del report_dict['last commit hash']
for lang in report_dict['language_detection']:
report_dict['language_detection'][lang] = 0
report_dict['report time'] = '0'
report_dict['last commit hash'] = '0'
for lang in report_dict['Programming Language Detection']['result']:
report_dict['Programming Language Detection']['result'][lang] = 0
else:
report_dict.update({'report time': datetime.now().strftime("%d/%m/%Y %H:%M:%S")})
od = collections.OrderedDict(sorted(report_dict.items()))
# sort report
report_dict_ordered = collections.OrderedDict(sorted(report_dict.items()))
# sort subreports
for subreport in report_dict_ordered:
if isinstance(report_dict_ordered[subreport], dict):
report_dict_ordered[subreport]['result'] = collections.OrderedDict(sorted(report_dict_ordered[subreport]['result'].items()))
open(working_dir + '/ci-services-report.md', 'w').close()
# write new report
with open(working_dir + '/ci-services-report.md', "a+") as md:
md.write(json.dumps(od, indent=2))
md.write("# Software Quality Report\n")
md.write("> **Note:** This report is automatically generated by [ci-services]("
"https://gitext.gfz-potsdam.de/hifis/software-services/fair/ci-services)\n\n")
md.write('---\n\n')
# write meta data
md.write("### Meta Data\n\n")
md.write("**Software Name:** {}\n\n".format(report_dict_ordered['name']))
md.write("**Software Location:** [{}]({})\n\n".format(report_dict_ordered['location'].split('.')[0][8:],
report_dict_ordered['location']))
md.write("**Last Commit:** {}\n\n".format(report_dict_ordered['last commit hash']))
md.write("**Report Time:** {}\n\n".format(report_dict_ordered['report time']))
md.write('---\n\n')
# write test results
md.write("### Completed Tests\n")
for subreport in report_dict_ordered:
if isinstance(report_dict_ordered[subreport], dict):
md.write("**{}**\n\n".format(subreport))
md.write("> **Description: {}**\n\n".format(report_dict_ordered[subreport]['description']))
# empty table header
md.write("|name|result|\n")
md.write("|---|---|\n")
for subreport_result in report_dict_ordered[subreport]['result']:
md.write("|{}|{}|\n".format(subreport_result, report_dict_ordered[subreport]['result'][subreport_result]))
# md.write(json.dumps(report_dict_ordered, indent=2))
......@@ -10,13 +10,16 @@ working_dir = repo_dir + sys.argv[2]
# collect report data
project_name = os.popen('basename $(git remote get-url origin)').read()[:-5]
last_commit_ref = os.popen('git rev-parse HEAD').read()[0:40]
project_location = os.popen('echo $CI_PROJECT_URL').read()[:-1]
report_time = datetime.now().strftime("%d/%m/%Y %H:%M:%S")
# generate report as dict
report = {'name': project_name,
'report time': report_time,
'last commit hash': last_commit_ref,
'test': {'test': 'passed'}}
'location': project_location,
'test': {'description': 'used for debug output in test cases',
'result': {'test': 'passed'}}}
# create report
......
{
"language_detection": {
"Ruby": 0,
"Dockerfile": 0,
"Shell": 0,
"Python": 0
},
"name": "ci-services",
"test": {
"test": "passed"
}
}
\ No newline at end of file
# Software Quality Report
> **Note:** This report is automatically generated by [ci-services](https://gitext.gfz-potsdam.de/hifis/software-services/fair/ci-services)
---
### Meta Data
**Software Name:** ci-services
**Software Location:** [gitext](https://gitext.gfz-potsdam.de/hifis/software-services/fair/ci-services)
**Last Commit:** 0
**Report Time:** 0
---
### Completed Tests
**Programming Language Detection**
> **Description: Detects used programming languages. Output values are bytes of code.**
|name|result|
|---|---|
|Dockerfile|0|
|Python|0|
|Ruby|0|
|Shell|0|
**test**
> **Description: used for debug output in test cases**
|name|result|
|---|---|
|test|passed|
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