From 64c3385818c0d3b7c368ecf7be72980b03bdd157 Mon Sep 17 00:00:00 2001 From: Florent Pruvost <florent.pruvost@inria.fr> Date: Fri, 22 Nov 2024 11:54:27 +0100 Subject: [PATCH] Update docker environmnent --- .gitlab-ci.yml | 38 ++++++++++++++++++++------------------ .gitlab/analysis.sh | 5 +++-- .gitlab/build.sh | 15 +++++---------- .gitlab/test.sh | 13 ++++--------- 4 files changed, 32 insertions(+), 39 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6acc557..2d298c3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,30 +1,29 @@ -image: registry.gitlab.inria.fr/solverstack/docker/distrib - stages: - pre - build - test - analyze +default: + image: registry.gitlab.inria.fr/solverstack/docker/base + tags: ['ci.inria.fr', 'linux', 'small'] # gitlab instance runner (i.e. docker on linux) + interruptible: true + before_script: - git config --global --add safe.directory $CI_PROJECT_DIR - git submodule update --init --recursive .only-master-mr: - interruptible: true rules: - if: ($CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ /^ci-.*$/) - if: ($CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME !~ /^notest-.*$/) .only-mr: - interruptible: true rules: - if: ($CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME !~ /^notest-.*$/) preliminary_checks: stage: pre - tags: ["docker", "large"] - interruptible: true rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event" parallel: @@ -35,7 +34,6 @@ preliminary_checks: hqr_build_linux: stage: build - tags: ["docker", "large"] extends: .only-master-mr variables: SYSTEM: linux @@ -43,7 +41,7 @@ hqr_build_linux: - bash .gitlab/build.sh | tee hqr-build-linux.log artifacts: name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG" - expire_in: 180 minutes + expire_in: 1 week untracked: true hqr_build_macosx: @@ -56,7 +54,7 @@ hqr_build_macosx: - bash .gitlab/build.sh | tee hqr-build-linux.log artifacts: name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG" - expire_in: 180 minutes + expire_in: 1 week paths: - hqr-build-linux.log cache: @@ -76,7 +74,7 @@ hqr_build_windows: - bash -lc .gitlab/build.sh | tee hqr-build-linux.log artifacts: name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG" - expire_in: 180 minutes + expire_in: 1 week paths: - hqr-build-linux.log cache: @@ -86,7 +84,6 @@ hqr_build_windows: hqr_test_linux: stage: test - tags: ["docker", "large"] extends: .only-master-mr needs: [hqr_build_linux] variables: @@ -96,14 +93,18 @@ hqr_test_linux: coverage: /^\s*lines......:\s*\d+.\d+\%/ artifacts: name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG" - expire_in: 180 minutes + when: always + expire_in: 1 week paths: - hqr-test-linux.log - junit.xml - hqr.lcov - - hqr-coverage.xml + - coverage.xml reports: junit: junit.xml + coverage_report: + coverage_format: cobertura + path: coverage.xml hqr_test_macosx: stage: test @@ -116,7 +117,8 @@ hqr_test_macosx: - bash .gitlab/test.sh | tee hqr-test-macosx.log artifacts: name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG" - expire_in: 180 minutes + when: always + expire_in: 1 week paths: - hqr-test-macosx.log reports: @@ -139,7 +141,8 @@ hqr_test_windows: - bash .gitlab/test.sh | tee hqr-test-windows.log artifacts: name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG" - expire_in: 180 minutes + when: always + expire_in: 1 week paths: - hqr-test-windows.log reports: @@ -151,8 +154,7 @@ hqr_test_windows: sonarqube: stage: analyze - tags: ["docker", "large"] - interruptible: true + image: registry.gitlab.inria.fr/solverstack/docker/analysis rules: - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ /^ci-.*$/ - if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME !~ /^notest-.*$/ @@ -165,7 +167,7 @@ sonarqube: - ./.gitlab/analysis.sh artifacts: name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG" - expire_in: 180 minutes + expire_in: 1 week paths: - filelist.txt - hqr-cppcheck.xml diff --git a/.gitlab/analysis.sh b/.gitlab/analysis.sh index 0bdd2fd..43f2cd2 100755 --- a/.gitlab/analysis.sh +++ b/.gitlab/analysis.sh @@ -15,7 +15,8 @@ # - we consider to be in HQR's source code root # - we consider having the junit.xml file and the coverage file hqr-coverage.xml in the root directory # - we consider having cppcheck, rats, sonar-scanner programs available in the environment - +set -e +set -x if [ $# -gt 0 ] then BUILDDIR=$1 @@ -30,7 +31,7 @@ git ls-files | grep "\.[ch]$" > filelist.txt export UNDEFINITIONS="-UWIN32 -UWIN64 -U_MSC_EXTENSIONS -U_MSC_VER -U__SUNPRO_C -U__SUNPRO_CC -U__sun -Usun -U__cplusplus" # run cppcheck analysis -cppcheck -v -f --project=build/compile_commands.json --language=c --platform=unix64 --enable=all --xml --xml-version=2 --suppress=missingInclude ${UNDEFINITIONS} ${DEFINITIONS} --file-list=./filelist.txt 2> hqr-cppcheck.xml +cppcheck -v -f --project=build/compile_commands.json --language=c --platform=unix64 --enable=all --xml --xml-version=2 --suppress=missingInclude ${UNDEFINITIONS} ${DEFINITIONS} 2> hqr-cppcheck.xml # run rats analysis rats -w 3 --xml `cat filelist.txt` > hqr-rats.xml diff --git a/.gitlab/build.sh b/.gitlab/build.sh index 86efc5c..37456ce 100755 --- a/.gitlab/build.sh +++ b/.gitlab/build.sh @@ -1,10 +1,5 @@ #!/usr/bin/env bash - -fatal() { - echo "$0: error occurred, exit" - exit 1 -} - +set -e set -x if [[ "$SYSTEM" == "linux" ]]; then @@ -13,14 +8,14 @@ if [[ "$SYSTEM" == "linux" ]]; then cmake -B build -S . -DCMAKE_INSTALL_PREFIX=$PWD/install \ -DBUILD_SHARED_LIBS=ON -DCMAKE_VERBOSE_MAKEFILE=ON \ -DCMAKE_C_FLAGS="-O0 -g -fPIC --coverage -Wall -fdiagnostics-show-option -fno-inline" \ - -DCMAKE_EXE_LINKER_FLAGS="--coverage" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON || fatal + -DCMAKE_EXE_LINKER_FLAGS="--coverage" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON else # no coverage analysis on other platforms cmake -B build -S . -DCMAKE_INSTALL_PREFIX=$PWD/install \ - -DBUILD_SHARED_LIBS=ON -DCMAKE_VERBOSE_MAKEFILE=ON || fatal + -DBUILD_SHARED_LIBS=ON -DCMAKE_VERBOSE_MAKEFILE=ON fi -cmake --build build -j 4 || fatal -cmake --install build || fatal +cmake --build build -j 4 +cmake --install build diff --git a/.gitlab/test.sh b/.gitlab/test.sh index 2edbdc7..2537a35 100755 --- a/.gitlab/test.sh +++ b/.gitlab/test.sh @@ -1,14 +1,9 @@ #!/usr/bin/env bash - -fatal() { - echo "$0: error occurred, exit" - exit 1 -} - +set -e set -x if [[ "$SYSTEM" == "linux" ]]; then - source install/bin/hqr_env.sh || fatal + source install/bin/hqr_env.sh fi cd build if [[ "$SYSTEM" == "windows" ]]; then @@ -16,12 +11,12 @@ if [[ "$SYSTEM" == "windows" ]]; then export PATH="/c/Windows/WinSxS/x86_microsoft-windows-m..namespace-downlevel_31bf3856ad364e35_10.0.19041.1_none_21374cb0681a6320":$PATH export PATH=$PWD/src:$PATH fi -ctest --output-on-failure --no-compress-output -T Test --output-junit ../junit.xml || fatal +ctest --output-on-failure --no-compress-output -T Test --output-junit ../junit.xml if [[ "$SYSTEM" == "linux" ]]; then # clang is used on macosx and it is not compatible with --coverage option # so that we can only make the coverage report on the linux runner with gcc cd .. lcov --capture --directory build -q --output-file hqr.lcov lcov --summary hqr.lcov - lcov_cobertura hqr.lcov --output hqr-coverage.xml + lcov_cobertura hqr.lcov --output coverage.xml fi -- GitLab