...
 
Commits (2)
......@@ -102,6 +102,7 @@ test:python-unittest:
script:
- python test/unittests/test_generate_report.py
- python test/unittests/test_list_used_licenses.py
- python test/unittests/test_validation.py
only:
changes:
- "**/*.py"
......
......@@ -58,7 +58,7 @@ if [ ! -d /repo/.sqa ]; then
fi
# validate the config
if ! python /utility/validate_config.py; then
if ! python /utility/validation/validate_config.py /repo/.sqa/config.yml; then
exit $?
fi
......
......@@ -30,6 +30,9 @@ from schema import Schema, And, Use, Optional
import yaml
import sys
# config vars
config_path = sys.argv[1]
config_schema = Schema({'list-used-licenses': {'exclude': [str],
'rename': {'lib': {str: {str: str}}},
'local_imports': {str: [str]}},
......@@ -47,7 +50,7 @@ config_schema = Schema({'list-used-licenses': {'exclude': [str],
'insignificant': {'spdx-identifier': str,
'copyright': str}}}})
with open('/repo/.sqa/config.yml') as config_yaml:
with open(config_path) as config_yaml:
config = yaml.load(config_yaml, Loader=yaml.FullLoader)
config_yaml.close()
......
# software-quality-assurance
# This Software provides services to check and improve the source code quality of software-projects
#
# SPDX-FileCopyrightText: 2020 Helmholtz Centre Potsdam - GFZ German Research Centre for Geosciences Potsdam, Germany (https://www.gfz-potsdam.de/)
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version, complemented with
# the following provision:
# For the scientific transparency and verification of results obtained
# and communicated to the public after using a modified version of the
# work, You (as the recipient of the source code and author of this
# modified version, used to produce the published results in scientific
# communications) commit to make this modified source code available in
# a repository that is easily and freely accessible for a duration of
# five years after the communication of the obtained results.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import unittest
import subprocess
class TestValidateConfig(unittest.TestCase):
def test_valid(self):
# valid config
exitcode = subprocess.call(['python',
'src/utility/validation/validate_config.py',
'test/unittests/testfiles/config_valid.yml'],
stdout=subprocess.DEVNULL)
assert exitcode == 0
def test_completeness(self):
# typo in config naming
exitcode = subprocess.call(['python',
'src/utility/validation/validate_config.py',
'test/unittests/testfiles/config_incomplete.yml'],
stdout=subprocess.DEVNULL)
assert exitcode == 1
def test_datatypes(self):
# wrong data type in config
exitcode = subprocess.call(['python',
'src/utility/validation/validate_config.py',
'test/unittests/testfiles/config_wrong_datatype.yml'],
stdout=subprocess.DEVNULL)
assert exitcode == 1
if __name__ == '__main__':
unittest.main()
# SPDX-FileCopyrightText: 2020 Helmholtz Centre Potsdam - GFZ German Research Centre for Geosciences Potsdam, Germany (https://www.gfz-potsdam.de/)
#
# SPDX-License-Identifier: CC0-1.0
list-used-licenses:
# exclude patterns for license check
exclude:
- 'doc/.*' # documentation
- 'meta/.*' # meta data
- 'test/.*' # test files
- '.*dep5_template$' # plain text template file, not source code
# matching of imported name to name in pkg manager
rename:
lib:
Python:
yaml: 'PyYAML'
stdlib_list: 'stdlib-list'
# mark local imports to exclude from license check
local_imports:
Python:
- 'functions'
apply-license:
description: 'This Software provides services to check and improve the source code quality of software-projects'
copyright: 'Helmholtz Centre Potsdam - GFZ German Research Centre for Geosciences Potsdam, Germany (https://www.gfz-potsdam.de/)'
time: '2020'
maintainer:
name: 'Maximilian Dolling'
mail: 'mdolling@gfz-potsdam.de'
licenses:
data:
spdx-identifier: 'CC-BY-4.0'
copyright: 'GFZ-Potsdam'
software:
spdx-identifier: 'GPL-3.0-or-later'
copyright: 'GFZ-Potsdam'
pictures:
spdx-identifier: 'CC-BY-4.0'
copyright: 'GFZ-Potsdam'
insignificant:
spdx-identifier: 'CC0-1.0'
copyrigh: 'GFZ-Potsdam'
# SPDX-FileCopyrightText: 2020 Helmholtz Centre Potsdam - GFZ German Research Centre for Geosciences Potsdam, Germany (https://www.gfz-potsdam.de/)
#
# SPDX-License-Identifier: CC0-1.0
list-used-licenses:
# exclude patterns for license check
exclude:
- 'doc/.*' # documentation
- 'meta/.*' # meta data
- 'test/.*' # test files
- '.*dep5_template$' # plain text template file, not source code
# matching of imported name to name in pkg manager
rename:
lib:
Python:
yaml: 'PyYAML'
stdlib_list: 'stdlib-list'
# mark local imports to exclude from license check
local_imports:
Python:
- 'functions'
apply-license:
description: 'This Software provides services to check and improve the source code quality of software-projects'
copyright: 'Helmholtz Centre Potsdam - GFZ German Research Centre for Geosciences Potsdam, Germany (https://www.gfz-potsdam.de/)'
time: '2020'
maintainer:
name: 'Maximilian Dolling'
mail: 'mdolling@gfz-potsdam.de'
licenses:
data:
spdx-identifier: 'CC-BY-4.0'
copyright: 'GFZ-Potsdam'
software:
spdx-identifier: 'GPL-3.0-or-later'
copyright: 'GFZ-Potsdam'
pictures:
spdx-identifier: 'CC-BY-4.0'
copyright: 'GFZ-Potsdam'
insignificant:
spdx-identifier: 'CC0-1.0'
copyright: 'GFZ-Potsdam'
# SPDX-FileCopyrightText: 2020 Helmholtz Centre Potsdam - GFZ German Research Centre for Geosciences Potsdam, Germany (https://www.gfz-potsdam.de/)
#
# SPDX-License-Identifier: CC0-1.0
list-used-licenses:
# exclude patterns for license check
exclude:
- 'doc/.*' # documentation
- 'meta/.*' # meta data
- 'test/.*' # test files
- '.*dep5_template$' # plain text template file, not source code
# matching of imported name to name in pkg manager
rename:
lib:
Python:
yaml: 'PyYAML'
stdlib_list: 'stdlib-list'
# mark local imports to exclude from license check
local_imports:
Python:
- 'functions'
apply-license:
description: 'This Software provides services to check and improve the source code quality of software-projects'
copyright: 'Helmholtz Centre Potsdam - GFZ German Research Centre for Geosciences Potsdam, Germany (https://www.gfz-potsdam.de/)'
time: '2020'
maintainer:
name: 'Maximilian Dolling'
mail: 'mdolling@gfz-potsdam.de'
licenses:
data:
spdx-identifier: 'CC-BY-4.0'
copyright: 'GFZ-Potsdam'
software:
spdx-identifier: 'GPL-3.0-or-later'
copyright: 'GFZ-Potsdam'
pictures:
spdx-identifier: 'CC-BY-4.0'
copyright: 'GFZ-Potsdam'
insignificant:
spdx-identifier: 'CC0-1.0'
copyright: 1