diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dd7e907..4f249c0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,183 +1,234 @@ .build_docker: image: 'docker:19.03.11' services: - docker:19.03.11-dind variables: # Use TLS https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#tls-enabled DOCKER_HOST: tcp://docker:2376 DOCKER_TLS_CERTDIR: "/certs" stage: .pre before_script: - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY script: - echo ${DOCKERFILE} - cd ${DOCKERFILE} - docker build -t ${DOCKERREPO} . - docker push ${DOCKERREPO} when: manual docker build:debian_bullseye: extends: .build_docker variables: DOCKERFILE: dockerfiles/debian:bullseye/ DOCKERREPO: registry.gitlab.com/libmultiscale/libmultiscale:debian_bullseye docker build:ubuntu_20_04: extends: .build_docker variables: DOCKERFILE: dockerfiles/ubuntu:20.04/ DOCKERREPO: registry.gitlab.com/libmultiscale/libmultiscale:ubuntu_20_04 .image_lm: variables: BUILD_TYPE: Release CCACHE_BASEDIR: ${CI_PROJECT_DIR}/ CCACHE_DIR: ${CI_PROJECT_DIR}/ccache cache: key: ${DOCKERREPO}_${CI_COMMIT_REF_SLUG}_${BUILD_TYPE} paths: - ${CI_PROJECT_DIR}/ccache - third-party - .git/modules/third-party image: ${DOCKERREPO} artifacts: paths: - build expire_in: 1 day .build_lm: extends: - .image_lm stage: build before_script: - git submodule update --init third-party/eigen - git submodule update --init third-party/akantu - git submodule update --init third-party/lammps script: - echo $CCACHE_DIR - echo $CCACHE_BASEDIR - echo $BUILD_TYPE - echo "free -h" - free -h - echo "grep -c ^processor /proc/cpuinfo" - grep -c ^processor /proc/cpuinfo - mkdir -p build - cd build - cmake -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE -DLIBMULTISCALE_AKANTU_PLUGIN:BOOL=ON -DLIBMULTISCALE_MD1D:BOOL=ON -DLIBMULTISCALE_MECA1D:BOOL=ON -DLIBMULTISCALE_LAMMPS_PLUGIN:BOOL=ON -DLIBMULTISCALE_DOCUMENTATION:BOOL=ON -DLIBMULTISCALE_TESTS:BOOL=ON .. - cmake . - make - ls ../ccache .tests: stage: test variables: OMPI_MCA_plm: 'isolated' OMPI_MCA_btl: 'tcp,self' OMPI_ALLOW_RUN_AS_ROOT: 1 OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: 1 OMPI_MCA_rmaps_base_oversubscribe: 1 script: - cd build/test - export PYTHONPATH=$PYTHONPATH:$CI_PROJECT_DIR/build/python:$CI_PROJECT_DIR/test/python ; ctest -T test --no-compress-output --timeout 300 after_script: - cd build/test - tag=$(head -n 1 < Testing/TAG) - if [ -e Testing/${tag}/Test.xml ]; then - xsltproc -o ./juint.xml ${CI_PROJECT_DIR}/test/ctest2junit.xsl Testing/${tag}/Test.xml; - fi artifacts: when: always paths: - build/test/juint.xml reports: junit: - build/test/juint.xml build:debian_bullseye: variables: DOCKERREPO: registry.gitlab.com/libmultiscale/libmultiscale:debian_bullseye extends: - .build_lm build:debian_bullseye_debug: variables: DOCKERREPO: registry.gitlab.com/libmultiscale/libmultiscale:debian_bullseye BUILD_TYPE: Debug extends: - .build_lm build:ubuntu_20_04: variables: DOCKERREPO: registry.gitlab.com/libmultiscale/libmultiscale:ubuntu_20_04 extends: - .build_lm test:debian_bullseye: variables: DOCKERREPO: registry.gitlab.com/libmultiscale/libmultiscale:debian_bullseye extends: - .tests - .image_lm dependencies: - build:debian_bullseye .test:debian_bullseye_debug: variables: BUILD_TYPE: Debug DOCKERREPO: registry.gitlab.com/libmultiscale/libmultiscale:debian_bullseye extends: - .tests - .image_lm dependencies: - build:debian_bullseye_debug pages: extends: - .image_lm variables: DOCKERREPO: registry.gitlab.com/libmultiscale/libmultiscale:debian_bullseye stage: deploy script: - cd build - rm -r doc - export PYTHONPATH=$PYTHONPATH:$CI_PROJECT_DIR/build/python ; make libmultiscale-doc - mv doc/build/html ../public artifacts: paths: - public only: - master package: extends: - .image_lm variables: DOCKERREPO: registry.gitlab.com/libmultiscale/libmultiscale:debian_bullseye stage: deploy script: - cd build/python - python3 setup.py sdist bdist_wheel artifacts: paths: - build/python/dist only: - master + +code_quality: + stage: test + image: docker:19.03.12 + allow_failure: true + services: + - docker:19.03.12-dind + variables: + DOCKER_DRIVER: overlay2 + DOCKER_HOST: tcp://docker:2376 + DOCKER_TLS_CERTDIR: "/certs" + CODECLIMATE_DEV: 1 + CODE_QUALITY_IMAGE: "registry.gitlab.com/gitlab-org/ci-cd/codequality:0.85.22" + needs: [] + script: + - export SOURCE_CODE=$PWD + - | # this is required to avoid undesirable reset of Docker image ENV variables being set on build stage + function propagate_env_vars() { + CURRENT_ENV=$(printenv) + for VAR_NAME; do + echo $CURRENT_ENV | grep "${VAR_NAME}=" > /dev/null && echo "--env $VAR_NAME " + done + } + - docker pull --quiet "$CODE_QUALITY_IMAGE" + - | + - docker build -t codeclimate/codeclimate-clang-tidy test/ci/codeclimate/codeclimate-clang-tidy + - | + docker run \ + $(propagate_env_vars \ + SOURCE_CODE \ + TIMEOUT_SECONDS \ + CODECLIMATE_DEBUG \ + CODECLIMATE_DEV \ + REPORT_STDOUT \ + REPORT_FORMAT \ + ENGINE_MEMORY_LIMIT_BYTES \ + ) \ + --volume "$PWD":/code \ + --volume /var/run/docker.sock:/var/run/docker.sock \ + "$CODE_QUALITY_IMAGE" /code + artifacts: + paths: + - gl-code-quality-report.json + reports: + codequality: gl-code-quality-report.json + expire_in: 1 week + dependencies: [] + rules: + - if: '$CODE_QUALITY_DISABLED' + when: never + - if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH'