Skip to content
Snippets Groups Projects
.gitlab-ci.yml 11.6 KiB
Newer Older
  • Learn to ignore specific revisions
  • # NOTE #1: Our GitLab CI runs jobs inside Alpine Linux container by default.
    #
    # NOTE #2: Keep in mind that each job (e.g. test-gcc) is executed in a separate
    # isolated environment (it may be even on different machine). There are no
    # files implicitly passed between jobs or stages, only artifacts and maybe
    # cache (depends on configuration).
    
    
    image: alpine:3.9
    
    stages:
     - build
     - test
    
    
    #==========  Stage build  ==========
    
    
    .build: &build
    
      stage: build
    
        - CMake/generate.py -wm
    
        - mkdir release
        - cd release
    
        - cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..
    
        - make -j $(grep -c processor /proc/cpuinfo)
    
      artifacts:
        paths:
    
    
    .build:push: &build-push
      <<: *build
    
    .build:compatibility: &build-compatibility
      <<: *build
      only:
        variables:
          - $SCHEDULED_COMPATIBILITY
    
    build:alpine:gcc:
      <<: *build-push
    
      image: alpine:3.9
    
      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:alpine:clang:
    #   <<: *build-compatibility
    #   image: alpine:3.9
    #   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 clang
    #   variables:
    #     CXX: clang++
    
    # build:debian:stable:
    #   <<: *build-compatibility
    #   image: amd64/debian:stable-slim
    #   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:
      <<: *build-compatibility
      image: amd64/debian:testing-slim
      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:
      <<: *build-push
      image: amd64/debian:testing-slim
      before_script:
        - apt-get update
        - apt-get install -y build-essential clang-7 cmake make python3 libxml2-dev libtclap-dev libreadline-dev qtbase5-dev graphviz-dev libjsoncpp-dev
      variables:
        CXX: clang++-7
    
    
    build:arch:
      <<: *build-compatibility
      image: archlinux/base:latest
      before_script:
    
        - pacman -Syu --noconfirm base-devel cmake make python libxml2 tclap readline qt5-base graphviz jsoncpp
    
    Tomáš Pecka's avatar
    Tomáš Pecka committed
        - pacman -Syu --noconfirm binutils
        - strip --remove-section=.note.ABI-tag /usr/lib/libQt5Core.so.5
    
    build:opensuse:
      <<: *build-compatibility
      image: opensuse/leap:latest
      before_script:
    
        - zypper -n install python3 cmake gcc-c++ curl bash make libxml2-devel tclap readline-devel libQt5Widgets-devel libQt5Xml-devel graphviz-devel jsoncpp-devel
    
        # gcc 7.3.0 fails with StringTest.h (in variant, it thinks something is uninitialized)
        - zypper -n install clang5
        - export CXX=clang++-5.0
    
    build:ubuntu:lts:
      <<: *build-compatibility
      image: ubuntu:latest
      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
    
        # gcc 7.3.0 fails with StringTest.h (in variant, it thinks something is uninitialized)
        - apt-get install -y clang-5.0
        - export CXX=clang++-5.0
        - export CXXFLAGS=-stdlib=libstdc++
    
    build:ubuntu:rolling:
      <<: *build-compatibility
      image: ubuntu:rolling
      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:doc:
      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: &static
      stage: test
      image: amd64/debian:testing-slim
      before_script:
        - apt-get update
      dependencies:
        - build:debian:testing:clang
      except:
        variables:
          - $SCHEDULED_NIGHTLY
      allow_failure: true
    
    static:cppcheck:
      <<: *static
      script:
        - apt-get install -y cppcheck
        - cppcheck -q --enable=all --project=release/compile_commands.json --suppress="*:*/contrib/*" -j$(grep -c processor /proc/cpuinfo) --error-exitcode=1
    
    static:clang-tidy:
      <<: *static
      script:
        - 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/
    
    # ---
    
    
    Tomáš Pecka's avatar
    Tomáš Pecka committed
        - mkdir reports
        - make test ARGS="-j$(grep -c processor /proc/cpuinfo) --output-on-failure"
    
    .test:push: &test-push
      <<: *test
    
    Tomáš Pecka's avatar
    Tomáš Pecka committed
      image: alpine:edge
      before_script:
    
        - apk add --no-cache bash bc coreutils python3 cmake make libexecinfo libxml2 tclap readline qt5-qtbase qt5-qtbase-x11 graphviz jsoncpp
    
    
    .test:compatibility: &test-compatibility
      <<: *test
      only:
        variables:
          - $SCHEDULED_COMPATIBILITY
    
    test:alpine:gcc:
      <<: *test-push
    
      image: alpine:3.9
    
      before_script:
    
        - apk add --no-cache bash bc coreutils python3 cmake make libexecinfo libxml2 tclap readline qt5-qtbase qt5-qtbase-x11 graphviz jsoncpp
    
      dependencies:
        - build:alpine:gcc
    
    
    # test:alpine:clang:
    #   <<: *test-compatibility
    #   image: alpine:3.9
    #   before_script:
    #     - apk add --no-cache bash bc coreutils python3 cmake make libexecinfo libxml2 tclap readline qt5-qtbase qt5-qtbase-x11 graphviz jsoncpp
    #   dependencies:
    #     - build:alpine:clang
    
    # test:debian:stable:
    #  <<: *test-compatibility
    #  image: amd64/debian:stable-slim
    #  before_script:
    #    - apt-get update
    
    #    - apt-get install -y build-essential bash bc coreutils cmake make python3 libxml2 libreadline7 libqt5widgets5 libqt5xml5 graphviz libjsoncpp1
    
    #  dependencies:
    #    - build:debian:stable
    
    
    test:debian:testing:
      <<: *test-compatibility
      image: amd64/debian:testing-slim
      before_script:
        - apt-get update
    
        - apt-get install -y build-essential bash bc coreutils cmake make python3 libxml2 libreadline7 libqt5widgets5 libqt5xml5 graphviz libjsoncpp1
    
      dependencies:
    
        - build:debian:testing
    
    test:debian:testing:clang:
      <<: *test-push
      image: amd64/debian:testing-slim
      before_script:
        - apt-get update
        - apt-get install -y build-essential bash bc coreutils cmake make python3 libxml2 libreadline7 libqt5widgets5 libqt5xml5 graphviz libjsoncpp1
      dependencies:
        - build:debian:testing:clang
    
    
    test:arch:
      <<: *test-compatibility
      image: archlinux/base:latest
      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
    
    
      dependencies:
    
    test:opensuse:
      <<: *test-compatibility
      image: opensuse/leap:latest
      before_script:
    
        - zypper -n install bash bc coreutils python3 cmake make libxml2 readline libQt5Widgets5 libQt5Xml5 graphviz libjsoncpp19
    
      dependencies:
        - build:opensuse
    
    test:ubuntu:lts:
      <<: *test-compatibility
      image: ubuntu:latest
      before_script:
        - apt-get update
    
        - apt-get install -y build-essential bash bc coreutils cmake make python3 libxml2 libreadline7 libqt5widgets5 libqt5xml5 graphviz libjsoncpp1
    
      dependencies:
        - build:ubuntu:lts
    
    test:ubuntu:rolling:
      <<: *test-compatibility
      image: ubuntu:rolling
      before_script:
        - apt-get update
    
        - apt-get install -y build-essential bash bc coreutils cmake make python3 libxml2 libreadline8 libqt5widgets5 libqt5xml5 graphviz libjsoncpp1
    
    #==========  Stage release =========
    
    .docker: &docker_template
      stage: docker
    
      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
        - 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
    
    Tomáš Pecka's avatar
    Tomáš Pecka committed
          - $SCHEDULED_NIGHTLY
    
      environment:
        name: docker-nightly
    
        - docker build -f extra/docker/Dockerfile.master     -t "$IMAGE_ALL:$TAG_NIGHTLY" .
        - docker build -f extra/docker/Dockerfile.master-cli -t "$IMAGE_CLI:$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_ALL:$TAG_NIGHTLY" /usr/bin/aql2 --help
        - docker run "$IMAGE_CLI:$TAG_NIGHTLY" /usr/bin/aql2 --help
        - docker run "$IMAGE_GUI:$TAG_NIGHTLY" /usr/bin/aql2 --help
        - docker push "$IMAGE_ALL:$TAG_NIGHTLY"
        - docker push "$IMAGE_CLI:$TAG_NIGHTLY"
        - docker push "$IMAGE_GUI:$TAG_NIGHTLY"
    
      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: &obs_template
      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
      stage: deploy
      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
      only:
    
        refs:
          - master
    
        variables:
          - $SCHEDULED_NIGHTLY
    
    deploy:obs:release:
      <<: *obs_template
      stage: deploy
      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
      only:
        - /^v.*$/
      except:
        - branches