diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dc1996f2738bda5dfb50572ba1e8831093c0102e..5c481977348a3e92b8174bc8cae4b939b994c496 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,3 +1,7 @@ +stages: + - license + - build_and_test + ############ YAML ANCHORS ############ .preliminaries_template: &preliminaries_definition ## Install ssh-agent if not already installed, it is required by Docker. @@ -20,7 +24,45 @@ # update apt - apt-get update + # create 'ci_deps' folder (if not exists) + - mkdir -pv ci_deps + +.license_header_template: &license_header_definition + - cd $CI_PROJECT_DIR + + # configure git + - export CI_NEW_BRANCH=ci_processing$RANDOM + - echo creating new temporary branch... $CI_NEW_BRANCH + - git config --global user.email "${CI_EMAIL}" + - git config --global user.name "${CI_USERNAME}" + - git checkout -b $CI_NEW_BRANCH # temporary branch + + # license headers + - export CURRENT_YEAR=$( date +'%Y' ) + - echo "current year:" ${CURRENT_YEAR} + - if [ -f license_header_${CURRENT_YEAR}.txt ]; then + # add license headers to new files + - echo "File license_header_${CURRENT_YEAR}.txt already exists. License headers are assumed to be updated. Adding headers to new files..." + - ./ci_deps/wolf/wolf_scripts/license_manager.sh --add --path=. --license-header=license_header_${CURRENT_YEAR}.txt --exclude=ci_deps + - else + # update license headers of all files + - export PREV_YEAR=$(( CURRENT_YEAR-1 )) + - echo "Creating new file license_header_${CURRENT_YEAR}.txt..." + - git mv license_header_${PREV_YEAR}.txt license_header_${CURRENT_YEAR}.txt + - sed -i "s/${PREV_YEAR}/${PREV_YEAR},${CURRENT_YEAR}/g" license_header_${CURRENT_YEAR}.txt + - ./ci_deps/wolf/wolf_scripts/license_manager.sh --update --path=. --license-header=license_header_${CURRENT_YEAR}.txt --exclude=ci_deps + - fi + + # push changes (if any) + - if git commit -a -m "[skip ci] license headers added or modified" ; then + - git remote set-url --push origin "ssh://git@gitlab.iri.upc.edu:2202/${CI_PROJECT_PATH}.git" + - git push origin $CI_NEW_BRANCH:${CI_COMMIT_REF_NAME} + - else + - echo "No changes, nothing to commit!" + - fi + .install_wolf_template: &install_wolf_definition + - cd ${CI_PROJECT_DIR}/ci_deps - if [ -d wolf ]; then - echo "directory wolf exists" - cd wolf @@ -34,12 +76,12 @@ - mkdir -pv build - cd build - cmake -DCMAKE_BUILD_TYPE=release -DBUILD_EXAMPLES=ON -DBUILD_TESTS=ON .. - - make -j$WOLF_N_PROC - - ctest -j$WOLF_N_PROC + - make -j$(nproc) + - ctest -j$(nproc) - make install - - cd ../.. .install_wolfimu_template: &install_wolfimu_definition + - cd ${CI_PROJECT_DIR}/ci_deps - if [ -d imu ]; then - echo "directory imu exists" - cd imu @@ -51,29 +93,46 @@ - mkdir -pv build - cd build - cmake -DCMAKE_BUILD_TYPE=release -DBUILD_EXAMPLES=ON -DBUILD_TESTS=ON .. - - make -j$WOLF_N_PROC - - ctest -j$WOLF_N_PROC + - make -j$(nproc) + - ctest -j$(nproc) - make install - - cd ../.. .build_and_test_template: &build_and_test_definition + - cd $CI_PROJECT_DIR - mkdir -pv build - cd build - cmake -DCMAKE_BUILD_TYPE=release -DBUILD_EXAMPLES=ON -DBUILD_TESTS=ON .. - - make -j$WOLF_N_PROC - - ctest -j$WOLF_N_PROC + - make -j$(nproc) + - ctest -j$(nproc) - make install +############ LICENSE HEADERS ############ +license_headers: + stage: license + image: labrobotica/wolf_deps:16.04 + cache: + - key: wolf-xenial + paths: + - ci_deps/wolf/ + except: + - master + before_script: + - *preliminaries_definition + - *install_wolf_definition + script: + - *license_header_definition + ############ UBUNTU 16.04 TESTS ############ build_and_test:xenial: image: labrobotica/wolf_deps:16.04 + stage: build_and_test cache: - key: wolf-xenial paths: - - wolf/ + - ci_deps/wolf/ - key: imu-xenial paths: - - imu/ + - ci_deps/imu/ except: - master before_script: @@ -87,13 +146,14 @@ build_and_test:xenial: ############ UBUNTU 18.04 TESTS ############ build_and_test:bionic: image: labrobotica/wolf_deps:18.04 + stage: build_and_test cache: - key: wolf-bionic paths: - - wolf/ + - ci_deps/wolf/ - key: imu-bionic paths: - - imu/ + - ci_deps/imu/ except: - master before_script: diff --git a/license_header_2021.txt b/license_header_2021.txt new file mode 100644 index 0000000000000000000000000000000000000000..c75a6f243b37109b77d60e16b7caebfc19215aea --- /dev/null +++ b/license_header_2021.txt @@ -0,0 +1,17 @@ +// Copyright (C) 2020,2021 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// 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 Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>.