diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9167f154f92e62ea9542ac85aa672d1007ecceb1..70ef0865d0af240e20aadc80871edcd607e1367b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -97,6 +97,18 @@ fast-build: - ctest -V -S CI/main_ci.cmake -DIMAGE_NAME:string=ubuntu-18.04-fast - ccache -s +contibutors-check: + extends: .common + only: [merge_requests, develop] + stage: precheck + image: $BUILD_IMAGE_REGISTRY/otb-alpine:3.7 + variables: + GIT_DEPTH: "" + allow_failure: true + script: + - ./CI/contributors_check.sh + after_script: [] + #------------------------- prepare & build jobs -------------------------------- debian-build: extends: .common-build diff --git a/CI/contributors_check.sh b/CI/contributors_check.sh new file mode 100755 index 0000000000000000000000000000000000000000..d9a6328d4609b8485825ef5b0799eacb4416388b --- /dev/null +++ b/CI/contributors_check.sh @@ -0,0 +1,54 @@ +#!/bin/bash +# +# Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES) +# +# This file is part of Orfeo Toolbox +# +# https://www.orfeo-toolbox.org/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script aims to identify the unreferenced authors to invite the team to +# check if they have already signed the contributor license agreement (CLA). +# When this is done, the author must be added to the reference list. + + +GITLAB_PROJECT_URL=https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb-devutils +GIT_CONTRIBUTORS=/tmp/git-contributors.txt +KNOWN_CONTRIBUTORS=/tmp/known-contributors.txt +UNKNOWN_CONTRIBUTORS=/tmp/unknown-contributors.txt + +# According to the Git documentation, the reference ("HEAD" in the present +# case) must be passed on the command line when the standard input of "git +# shortlog" command is not a terminal. Without the reference in such +# situation, the output of "git shortlog" is empty. +git shortlog -es HEAD | cut -f 2- \ + | sort -u > ${GIT_CONTRIBUTORS} + +curl -s ${GITLAB_PROJECT_URL}/raw/master/CI/contributors/known-contributors.txt \ + | sort -u > ${KNOWN_CONTRIBUTORS} + +diff ${KNOWN_CONTRIBUTORS} ${GIT_CONTRIBUTORS} > ${UNKNOWN_CONTRIBUTORS} +if [ "$?" -ne "0" ] ; then + echo "" + echo "WARNING: ***************************************************************" + echo "WARNING: Unknown contributors found:" + sed -n -e 's,^> ,WARNING: - ,p' ${UNKNOWN_CONTRIBUTORS} + echo "WARNING: Check if they have signed the contributor license agreements." + echo "WARNING: ***************************************************************" + echo "" + exit 1 +else + echo "All contributors are already known." + exit 0 +fi