...
 
Commits (2)
# 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'
{% for copyright_line in copyright_lines %}
{{ copyright_line }}
{% endfor %}
{% for expression in spdx_expressions %}
SPDX-License-Identifier: {{ expression }}
{% endfor %}
\ No newline at end of file
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
\ No newline at end of file
{% for copyright_line in copyright_lines %}
{{ copyright_line }}
{% endfor %}
{% for expression in spdx_expressions %}
SPDX-License-Identifier: {{ expression }}
{% endfor %}
\ No newline at end of file
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
\ No newline at end of file
{1}
{2}
{% for copyright_line in copyright_lines %}
{{ copyright_line }}
{% endfor %}
{% for expression in spdx_expressions %}
SPDX-License-Identifier: {{ expression }}
{% endfor %}
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/>.
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
\ No newline at end of file
{% for copyright_line in copyright_lines %}
{{ copyright_line }}
{% endfor %}
{% for expression in spdx_expressions %}
SPDX-License-Identifier: {{ expression }}
{% endfor %}
\ No newline at end of file
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
\ No newline at end of file
<!--
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
-->
## License
Copyright © {1} {2}
This work is licensed under multiple licenses:
- The data set is licensed under [{3}](LICENSES/{3}.txt).
- Pictures are licensed under [{4}](LICENSES/{4}.txt).
- The source code and the accompanying material is licensed under [{5}](LICENSES/{5}.txt).
- Insignificant files are licensed under [{6}](LICENSES/{6}.txt).
Please see the individual files for more accurate information.
> **Hint:** We provided the copyright and license information in accordance to the [REUSE Specification 3.0](https://reuse.software/spec/).
\ No newline at end of file
PyYAML==5.3
schema==0.7.2
\ No newline at end of file
......@@ -28,7 +28,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Version first, because it does not require any other files or settings.
# Version first, because it does not require any other files or config.
if [ "$1" = "--version" ]; then
cat /version.txt
exit 0
......@@ -53,11 +53,10 @@ if [ ! -d /repo/.sqa ]; then
echo "Visit https://gitext.gfz-potsdam.de/software/services/fair/software-quality-assurance/-/blob/master/doc/doc_service_description.md#general"
echo "for more information"
/utility/init/init.sh
exit 1
fi
# validate the settings
if ! python /utility/validate_settings.py; then
# validate the config
if ! python /utility/validate_config.py; then
exit $?
fi
......
......@@ -28,7 +28,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Version first, because it does not require any other files or settings.
# Version first, because it does not require any other files or config.
if [ "$1" = "--version" ]; then
cat /version.txt
exit 0
......
......@@ -10,8 +10,8 @@ SPDX-License-Identifier: CC0-1.0
### general
Some services require settings.
These settings will be done in a `.sqa.yaml` file in the root directory of the project.
Some services require config.
These config will be done in a `.sqa.yaml` file in the root directory of the project.
An example for a [.sqa.yaml](.sqa.yml) can be found in this project.
A minimal config is located [here](test/tetfiles/.min_sqa.yml) and an empty commented file below:
......
......@@ -43,7 +43,7 @@ How to do that, is described [here](https://docs.gitlab.com/ee/gitlab-basics/cre
### 3) Enable CI/CD
In the GitLab web-interface from the page of your repository navigate to `Settings > General > Visibility, project features, permissions`.
In the GitLab web-interface from the page of your repository navigate to `config > General > Visibility, project features, permissions`.
Enable `Pipelines` and set them to `Only Project Members`.
### 4) Add GitLab Runner
......@@ -115,7 +115,7 @@ More information on generating a key pair can be found [here](https://docs.gitla
ssh-keygen -t rsa -b 4096 -C "[PROJECT_NAME]_software-quality-assurance" -f [OUTPUTFILE] -q -N ""
```
In the GitLab web-interface from the page of your repository navigate to `Settings > CI/CD > Deploy Keys`.
In the GitLab web-interface from the page of your repository navigate to `config > CI/CD > Deploy Keys`.
Paste the content of `[OUTPUTFILE].pub` to the field `key` and give it any unique name (like *PROJECT_NAME*_deploy-key)
Check the 'Write access allowed' checkbox.
......@@ -139,7 +139,7 @@ ssh-keyscan -t rsa gitext.gfz-potsdam.de
gitext.gfz-potsdam.de ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCsiq5txhABcG9oePf47SCd+w/tfSs6NWKaMRd2BfBi9DGORQX4wwV4CYvSJbMfJvQO5SMGwhnEAXe0bWihC2V8X7lzcePrpjfP+uH2lmipcFbV9g3iQpM7Fusr96IV65v/qQ6HE4+KkHJLR1vEKj1AOaVgDww7CHhVAHCkvqcSwwtfOjBbqyfQ2Su7O6UNzs1ecQcIXnQNO8ebzimv3c8mKdo9j8i5eiWVqzRivmi/R3XIIc2T695mTLyxUplqfyvZpDL90F9VEjr/3HM9/3dASbonaTH8SoMRCxOy8Fpz0Va1MdpSor0uoemQjbu8aZzGB0+tsE5eWjuFaZib8QDF
```
Now open the GitLab web-interface and navigate to `Settings > CI/CD > Variables` from from the page of your repository.
Now open the GitLab web-interface and navigate to `config > CI/CD > Variables` from from the page of your repository.
We need to fill in two variables here.
Click on 'Add Variable'.
......
......@@ -64,7 +64,7 @@
|---|---|---|
|Apache 2.0|1|requests|
|GPL-3.0-or-later AND Apache-2.0 AND CC0-1.0 AND CC-BY-SA-4.0|1|reuse|
|MIT|3|PyYAML <br> httpretty <br> stdlib-list|
|MIT|4|PyYAML <br> httpretty <br> schema <br> stdlib-list|
|Python-2.0|10|datetime <br> importlib <br> json <br> os <br> pathlib <br> re <br> shutil <br> sys <br> time <br> unittest|
|mock|1|stdlib|
......
......@@ -28,7 +28,7 @@
"""apply-license.py
This script is a wrapper for the reuse software by fsfe.
It reads settings from .sqa.yml.
It reads config from .sqa.yml.
Afterwards it inits reuse, adjusts header templates and add them to all files.
"""
......@@ -40,7 +40,7 @@ from datetime import datetime
import yaml
# setting vars
# config vars
repo_dir = sys.argv[1]
working_dir = repo_dir + sys.argv[2]
test = False
......@@ -48,14 +48,14 @@ test = False
if "--test" in sys.argv:
test = True
with open('/repo/.sqa.yml') as settings_yaml:
tmp = yaml.load(settings_yaml, Loader=yaml.FullLoader)
with open('/repo/.sqa.yml') as config_yaml:
tmp = yaml.load(config_yaml, Loader=yaml.FullLoader)
if 'apply-license' not in tmp:
print("no settings for this service in '.sqa.yml - exiting service'")
print("no config for this service in '.sqa.yml - exiting service'")
sys.exit(1)
else:
settings = tmp['apply-license']
settings_yaml.close()
config = tmp['apply-license']
config_yaml.close()
with open('/services/apply-license/data/apply-license_patterns.yml') as apply_license_patterns_yaml:
apply_license_patterns = yaml.load(apply_license_patterns_yaml, Loader=yaml.FullLoader)
......@@ -73,8 +73,8 @@ with open('/version.txt', 'r') as file:
report_version = file.read().replace('\n', '')
# download license texts
for item in settings['licenses']:
os.system('reuse download {} &> /dev/null'.format(settings['licenses'][item]['spdx-identifier']))
for item in config['licenses']:
os.system('reuse download {} &> /dev/null'.format(config['licenses'][item]['spdx-identifier']))
# create main license file
......@@ -86,11 +86,11 @@ with open('/services/apply-license/data/templates/licensefile_template.md', 'r')
# format template
license_year = time.strftime("%Y")
licensetext = licensetext.replace('{1}', license_year)
licensetext = licensetext.replace('{2}', settings['copyright'])
licensetext = licensetext.replace('{3}', settings['licenses']['data']['spdx-identifier'])
licensetext = licensetext.replace('{4}', settings['licenses']['pictures']['spdx-identifier'])
licensetext = licensetext.replace('{5}', settings['licenses']['software']['spdx-identifier'])
licensetext = licensetext.replace('{6}', settings['licenses']['insignificant']['spdx-identifier'])
licensetext = licensetext.replace('{2}', config['copyright'])
licensetext = licensetext.replace('{3}', config['licenses']['data']['spdx-identifier'])
licensetext = licensetext.replace('{4}', config['licenses']['pictures']['spdx-identifier'])
licensetext = licensetext.replace('{5}', config['licenses']['software']['spdx-identifier'])
licensetext = licensetext.replace('{6}', config['licenses']['insignificant']['spdx-identifier'])
# write licensefile
with open(repo_dir + '/LICENSE.md', 'w') as licensefile:
......@@ -106,8 +106,8 @@ with open('/services/apply-license/data/templates/dep5_template', 'r') as dep5_t
# format template
dep5text = dep5text.replace('{1}', project_name)
dep5text = dep5text.replace('{2}', settings['maintainer']['name'])
dep5text = dep5text.replace('{3}', settings['maintainer']['mail'])
dep5text = dep5text.replace('{2}', config['maintainer']['name'])
dep5text = dep5text.replace('{3}', config['maintainer']['mail'])
dep5text = dep5text.replace('{4}', project_location)
# write licensefile
......@@ -134,7 +134,7 @@ for root, dirs, files in os.walk('/services/apply-license/data/templates/header'
template.close()
# modify template
template_text = template_text.replace('{1}', project_name)
template_text = template_text.replace('{2}', settings['description'])
template_text = template_text.replace('{2}', config['description'])
# write template
with open(repo_dir + '/.reuse/templates/{}'.format(file), 'w') as template:
template.write(template_text)
......@@ -162,8 +162,8 @@ for root, dirs, files in os.walk(repo_dir, topdown=False):
type_found = False
command = 'reuse addheader --year="{1}" --copyright="{2}" --license="{3}" --template={4}{5} {6}&>/dev/null'
command = command.replace('{1}', settings['time'])
command = command.replace('{2}', settings['copyright'])
command = command.replace('{1}', config['time'])
command = command.replace('{2}', config['copyright'])
command = command.replace('{6}', filepath)
for file_type_pattern in apply_license_patterns['comment in file']:
......@@ -181,11 +181,11 @@ for root, dirs, files in os.walk(repo_dir, topdown=False):
p = re.compile(file_type_pattern, re.IGNORECASE)
if p.match(file):
command = command.replace('{3}',
settings['licenses'][file_type]['spdx-identifier'])
config['licenses'][file_type]['spdx-identifier'])
if os.path.isfile(repo_dir + '/.reuse/templates/{}.jinja2'.format(
settings['licenses'][file_type]['spdx-identifier'])):
config['licenses'][file_type]['spdx-identifier'])):
command = command.replace('{4}',
settings['licenses'][file_type]['spdx-identifier'])
config['licenses'][file_type]['spdx-identifier'])
else:
command = command.replace('{4}', 'default')
os.system(command)
......@@ -194,10 +194,10 @@ for root, dirs, files in os.walk(repo_dir, topdown=False):
if type_found:
break
else:
command = command.replace('{3}', settings['licenses']['insignificant']['spdx-identifier'])
command = command.replace('{3}', config['licenses']['insignificant']['spdx-identifier'])
if os.path.isfile(repo_dir + '/.reuse/templates/{}.jinja2'.format(
settings['licenses']['insignificant']['spdx-identifier'])):
command = command.replace('{4}', settings['licenses']['insignificant']['spdx-identifier'])
config['licenses']['insignificant']['spdx-identifier'])):
command = command.replace('{4}', config['licenses']['insignificant']['spdx-identifier'])
else:
command = command.replace('{4}', 'default')
os.system(command)
......@@ -38,7 +38,7 @@ from pathlib import Path
import yaml
# setting vars
# config vars
repo_dir = sys.argv[1]
working_dir = repo_dir + sys.argv[2]
test = False
......
......@@ -42,7 +42,7 @@ import yaml
from functions import language_parser
from functions import license_requester
# setting vars
# config vars
repo_dir = sys.argv[1]
working_dir = repo_dir + sys.argv[2]
test = False
......@@ -50,14 +50,14 @@ test = False
if "--test" in sys.argv:
test = True
with open('/repo/.sqa.yml') as settings_yaml:
tmp = yaml.load(settings_yaml, Loader=yaml.FullLoader)
with open('/repo/.sqa.yml') as config_yaml:
tmp = yaml.load(config_yaml, Loader=yaml.FullLoader)
if 'list-used-licenses' not in tmp:
print("no settings for this service in '.sqa.yml - exiting service'")
print("no config for this service in '.sqa.yml - exiting service'")
sys.exit(1)
else:
settings = tmp['list-used-licenses']
settings_yaml.close()
config = tmp['list-used-licenses']
config_yaml.close()
# collect report data
project_name = os.popen('basename $(git remote get-url origin)').read()[:-5]
......@@ -117,7 +117,7 @@ for root, dirs, files in os.walk(repo_dir, topdown=False):
# priorities: (user keep >) user ignore > software keep > software ignore
# this section can be optimized if you get the regex in ignore_file_pattern.yml correct
ignore_file = False
for user_ignore_pattern in settings['exclude']:
for user_ignore_pattern in config['exclude']:
if not test and user_ignore_pattern is not None:
p = re.compile(user_ignore_pattern, re.IGNORECASE)
if p.match(filepath):
......@@ -180,7 +180,7 @@ for language in used_languages_dict:
# rearrange libraries
# * remove duplicate and empty entries
# * remove local packages
# * rename libraries according to settings
# * rename libraries according to config
# (might be useful if pkg manager name differs from import name)
# * restructure entries
# * split multiple version constrains
......@@ -201,12 +201,12 @@ for language in used_libs_dict:
lib_key = list(lib.keys())[0]
lib_val = list(lib.values())[0].split(',')
# rename lib
if settings['rename']['lib'] is not None and language in settings['rename']['lib']:
if lib_key in settings['rename']['lib'][language]:
lib_key = settings['rename']['lib'][language][lib_key]
if config['rename']['lib'] is not None and language in config['rename']['lib']:
if lib_key in config['rename']['lib'][language]:
lib_key = config['rename']['lib'][language][lib_key]
# ignore local imports
if settings['local_imports'] is not None and language in settings['local_imports']:
if lib_key in settings['local_imports'][language]:
if config['local_imports'] is not None and language in config['local_imports']:
if lib_key in config['local_imports'][language]:
continue
# check duplicates
if lib_key in tmp[language]:
......
......@@ -38,7 +38,7 @@ from pathlib import Path
import yaml
# setting vars
# config vars
repo_dir = sys.argv[1]
working_dir = repo_dir + sys.argv[2]
test = False
......
......@@ -32,7 +32,7 @@ REPO_DIR="/repo"
cd "$REPO_DIR" || exit 1
# test if folder with settings already exists
# test if folder with config already exists
if [ -d /repo/.sqa ]; then
echo
echo "sqa was already initialized."
......@@ -40,5 +40,5 @@ if [ -d /repo/.sqa ]; then
exit 1
fi
cp -r /services/init/.sqa "$REPO_DIR"
cp -r /utility/init/.sqa "$REPO_DIR"
......@@ -26,4 +26,34 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
print('settings valid...')
\ No newline at end of file
# from schema import Schema, And, Use, Optional
# import yaml
#
# schema = Schema({'list-used-licenses': {'exclude': [str],
# 'rename': {'lib': {str: {str: str}}},
# 'local_imports': {str: [str]}},
# 'apply-license': {'description': str,
# 'copyright': str,
# 'time': str,
# 'maintainer': {'name': str,
# 'mail': str},
# 'licenses': {'data': {'spdx-identifier': str,
# 'copyright': str},
# 'software': {'spdx-identifier': str,
# 'copyright': str},
# 'pictures': {'spdx-identifier': str,
# 'copyright': str},
# 'insignificant': {'spdx-identifier': str,
# 'copyright': str}}}})
#
# with open('/repo/.sqa/config.yml') as config_yaml:
# config = yaml.load(config_yaml, Loader=yaml.FullLoader)
# config_yaml.close()
#
# validated = schema.validate(data)
#
# assert validated == [{'name': 'Sue', 'age': 28, 'gender': 'squid'},
# {'name': 'Sam', 'age': 42},
# {'name': 'Sacha', 'age': 20, 'gender': 'kid'}]
print('config valid...')