Skip to content
Snippets Groups Projects
.gitlab-ci.yml 11.7 KiB
Newer Older
  • Learn to ignore specific revisions
  • stages:
     - build
     - test
    
    # #################################################################################################
    # runs
    .config:run:compatibility_only: &config_run_only_compatibility
      only:
        variables:
         - $SCHEDULED_COMPATIBILITY
    
    .config:run:nightly_only: &config_run_only_nightly
      only:
        variables:
         - $SCHEDULED_NIGHTLY
    
    .config:run:nightly_except: &config_run_except_nightly
      except:
        variables:
         - $SCHEDULED_NIGHTLY
    
    .config:run:release_tag: &config_run_only_release
      only:
        - /^v.*$/
      except:
        - branches
    
    # #################################################################################################
    # distro builds and tests config
    .config: &config_buildbase
      <<: *config_run_except_nightly
    
    .config:arch: &config_arch
      image: archlinux/base
      <<: *config_buildbase
      <<: *config_run_only_compatibility
    
    .config:alpine: &config_alpine
      image: alpine:3.9
      <<: *config_buildbase
    
    .config:debian-testing: &config_debiantesting
      image: amd64/debian:testing-slim
      <<: *config_buildbase
      <<: *config_run_only_compatibility
    
    .config:debian-testing:clang: &config_debiantesting_clang
      image: amd64/debian:testing-slim
      <<: *config_buildbase
    
    .config:debian-stable: &config_debianstable
      image: amd64/debian:stable-slim
      <<: *config_run_only_compatibility
    
    .config:opensuse-leap: &config_opensuseleap
      image: opensuse/leap:latest
      <<: *config_buildbase
      <<: *config_run_only_compatibility
    
    .config:ubuntu-lts: &config_ubuntults
      image: ubuntu:latest
      <<: *config_buildbase
      <<: *config_run_only_compatibility
    
    .config:ubuntu-rolling: &config_ubunturolling
      image: ubuntu:rolling
      <<: *config_buildbase
      <<: *config_run_only_compatibility
    
    # #################################################################################################
    # stage: build
    
    .build: &template_build
    
      stage: build
    
        - mkdir -p release && cd release
        - ../CMake/generate.py -wm
    
        - cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..
    
        - make -j $(grep -c processor /proc/cpuinfo)
    
      artifacts:
        paths:
    
    build:arch:
      <<: *config_arch
      <<: *template_build
      before_script:
        - pacman -Syu --noconfirm base-devel cmake make python libxml2 tclap readline qt5-base graphviz jsoncpp
        - pacman -Syu --noconfirm binutils && strip --remove-section=.note.ABI-tag /usr/lib/libQt5Core.so.5 # qt hack
    
    build:alpine:
      <<: *config_alpine
      <<: *template_build
    
      before_script:
    
        - apk add --no-cache bash build-base cmake python3 libexecinfo-dev libxml2-dev tclap-dev readline-dev qt5-qtbase-dev graphviz-dev jsoncpp-dev
    
    #build:debian:stable:
    #  <<: *config_debianstable
    #  <<: *template_build
    #  before_script:
    #    - apt-get update && apt-get install -y build-essential cmake make python3 libxml2-dev libtclap-dev libreadline-dev qtbase5-dev graphviz-dev libjsoncpp-dev
    
    
    build:debian:testing:
    
      <<: *config_debiantesting
      <<: *template_build
    
      before_script:
    
        - apt-get update && apt-get install -y build-essential cmake make python3 libxml2-dev libtclap-dev libreadline-dev qtbase5-dev graphviz-dev libjsoncpp-dev
    
    build:debian:testing:clang:
    
      <<: *config_debiantesting_clang
      <<: *template_build
    
      before_script:
    
        - apt-get update && apt-get install -y build-essential cmake make python3 libxml2-dev libtclap-dev libreadline-dev qtbase5-dev graphviz-dev libjsoncpp-dev
        - apt-get install -y clang-7
    
    build:opensuse-leap:
      <<: *config_opensuseleap
      <<: *template_build
    
        - zypper -n install python3 cmake gcc-c++ bash make libxml2-devel tclap readline-devel libQt5Widgets-devel libQt5Xml-devel graphviz-devel jsoncpp-devel
    
      <<: *config_ubuntults
      <<: *template_build
    
        - apt-get update && apt-get install -y build-essential cmake make python3 libxml2-dev libtclap-dev libreadline-dev qtbase5-dev graphviz-dev libjsoncpp-dev
    
      <<: *config_ubunturolling
      <<: *template_build
    
        - apt-get update && apt-get install -y build-essential cmake make python3 libxml2-dev libtclap-dev libreadline-dev qtbase5-dev graphviz-dev libjsoncpp-dev
    
    # -----------------------------------------------
    
      <<: *config_run_except_nightly
      image: alpine:3.9
    
      stage: build
      before_script:
        - apk add --no-cache doxygen graphviz
    
      script:
    
        - doxygen
    
      allow_failure: true
      artifacts:
        name: docs
        paths:
    
        expire_in: 1 day
    
    # #################################################################################################
    # stage: test
    
    # -----------------------------------------------
    # static tests
    
    .static: &static_template
      <<: *config_run_except_nightly
    
      stage: test
      image: amd64/debian:testing-slim
      dependencies:
        - build:debian:testing:clang
      allow_failure: true
    
    static:cppcheck:
    
      <<: *static_template
      before_script:
        - apt-get update && apt-get install -y cppcheck
    
      script:
        - cppcheck -q --enable=all --project=release/compile_commands.json --suppress="*:*/contrib/*" -j$(grep -c processor /proc/cpuinfo) --error-exitcode=1
    
    static:clang-tidy:
    
      <<: *static_template
      before_script:
        - apt-get update && apt-get install -y clang-tidy
    
        - apt-get install -y libxml2-dev libtclap-dev libreadline-dev qtbase5-dev graphviz-dev libjsoncpp-dev
    
        - find . -wholename "*/src/*.cpp" -print0 | xargs -n1 -P$(grep -c processor /proc/cpuinfo) -0 clang-tidy -warnings-as-errors='*' -p release/
    
    
    # -----------------------------------------------
    # smoke tests
    
    Tomáš Pecka's avatar
    Tomáš Pecka committed
        - make test ARGS="-j$(grep -c processor /proc/cpuinfo) --output-on-failure"
    
    test:arch:
      <<: *config_arch
      <<: *template_test
      dependencies:
       - build:arch
    
    Tomáš Pecka's avatar
    Tomáš Pecka committed
      before_script:
    
        - pacman -Syu --noconfirm base-devel bash bc coreutils cmake make python libxml2 tclap readline qt5-base graphviz jsoncpp
        - pacman -Syu --noconfirm binutils && strip --remove-section=.note.ABI-tag /usr/lib/libQt5Core.so.5 # qt hack
    
    test:alpine:
      <<: *config_alpine
      <<: *template_test
      dependencies:
        - build:alpine
    
      before_script:
    
        - apk add --no-cache bash bc coreutils python3 cmake make libexecinfo libxml2 tclap readline qt5-qtbase qt5-qtbase-x11 graphviz jsoncpp
    
    
    #test:debian:stable:
    #  <<: *config_debianstable_test
    #  <<: *template_test
    
    #  dependencies:
    
    #   - build:debian:stable
    #  before_script:
    #   - apt-get update && apt-get install -y build-essential bash cmake make libxml2 libreadline7 libqt5widgets5 libqt5xml5 graphviz libjsoncpp1
    
    
    test:debian:testing:
    
      <<: *config_debiantesting
      <<: *template_test
    
      dependencies:
    
        - build:debian:testing
    
      before_script:
        - apt-get update && apt-get install -y build-essential bash cmake make libxml2 libreadline7 libqt5widgets5 libqt5xml5 graphviz libjsoncpp1
    
    test:debian:testing:clang:
    
      <<: *config_debiantesting_clang
      <<: *template_test
    
      dependencies:
        - build:debian:testing:clang
    
      before_script:
    
        - apt-get update && apt-get install -y build-essential bash cmake make libxml2 libreadline7 libqt5widgets5 libqt5xml5 graphviz libjsoncpp1
    
    test:opensuse-leap:
      <<: *config_opensuseleap
      <<: *template_test
    
      dependencies:
    
        - zypper -n install bash cmake make libxml2 readline libQt5Widgets5 libQt5Xml5 graphviz libjsoncpp19
    
      <<: *config_ubuntults
      <<: *template_test
    
      before_script:
        - apt-get update && apt-get install -y build-essential bash cmake make libxml2 libreadline7 libqt5widgets5 libqt5xml5 graphviz libjsoncpp1
    
      <<: *config_ubunturolling
      <<: *template_test
    
        - apt-get update && apt-get install -y build-essential bash cmake make libxml2 libreadline8 libqt5widgets5 libqt5xml5 graphviz libjsoncpp1
    
    # #################################################################################################
    # stage: deploy
    
    # -----------------------------------------------
    # docker images
    
      image: alpine:3.9
    
      cache: {}  # disable
      variables:
        DOCKER_DRIVER: overlay2
        DOCKER_HOST: docker
    
        # ---------
        IMAGE_CLI: $CI_REGISTRY_IMAGE/cli
        IMAGE_GUI: $CI_REGISTRY_IMAGE/gui
        IMAGE_ALL: $CI_REGISTRY_IMAGE
        TAG_NIGHTLY: nightly
        TAG_RELEASE: $CI_COMMIT_REF_NAME
        TAG_LATEST:  latest
    
      services:
        - docker:dind
      before_script:
    
        - apk add --no-cache docker curl
    
        - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
    
        - docker info
    
    Tomáš Pecka's avatar
    Tomáš Pecka committed
        - curl -X POST -F token="$PY_ALIB_TOKEN" -F ref=master https://gitlab.fit.cvut.cz/api/v4/projects/11497/trigger/pipeline
    
    deploy:docker:nightly: &docker_nightly_template
    
      <<: *config_run_only_nightly
    
      environment:
        name: docker-nightly
    
        - docker build --target=deploy-cli -f extra/docker/Dockerfile.master -t "$IMAGE_CLI:$TAG_NIGHTLY" .
        - docker build --target=deploy-all -f extra/docker/Dockerfile.master -t "$IMAGE_ALL:$TAG_NIGHTLY" .
    
        - docker tag "$IMAGE_ALL:$TAG_NIGHTLY" "$IMAGE_GUI:$TAG_NIGHTLY" # gui-version is now only a symlink to all-version
        - docker run "$IMAGE_CLI:$TAG_NIGHTLY" /usr/bin/aql2 --help
        - docker run "$IMAGE_GUI:$TAG_NIGHTLY" /usr/bin/aql2 --help
    
        - docker run "$IMAGE_ALL:$TAG_NIGHTLY" /usr/bin/aql2 --help
    
        - docker push "$IMAGE_CLI:$TAG_NIGHTLY"
        - docker push "$IMAGE_GUI:$TAG_NIGHTLY"
    
        - docker push "$IMAGE_ALL:$TAG_NIGHTLY"
    
      <<: *config_run_only_release
    
      environment:
        name: docker-production
    
        - docker build -f extra/docker/Dockerfile.master     -t "$IMAGE_ALL:$TAG_RELEASE" -t "$IMAGE_ALL:$TAG_LATEST" .
        - docker build -f extra/docker/Dockerfile.master-cli -t "$IMAGE_CLI:$TAG_RELEASE" -t "$IMAGE_CLI:$TAG_LATEST" .
        - docker tag "$IMAGE_ALL:$TAG_RELEASE" "$IMAGE_GUI:$TAG_RELEASE" # gui-version is now only a symlink to all-version
        - docker tag "$IMAGE_ALL:$TAG_LATEST"  "$IMAGE_GUI:$TAG_LATEST"  # gui-version is now only a symlink to all-version
        - docker run "$IMAGE_ALL:$TAG_RELEASE" /usr/bin/aql2 --help
        - docker run "$IMAGE_CLI:$TAG_RELEASE" /usr/bin/aql2 --help
        - docker run "$IMAGE_GUI:$TAG_RELEASE" /usr/bin/aql2 --help
        - docker push "$IMAGE_ALL:$TAG_LATEST"
        - docker push "$IMAGE_CLI:$TAG_LATEST"
        - docker push "$IMAGE_GUI:$TAG_LATEST"
        - docker push "$IMAGE_ALL:$TAG_RELEASE"
        - docker push "$IMAGE_CLI:$TAG_RELEASE"
        - docker push "$IMAGE_GUI:$TAG_RELEASE"
    
    # -----------------------------------------------
    # obs push
    
    
      image: gitlab.fit.cvut.cz:5000/algorithms-library-toolkit/ci-docker-images/osc:latest
      before_script:
        - echo -e "[general]\napiurl = https://api.opensuse.org\n\n[https://api.opensuse.org]\nuser = ${OBS_USER}\npass = ${OBS_PASS}\n" > ~/.oscrc
        - mkdir -p /obs_repo /distrofiles
      script:
        - extra/obs/make-distrofiles.sh ${OBS_MODE} /distrofiles/
        - cd /obs_repo && osc co ${OBS_PROJECT} ${OBS_PACKAGE}
        - cd ${OBS_PROJECT}/${OBS_PACKAGE}
        - mv /distrofiles/* .
        - osc addremove
        - osc ci -n -m "CI autocommit (${CI_COMMIT_SHA}, tag=${CI_COMMIT_TAG})"
      dependencies: []
    
    deploy:obs:nightly:
      <<: *obs_template
    
      <<: *config_run_only_nightly
    
      environment:
        name: obs-nightly
        url: https://build.opensuse.org/package/show/home:algorithms-library/algorithms-library-all-nightly
      variables:
        OBS_PROJECT: home:algorithms-library
        OBS_PACKAGE: algorithms-library-all-nightly
        OBS_MODE: nightly
    
    deploy:obs:release:
      <<: *obs_template
    
      <<: *config_run_only_release
    
      environment:
        name: obs-production
        url: https://build.opensuse.org/package/show/home:algorithms-library/algorithms-library
      variables:
        OBS_PROJECT: home:algorithms-library
        OBS_PACKAGE: algorithms-library
        OBS_MODE: release