.gitlab-ci.yml 4.34 KB
Newer Older
Noah Olsen's avatar
commit  
Noah Olsen committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
image: gitlab.cs.wallawalla.edu:5050/pridja/catch2-example:latest


before_script:
  


stages:
  - analysis
  - build
  - test
  - coverage
  - deploy

check_formatting:
  stage: analysis
  script:
    - echo `which clang-format-6.0`
    - ln -s `which clang-format-6.0` /usr/bin/clang-format
    - echo $CI_PROJECT_DIR
    - cd "$CI_PROJECT_DIR"
    - linter_errors=$(git-clang-format-6.0 --commit "HEAD~1" -q --diff | grep -v --color=never "no modified files to format" || true)
    - echo "$linter_errors"
    - if [ ! -z "$linter_errors" ]; then echo "Detected formatting issues; please fix"; exit 1; else echo "Formatting is correct"; exit 0; fi

run_cpplint:
  stage: analysis
  script:
    - cpplint --filter=-whitespace,-legal/copyright,-readability/multiline_comment ./Main/main.cpp
    - cd src
    - find -name '*.h' -exec cpplint {} +
    - find -name '*.cpp' -exec cpplint {} +

run_cppcheck:
  stage: analysis
  script:
    - find -name '*.h' -exec cppcheck --enable=all --suppress=missingIncludeSystem --language=c++ {} +
    - find -name '*.cpp' -exec cppcheck --enable=all --suppress=missingIncludeSystem --language=c++ {} +


build_programs:
  stage: build
  script:
    - mkdir build
    - cd build
    - cmake ..
    - make
  artifacts:
    paths:
      - build/tests
    expire_in: 1 hour

test:
  image: ruby:2.3
  stage: test
  script:
    - bundle install
    - cd docs
    - bundle exec jekyll build -d ../test
  artifacts:
    paths:
      - test
  except:
    - master    

quote_tests:
  stage: test
  script:
    - build/tests [quote]

code_coverage:
  stage: coverage
  script:
    - mkdir -p build && cd build
    - cmake .. -DGENERATE_CODE_COVERAGE=true
    - make tests
    - ./tests
    - cd CMakeFiles/tests.dir
    - mkdir -p cov
    - find -name '*.o' -exec cp -t cov {} +
    - find -name '*.gcno' -exec cp -t cov {} +
    - find -name '*.gcda' -exec cp -t cov {} +
    - cd cov || exit 1
    - find -name '*.o' -exec gcov -bf {} \; > /dev/null
    - lcov --quiet --capture --directory . --output-file coverage.info
    - lcov --quiet --remove coverage.info "*include*" -o coverage.info
    - lcov --list coverage.info
    - echo "Generating HTML Report"
    - genhtml coverage.info --output-directory out
    - echo "You can download the report from the pipleine artifacts in gitlab for the next week"
  artifacts:
    paths:
      - build/CMakeFiles/tests.dir/cov/out/
    expire_in: 7 days


# deploy_prod:
#   stage: deploy
#   before_script:
#     - apt-get update -qq
#     - apt-get install -qq curl
#     - 'which ssh-agent || ( apt-get install -qq openssh-client )'
#     - eval $(ssh-agent -s)
#     - ssh-add <(echo "$SSH_PRIVATE_KEY" | base64 -d -w 0)
#     - mkdir -p ~/.ssh
#     - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
#   script:
#     - ELF_NAME="${CI_PROJECT_NAMESPACE}-fact"
#     - SSH_COMMAND_STRING="if pgrep ${ELF_NAME}; then pkill ${ELF_NAME}; fi && "
#     # Double quotes around everything needed as it has a colon in it
#     - "SSH_COMMAND_STRING+=\"curl --location --header 'PRIVATE-TOKEN: ${API_TOKEN}' '${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/jobs/artifacts/${CI_BUILD_REF_NAME}/raw/build/factorial?job=build_programs' --output ${ELF_NAME} &&\" "
#     # Make sure the file is executable
#     - SSH_COMMAND_STRING+="chmod +x ${ELF_NAME} && "
#     # Start it in the background in such a way that SSH will not hang when we exit
#     - SSH_COMMAND_STRING+="(nohup ./${ELF_NAME} ${RUN_PORT} > /dev/null 2>&1 &) && "
#     # Make sure the program is running, if it is, we exit gracefully
#     - SSH_COMMAND_STRING+="if pgrep ${ELF_NAME}; then exit; fi && "
#     # If the program is not running, exit with an error code to say something went wrong
#     - SSH_COMMAND_STRING+="exit 1"
#     # Print it out so we can see what happened for debugging purposes.
#     - echo "$SSH_COMMAND_STRING"
#     # Execute the deploy
#     - ssh $SSH_USER@$SSH_HOST "${SSH_COMMAND_STRING}"
#     # Make sure it is running
#     - "curl --location http://${SSH_HOST}:${RUN_PORT} | grep \"Hello World!\""
#   when: manual
#   only:
#     - master


variables:
  JEKYLL_ENV: production
  LC_ALL: C.UTF-8


pages:
  image: ruby:2.3
  stage: deploy
  script:
    - bundle install
    - cd docs
    - bundle exec jekyll build -d ../public
    - echo "Deployed at ${CI_PAGES_URL}"
  artifacts:
    paths:
      - public
  only:
    - master