Commit 0eb50f5b authored by Maximilian Dolling's avatar Maximilian Dolling

Resolve "add version to report and -v"

parent f6edd771
......@@ -5,7 +5,7 @@ stages:
- ci-services
variables:
VERSION: 0.0.4
VERSION: 0.1.0
DOCKER_DST_IMAGE_NAME: ci-services
build-deploy:dep:
......
......@@ -2,7 +2,7 @@
---
This Framework provides various services for the GitLab CI regarding to software quality.
This framework provides various services for the GitLab CI regarding to software quality.
## Description
......
......@@ -9,6 +9,7 @@ RUN apk upgrade
# copy entrypoint script to executables
COPY ./build/docker/dev/docker-entrypoint.sh /usr/local/bin/
COPY ./build/docker/dev/entrypoint-manual.txt /usr/local/bin/
RUN echo '0.1.0' > /version.txt
# copy service scripts to root dir
COPY ./src/services /services
......
......@@ -10,17 +10,23 @@ then
fi
# checks for command line argument to start respective service
if [ "$1" = "--all" ] || [ "$1" = "-a" ]
then
/services/language_detection/service_language_detection.sh
/services/report/service_report.sh "$2"
chmod -R 777 /repo/meta
exit 0
fi
if [ "$1" = "--help" ] || [ "$1" = "-h" ]
then
cat /usr/local/bin/entrypoint-manual.txt
exit 0
fi
if [ "$1" = "--test" ] || [ "$1" = "-t" ]
if [ "$1" = "--language" ] || [ "$1" = "-l" ]
then
/services/test/service_test.sh
/services/language_detection/service_language_detection.sh
/services/report/service_report.sh --test --debug
chmod -R 777 /repo/meta
exit 0
fi
......@@ -32,18 +38,18 @@ then
exit 0
fi
if [ "$1" = "--language" ] || [ "$1" = "-l" ]
if [ "$1" = "--test" ] || [ "$1" = "-t" ]
then
/services/test/service_test.sh
/services/language_detection/service_language_detection.sh
/services/report/service_report.sh --test --debug
chmod -R 777 /repo/meta
exit 0
fi
if [ "$1" = "--all" ] || [ "$1" = "-a" ]
if [ "$1" = "--version" ] || [ "$1" = "-v" ]
then
/services/language_detection/service_language_detection.sh
/services/report/service_report.sh "$2"
chmod -R 777 /repo/meta
cat /version.txt
exit 0
fi
......
......@@ -13,4 +13,5 @@ Available services:
generates markdown report
-t, --test show the content of the repo to run services on
and list all available services
and runs all available services with certain debug flags
\ No newline at end of file
and runs all available services with certain debug flags
-v, --version returns version of ci-services
\ No newline at end of file
......@@ -9,6 +9,7 @@ RUN apk upgrade
# copy entrypoint script to executables
COPY ./build/docker/production/docker-entrypoint.sh /usr/local/bin/
COPY ./build/docker/production/entrypoint-manual.txt /usr/local/bin/
RUN echo '0.1.0' > /version.txt
# copy service scripts to root dir
COPY ./src/services /services
......
......@@ -10,16 +10,17 @@ then
fi
# checks for command line argument to start respective service
if [ "$1" = "--help" ] || [ "$1" = "-h" ]
if [ "$1" = "--all" ] || [ "$1" = "-a" ]
then
cat /usr/local/bin/entrypoint-manual.txt
/services/language_detection/service_language_detection.sh
/services/report/service_report.sh
chmod -R 777 /repo/meta
exit 0
fi
if [ "$1" = "--report" ] || [ "$1" = "-r" ]
if [ "$1" = "--help" ] || [ "$1" = "-h" ]
then
/services/report/service_report.sh
chmod -R 777 /repo/meta
cat /usr/local/bin/entrypoint-manual.txt
exit 0
fi
......@@ -30,14 +31,19 @@ then
exit 0
fi
if [ "$1" = "--all" ] || [ "$1" = "-a" ]
if [ "$1" = "--report" ] || [ "$1" = "-r" ]
then
/services/language_detection/service_language_detection.sh
/services/report/service_report.sh "$2"
/services/report/service_report.sh
chmod -R 777 /repo/meta
exit 0
fi
if [ "$1" = "--version" ] || [ "$1" = "-v" ]
then
cat /version.txt
exit 0
fi
# if no suitable argument was found, shows help page
echo
echo "Unknown command line argument! Showing help page..."
......
......@@ -10,4 +10,5 @@ Available services:
-h, --help shows this help page
-l, --language lists used programming languages in given repo
-r, --report consolidates reports from previous ran services
generates markdown report
\ No newline at end of file
generates markdown report
-v, --version returns version of ci-services
\ No newline at end of file
......@@ -9,13 +9,15 @@
**Software Location:** [gitext](https://gitext.gfz-potsdam.de/hifis/software-services/fair/ci-services)
**Last Commit:** 168465c558f94e0d1b92c51060b1d956eeb85c91
**Last Commit:** 93b84e30e87c5b611d84f0a18830e2c62ffb485a
**Report Time:** 22/03/2020 14:27:53
**Report Time:** 22/03/2020 20:57:31
**Report Version:** 0.1.0
---
### Completed Tests
### Completed Services
**Programming Language Detection**
......@@ -23,7 +25,7 @@
|name|result|
|---|---|
|Dockerfile|1745|
|Python|4626|
|Ruby|1350|
|Shell|2959|
|Dockerfile|1809|
|Python|5017|
|Ruby|1502|
|Shell|3118|
......@@ -21,6 +21,9 @@ last_commit_ref = last_commit_ref[0, 40]
report_time = Time.now.strftime("%d/%m/%Y %H:%M:%S")
report_version = File.read("/version.txt")
report_version = report_version[0, report_version.length - 1]
# language detection
repo = Rugged::Repository.new(repo_dir)
project = Linguist::Repository.new(repo, repo.head.target_id)
......@@ -30,6 +33,7 @@ report = {'last commit hash' => last_commit_ref,
'name' => project_name,
'report time' => report_time,
'location' => project_location,
'report version' => report_version,
'Programming Language Detection' => {'description' => 'Detects used programming languages. Output values are bytes of code.',
'result' => project.languages}}
......
......@@ -18,6 +18,10 @@ if "--test" in sys.argv:
if "--debug" in sys.argv:
cleanup = False
report_version = ''
with open('/version.txt', 'r') as file:
report_version = file.read().replace('\n', '')
# assure that report directory exists
Path(working_dir).mkdir(parents=True, exist_ok=True)
......@@ -29,7 +33,7 @@ Path(working_dir).mkdir(parents=True, exist_ok=True)
report_time = datetime.now().strftime("%d/%m/%Y %H:%M:%S")
# consolidate subreports
report_dict = {}
report_dict = {'report version': report_version}
for root, dirs, files in os.walk(working_dir, topdown=False):
for file in files:
......@@ -79,10 +83,11 @@ with open(working_dir + '/ci-services-report.md', "a+") as md:
md.write("**Software Location:** local\n\n")
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("**Report Version:** {}\n\n".format(report_dict_ordered['report version']))
md.write('---\n\n')
# write test results
md.write("### Completed Tests\n")
md.write("### Completed Services\n")
for subreport in report_dict_ordered:
if isinstance(report_dict_ordered[subreport], dict):
md.write("\n**{}**\n\n".format(subreport))
......
......@@ -14,12 +14,16 @@ project_location = os.popen('echo $CI_PROJECT_URL').read()[:-1]
if project_location == '':
project_location = 'local'
report_time = datetime.now().strftime("%d/%m/%Y %H:%M:%S")
report_version = ''
with open('/version.txt', 'r') as file:
report_version = file.read().replace('\n', '')
# generate report as dict
report = {'name': project_name,
'report time': report_time,
'last commit hash': last_commit_ref,
'location': project_location,
'report version': report_version,
'test': {'description': 'used for debug output in test cases',
'result': {'test': 'passed'}}}
......
......@@ -13,9 +13,11 @@
**Report Time:** 0
**Report Version:** 0.1.0
---
### Completed Tests
### Completed Services
**Programming Language Detection**
......
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