diff --git a/.gitlab-ci.d/templates.yaml b/.gitlab-ci.d/templates.yaml index 70b9bc00a..39a8b4506 100644 --- a/.gitlab-ci.d/templates.yaml +++ b/.gitlab-ci.d/templates.yaml @@ -1,140 +1,140 @@ # yaml-language-server: $format.enable=false, $schemaStore.enable=true, $schemas=gitlab-ci # Configuration template .configure: stage: configure variables: BLA_VENDOR: "Generic" CMAKE_GENERATOR: "Unix Makefiles" # CMAKE_GENERATOR: 'Ninja' script: # Create the build folder - cmake -E make_directory build - cd build - echo BUILD_TYPE=${BUILD_TYPE} # Configure the project - cmake -DAKANTU_COHESIVE_ELEMENT:BOOL=TRUE -DAKANTU_IMPLICIT:BOOL=TRUE -DAKANTU_PARALLEL:BOOL=TRUE -DAKANTU_STRUCTURAL_MECHANICS:BOOL=TRUE -DAKANTU_HEAT_TRANSFER:BOOL=TRUE -DAKANTU_DAMAGE_NON_LOCAL:BOOL=TRUE -DAKANTU_PHASE_FIELD:BOOL=TRUE -DAKANTU_PYTHON_INTERFACE:BOOL=TRUE -DAKANTU_CONTACT_MECHANICS:BOOL=TRUE -DAKANTU_EXAMPLES:BOOL=TRUE -DAKANTU_BUILD_ALL_EXAMPLES:BOOL=TRUE -DAKANTU_TESTS:BOOL=TRUE -DAKANTU_RUN_IN_DOCKER:BOOL=TRUE -DAKANTU_TEST_EXAMPLES:BOOL=${TEST_EXAMPLES} -DCMAKE_BUILD_TYPE:STRING=${BUILD_TYPE} -G "${CMAKE_GENERATOR}" .. - # Copie the compile commands for the code quality + # Copy the compile commands for the code quality - if [ -e compile_commands.json ]; then - - cp compile_commands.json .. + - cp compile_commands.json .. - fi artifacts: when: on_success paths: - build - compile_commands.json expire_in: 10h # Build the libraries .build_libs: stage: build_libs script: - echo BUILD_TYPE=${BUILD_TYPE} - cmake --build build --target akantu -j1 > >(tee -a build-${output}-out.log) 2> >(tee -a build-${output}-err.log >&2) - cmake --build build --target py11_akantu -j1 > >(tee -a build-${output}-out.log) 2> >(tee -a build-${output}-err.log >&2) artifacts: when: on_success paths: - build/ - build-${output}-err.log - compile_commands.json expire_in: 10h # build the tests .build_tests: stage: build_tests script: - cmake --build build -j1 > >(tee -a build-${output}-out.log) 2> >(tee -a build-${output}-err.log >&2) artifacts: when: on_success paths: - build/ - build-${output}-err.log - compile_commands.json exclude: - build/**/*.o expire_in: 10h # Build all .build_all: stage: build_libs script: - cmake --build build/src > >(tee -a build-${output}-out.log) 2> >(tee -a build-${output}-err.log >&2) - cmake --build build/python > >(tee -a build-${output}-out.log) 2> >(tee -a build-${output}-err.log >&2) - cmake --build build/test/ > >(tee -a build-${output}-out.log) 2> >(tee -a build-${output}-err.log >&2) - cmake --build build/examples > >(tee -a build-${output}-out.log) 2> >(tee -a build-${output}-err.log >&2) artifacts: when: on_success paths: - build/ - build-${output}-err.log - compile_commands.json exclude: - build/**/*.o expire_in: 10h # Run the tests .tests: stage: test script: - cd build - ctest -T test --output-on-failure --no-compress-output --timeout 1800 after_script: - cd build - tag=$(head -n 1 < Testing/TAG) - if [ -e Testing/${tag}/Test.xml ]; then - xsltproc -o ./juint.xml ${CI_PROJECT_DIR}/test/ci/ctest2junit.xsl Testing/${tag}/Test.xml; - fi - if [ ${BUILD_TYPE} = "Coverage" ]; then - gcovr --xml --gcov-executable "${GCOV_EXECUTABLE}" --xml-pretty --exclude-unreachable-branches --print-summary --output coverage.xml --object-directory ${CI_PROJECT_DIR}/build --root ${CI_PROJECT_DIR} -s || true - fi artifacts: when: always expire_in: 2 days paths: - build/juint.xml - build/coverage.xml reports: junit: - build/juint.xml coverage_report: coverage_format: cobertura path: build/coverage.xml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9da2d65be..a8693bbf2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,350 +1,371 @@ # yaml-language-server: $schema=gitlab-ci # yaml-language-server: $format.enable=false stages: + - version - configure - build_libs - build_tests - test - code_quality - deploy include: local: '.gitlab-ci.d/*.yaml' #------------------------------------------------------------------------------- # Rebuilding the docker images if needed #------------------------------------------------------------------------------- docker build:debian-bullseye: variables: IMAGE_NAME: debian:bullseye extends: .docker_build docker build:ubuntu-lts: variables: IMAGE_NAME: ubuntu:lts extends: .docker_build docker build:manylinux: variables: IMAGE_NAME: manylinux:2010_x86_64 extends: .docker_build +version_determination: + stage: version + variables: + GIT_STRATEGY: clone + extends: + - .debian_bullseye_gcc + script: + - git describe --tags --abbrev=0 --match v* || /bin/true + - git describe --tags --always --dirty --long --match v* || /bin/true + - git rev-parse HEAD || /bin/true + artifacts: + when: on_success + paths: + - VERSION + expire_in: 1day # ------------------------------------------------------------------------------ # Debian bullseye compiled with GCC # ------------------------------------------------------------------------------ configure:debian_bullseye_gcc: extends: - .debian_bullseye_gcc - .build_coverage - .configure - + needs: + - version_determination + build:debian_bullseye_gcc: extends: - .debian_bullseye_gcc - .build_coverage - .build_all needs: - job: configure:debian_bullseye_gcc test:debian_bullseye_gcc: extends: - .debian_bullseye_gcc - .build_coverage - .tests coverage: '/^lines: (\d+\.\d+\%)/' needs: - job: build:debian_bullseye_gcc # ------------------------------------------------------------------------------ # Debian bullseye compiled with Clang # ------------------------------------------------------------------------------ configure:debian_bullseye_clang: extends: - .debian_bullseye_clang - .build_coverage - .configure + needs: + - version_determination build:debian_bullseye_clang: extends: - .debian_bullseye_clang - .build_coverage - .build_all needs: - job: configure:debian_bullseye_clang test:debian_bullseye_clang: extends: - .debian_bullseye_clang - .build_coverage - .tests coverage: '/^lines: (\d+\.\d+\%)/' needs: - job: build:debian_bullseye_clang # ------------------------------------------------------------------------------ # Ubuntu LTS compiled with GCC # ------------------------------------------------------------------------------ configure:ubuntu_lts_gcc: extends: - .ubuntu_lts_gcc - .build_release - .configure + needs: + - version_determination build:ubuntu_lts_gcc: extends: - .ubuntu_lts_gcc - .build_release - .build_all needs: - job: configure:ubuntu_lts_gcc test:ubuntu_lts_gcc: extends: - .ubuntu_lts_gcc - .build_release - .tests needs: - job: build:ubuntu_lts_gcc # ------------------------------------------------------------------------------ # Debian bullseye compiled with GCC tested with valgrind # ------------------------------------------------------------------------------ configure:ubuntu_lts_gcc_valgrind: extends: - .ubuntu_lts_gcc - .build_valgrind - .configure + needs: + - version_determination build:ubuntu_lts_gcc_valgrind: extends: - .ubuntu_lts_gcc - .build_valgrind - .build_all needs: - job: configure:ubuntu_lts_gcc_valgrind test:ubuntu_lts_gcc_valgrind: extends: - .ubuntu_lts_gcc - .build_valgrind - .tests needs: - job: build:ubuntu_lts_gcc_valgrind # ------------------------------------------------------------------------------ # Manylinux to build python packages # ------------------------------------------------------------------------------ configure:python_package: stage: configure extends: - .manylinux_2010_x64_gcc - .build_release script: - - git config --global --add safe.directory ${CI_PROJECT_DIR} - - git describe --tags --abbrev=0 --match v* || /bin/true - - git describe --tags --always --dirty --long --match v* || /bin/true - - git rev-parse HEAD || /bin/true - # create the build folder - cmake -E make_directory build - cd build # Variables for cmake - export CMAKE_PREFIX_PATH=/softs/view - export BOOST_ROOT=/softs/view # Configure in sequential and without tests or examples - cmake -DAKANTU_COHESIVE_ELEMENT:BOOL=TRUE -DAKANTU_IMPLICIT:BOOL=TRUE -DAKANTU_PARALLEL:BOOL=FALSE -DAKANTU_STRUCTURAL_MECHANICS:BOOL=TRUE -DAKANTU_HEAT_TRANSFER:BOOL=TRUE -DAKANTU_DAMAGE_NON_LOCAL:BOOL=TRUE -DAKANTU_PHASE_FIELD:BOOL=TRUE -DAKANTU_PYTHON_INTERFACE:BOOL=FALSE -DAKANTU_CONTACT_MECHANICS:BOOL=TRUE -DAKANTU_EXAMPLES:BOOL=FALSE -DAKANTU_TESTS:BOOL=FALSE -DMUMPS_DETECT_DEBUG:BOOL=TRUE -DCMAKE_INSTALL_PREFIX:PATH=${CI_PROJECT_DIR}/install -DCMAKE_BUILD_TYPE:STRING=${BUILD_TYPE} .. + needs: + - version_determination artifacts: when: on_success paths: - build/ expire_in: 10h build_akantu:python_package: extends: - .build_libs - .build_release - .manylinux_2010_x64_gcc script: - cmake --build build --target akantu -j1 - cmake --install build artifacts: when: on_success paths: - install/ expire_in: 10h needs: - job: configure:python_package build_pip:python_package: stage: build_tests extends: - .build_release - .manylinux_2010_x64_gcc script: - export CI_AKANTU_INSTALL_PREFIX=${CI_PROJECT_DIR}/install - export CMAKE_PREFIX_PATH=/softs/view:${CI_AKANTU_INSTALL_PREFIX} - test/ci/make-wheels.sh needs: - job: build_akantu:python_package artifacts: when: on_success paths: - wheelhouse expire_in: 10h test:python_package: stage: test image: python:3.8 needs: - job: build_pip:python_package script: - pip install numpy scipy - pip install akantu --no-index --find-links=${PWD}/wheelhouse - python -c "import akantu" - cd examples/python/dynamics/ - apt update && apt install -y gmsh - gmsh -2 bar.geo - python ./dynamics.py package:python_gitlab: stage: deploy image: python:latest script: - pip install twine - TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token python3 -m twine upload --repository-url https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/packages/pypi wheelhouse/* needs: - job: build_pip:python_package - job: test:python_package only: - master package:python_pypi: stage: deploy image: python:latest script: - pip install twine - TWINE_PASSWORD=${PYPI_TOKEN} TWINE_USERNAME=__token__ python3 -m twine upload --verbose wheelhouse/* needs: - job: build_pip:python_package - job: test:python_package only: - tags # ------------------------------------------------------------------------------ # Code Quality # ------------------------------------------------------------------------------ cq:code_quality: extends: - .code_quality_gitlab_template needs: - job: build:debian_bullseye_clang artifacts: paths: - gl-code-quality-report.json cq:clang_tidy: extends: - .clang_tools script: - test/ci/scripts/cq -x third-party -x extra-packages -x pybind11 -x test ${FILE_LIST_ARG} clang-tidy -p ${CI_PROJECT_DIR}/build > gl-clang-tidy-report.json needs: - job: build:debian_bullseye_clang artifacts: paths: - gl-clang-tidy-report.json cq:clang_format: extends: - .clang_tools script: - test/ci/scripts/cq -x third-party -x extra-packages clang-format -p ${CI_PROJECT_DIR}/build > gl-clang-format-report.json needs: - job: build:debian_bullseye_clang artifacts: paths: - gl-clang-format-report.json cq:compilation_warnings: stage: code_quality image: python:latest script: - pip install warning-parser termcolor Click - ls build-*-err.log - test/ci/scripts/cq -x third-party -x extra-packages warnings build-*-err.log > gl-warnings-report.json needs: - job: build:debian_bullseye_clang - job: build:debian_bullseye_gcc - job: build:ubuntu_lts_gcc artifacts: paths: - gl-warnings-report.json cq:merge_code_quality: stage: deploy extends: - .debian_bullseye_clang script: - jq -Ms '[.[][]]' gl-*-report.json | tee gl-codequality.json | jq -C needs: - job: cq:code_quality - job: cq:clang_tidy - job: cq:clang_format - job: cq:compilation_warnings artifacts: reports: codequality: [gl-codequality.json] # ------------------------------------------------------------------------------ # Deploy pages # ------------------------------------------------------------------------------ pages: stage: deploy extends: - .debian_bullseye_gcc script: - cd build - cmake -DAKANTU_DOCUMENTATION=ON .. - cmake --build . -t sphinx-doc - mv doc/dev-doc/html ../public needs: - job: build:debian_bullseye_gcc artifacts: paths: - public only: - master