Skip to content
Snippets Groups Projects
.gitlab-ci.yml 5.65 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.8
    
    stages:
     - build
     - test
    
    
    #==========  Stage build  ==========
    
    
    .build: &build
    
      stage: build
    
        - CMake/generate.py -wm
    
        - mkdir release
        - cd release
        - cmake -DCMAKE_BUILD_TYPE=Release ..
    
        - make -j $(grep -c processor /proc/cpuinfo)
    
      artifacts:
        paths:
    
    
    .build:push: &build-push
      <<: *build
      image: alpine:3.8
      before_script:
        - apk add --no-cache bash build-base cmake python3 libexecinfo-dev cppunit-dev libxml2-dev tclap-dev readline-dev qt5-qtbase-dev graphviz-dev jsoncpp-dev ${EXTRA_PKGS}
        - export CXX=${CXX}
    
    .build:compatibility: &build-compatibility
      <<: *build
      only:
        variables:
          - $SCHEDULED_COMPATIBILITY
    
    build:alpine:gcc:
      <<: *build-push
    
      variables:
        CXX: g++
    
    build:alpine:clang:
      <<: *build-push
    
      variables:
    
        EXTRA_PKGS: clang
    
        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 libcppunit-dev 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 libcppunit-dev libxml2-dev libtclap-dev libreadline-dev qtbase5-dev graphviz-dev libjsoncpp-dev
    
    build:arch:
      <<: *build-compatibility
      image: archlinux/base:latest
      before_script:
        - pacman -Syu --noconfirm base-devel cmake make python cppunit libxml2 tclap readline qt5-base graphviz jsoncpp
    
    
    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  ==========
    
    
      stage: test
    
        - make test
          # temporary until make tests manages all tests
        - mkdir bin
        - cd bin
        - find .. -type f \( -perm -u=x -o -perm -g=x -o -perm -o=x \) -exec test -x {} \; -print | grep -v 'CMakeFiles' | while read line; do ln -s $line $(basename $line); done
        - cd ../..
        - for test in $(ls tests.*.sh); do ./${test} release/bin $(grep -c processor /proc/cpuinfo) || exit 1; touch release/bin/log_tests.txt; cat release/bin/log_tests.txt; done
    
    .test:push: &test-push
      <<: *test
      image: alpine:3.8
      before_script:
        - apk add --no-cache bash bc coreutils python3 cmake make libexecinfo cppunit libxml2 tclap readline qt5-qtbase qt5-qtbase-x11 graphviz jsoncpp
    
    .test:compatibility: &test-compatibility
      <<: *test
      only:
        variables:
          - $SCHEDULED_COMPATIBILITY
    
    test:alpine:gcc:
      <<: *test-push
      dependencies:
        - build:alpine:gcc
    
    test:alpine:clang:
      <<: *test-push
      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 libcppunit-1.13-0v5 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 libcppunit-1.14 libxml2 libreadline7 libqt5widgets5 libqt5xml5 graphviz libjsoncpp1
    
      dependencies:
    
        - build:debian:testing
    
    test:arch:
      <<: *test-compatibility
      image: archlinux/base:latest
      before_script:
        - pacman -Syu --noconfirm base-devel bash bc coreutils cmake make python cppunit libxml2 tclap readline qt5-base graphviz jsoncpp
    
      dependencies:
    
    
    #==========  Stage release =========
    
    .docker: &docker_template
      stage: docker
      image: gitlab.fit.cvut.cz:5000/ict/alpine-docker-images/ci:3.8
      cache: {}  # disable
      variables:
        DOCKER_DRIVER: overlay2
        DOCKER_HOST: docker
    
        IMAGE_TAG_NIGHTLY_FULL: $CI_REGISTRY_IMAGE/nightly:latest
        IMAGE_TAG_NIGHTLY_CLI:  $CI_REGISTRY_IMAGE/nightly-cli:latest
    
        IMAGE_TAG_RELEASE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
        IMAGE_TAG_LATEST: $CI_REGISTRY_IMAGE:latest
      services:
        - docker:dind
      before_script:
        - apk add --no-cache docker
        - docker info
        - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
    
    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
    
      dependencies: []
    
    docker:build-nightly:
      <<: *docker_template
      only:
    
    Tomáš Pecka's avatar
    Tomáš Pecka committed
          - $SCHEDULED_NIGHTLY
    
        - docker build -f extra/docker/master/Dockerfile     -t "$IMAGE_TAG_NIGHTLY_FULL" .
        - docker build -f extra/docker/master-cli/Dockerfile -t "$IMAGE_TAG_NIGHTLY_CLI" .
        - docker run "$IMAGE_TAG_NIGHTLY_FULL" /usr/bin/aql2 --help
        - docker run "$IMAGE_TAG_NIGHTLY_CLI"  /usr/bin/aql2 --help
        - docker push "$IMAGE_TAG_NIGHTLY_FULL"
        - docker push "$IMAGE_TAG_NIGHTLY_CLI"
    
    
    docker:build-release:
      <<: *docker_template
      only:
        - /^v.*$/
      except:
        - branches
      script:
    
        - docker build -f extra/docker/master/Dockerfile -t "$IMAGE_TAG_RELEASE" -t "$IMAGE_TAG_LATEST" .
    
        - docker run "$IMAGE_TAG_RELEASE" /usr/bin/aql2 --help
    
        - docker push "$IMAGE_TAG_RELEASE"
        - docker push "$IMAGE_TAG_LATEST"