diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 271581e4d845ea93d5fd3a09f471edec69913277..daf98cc7335244eb29b1197b200a08743a3b43fd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -25,7 +25,9 @@ ################################################################################ stages: - # Build + # Analyse code + - static_analysis + # Build Aidge - build # Unit test stage - test @@ -34,6 +36,7 @@ stages: include: - local: '/.gitlab/ci/_global.gitlab-ci.yml' + # - local: '/.gitlab/ci/static_analysis.gitlab-ci.yml' - local: '/.gitlab/ci/build.gitlab-ci.yml' - local: '/.gitlab/ci/test.gitlab-ci.yml' - - local: '/.gitlab/ci/coverage.gitlab-ci.yml' + # - local: '/.gitlab/ci/coverage.gitlab-ci.yml' diff --git a/.gitlab/ci/_global.gitlab-ci.yml b/.gitlab/ci/_global.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..0dda8ee7b1b8fb8a2c35ca2a1787c477ca2a5053 --- /dev/null +++ b/.gitlab/ci/_global.gitlab-ci.yml @@ -0,0 +1,24 @@ +################################################################################ +# Centralized definitions of common job parameter values. # +# Parameters with many optional configurations may be in separate files. # +# # +################################################################################ +variables: + GIT_SUBMODULE_STRATEGY: recursive + OMP_NUM_THREADS: 4 + GIT_SSL_NO_VERIFY: 1 + DEBIAN_FRONTEND: noninteractive + +# See https://docs.gitlab.com/ee/ci/yaml/workflow.html#switch-between-branch-pipelines-and-merge-request-pipelines +workflow: + rules: + - if: $CI_PIPELINE_SOURCE == "merge_request_event" + - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS + when: never + - if: $CI_COMMIT_BRANCH + +default: + image: nvidia/cuda:12.2.0-devel-ubuntu22.04 + before_script: + - apt update + - apt install -y cmake cppcheck python-is-python3 pip git gcovr unzip curl libopencv-dev diff --git a/.gitlab/ci/build.gitlab-ci.yml b/.gitlab/ci/build.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..264fefa4d0d4c34065581fafe7b66277cd6dedf7 --- /dev/null +++ b/.gitlab/ci/build.gitlab-ci.yml @@ -0,0 +1,234 @@ +build:ubuntu_cpp: + stage: build + needs: [] + tags: + - docker + script: + # Download dependencies + - DEPENDENCY_JOB="build:ubuntu_cpp" + # aidge_core + - DEPENDENCY_NAME="aidge_core" + - !reference [.download_dependency, script] + # aidge_backend_cpu + - DEPENDENCY_NAME="aidge_backend_cpu" + - !reference [.download_dependency, script] + + # Build current module + - export CMAKE_PREFIX_PATH=../install_cpp + - mkdir -p build_cpp + - cd build_cpp + - cmake -DCMAKE_INSTALL_PREFIX:PATH=../install_cpp -DCMAKE_BUILD_TYPE=Debug -DWERROR=ON -DCOVERAGE=ON .. + - make -j4 all install + + artifacts: + expire_in: 1 week + paths: + - build_cpp/ + - install_cpp/ +build:ubuntu_cpp_g++10: + stage: build + needs: [] + tags: + - docker + + script: + # Download dependencies + - DEPENDENCY_JOB="build:ubuntu_cpp" + # aidge_core + - DEPENDENCY_NAME="aidge_core" + - !reference [.download_dependency, script] + # aidge_backend_cpu + - DEPENDENCY_NAME="aidge_backend_cpu" + - !reference [.download_dependency, script] + + # Build current module + - export CMAKE_PREFIX_PATH=../install_cpp + - apt install -y g++-10 + - mkdir -p build_cpp + - mkdir -p install_cpp + - cd build_cpp + - export CXX=/usr/bin/g++-10 + - cmake -DCMAKE_INSTALL_PREFIX:PATH=../install_cpp -DCMAKE_BUILD_TYPE=Debug -DWERROR=ON -DCOVERAGE=ON .. + - make -j4 all install + +build:ubuntu_cpp_g++12: + stage: build + needs: [] + tags: + - docker + + script: + # Download dependencies + - DEPENDENCY_JOB="build:ubuntu_cpp" + # aidge_core + - DEPENDENCY_NAME="aidge_core" + - !reference [.download_dependency, script] + # aidge_backend_cpu + - DEPENDENCY_NAME="aidge_backend_cpu" + - !reference [.download_dependency, script] + + # Build current module + - export CMAKE_PREFIX_PATH=../install_cpp + - apt install -y g++-12 + - mkdir -p build_cpp + - mkdir -p install_cpp + - cd build_cpp + - export CXX=/usr/bin/g++-12 + - cmake -DCMAKE_INSTALL_PREFIX:PATH=../install_cpp -DCMAKE_BUILD_TYPE=Debug -DWERROR=ON -DCOVERAGE=ON .. + - make -j4 all install + +build:ubuntu_cpp_clang12: + stage: build + needs: [] + tags: + - docker + + script: + # Download dependencies + - DEPENDENCY_JOB="build:ubuntu_cpp" + # aidge_core + - DEPENDENCY_NAME="aidge_core" + - !reference [.download_dependency, script] + # aidge_backend_cpu + - DEPENDENCY_NAME="aidge_backend_cpu" + - !reference [.download_dependency, script] + + # Build current module + - export CMAKE_PREFIX_PATH=../install_cpp + - apt install -y clang-12 + - mkdir -p build_cpp + - mkdir -p install_cpp + - cd build_cpp + - export CXX=/usr/bin/clang++-12 + - cmake -DCMAKE_INSTALL_PREFIX:PATH=../install_cpp -DCMAKE_BUILD_TYPE=Debug -DWERROR=ON -DCOVERAGE=ON .. + - make -j4 all install + +build:ubuntu_cpp_clang15: + stage: build + needs: [] + tags: + - docker + + script: + # Download dependencies + - DEPENDENCY_JOB="build:ubuntu_cpp" + # aidge_core + - DEPENDENCY_NAME="aidge_core" + - !reference [.download_dependency, script] + # aidge_backend_cpu + - DEPENDENCY_NAME="aidge_backend_cpu" + - !reference [.download_dependency, script] + + # Build current module + - export CMAKE_PREFIX_PATH=../install_cpp + - apt install -y clang-15 + - mkdir -p build_cpp + - mkdir -p install_cpp + - cd build_cpp + - export CXX=/usr/bin/clang++-15 + - cmake -DCMAKE_INSTALL_PREFIX:PATH=../install_cpp -DCMAKE_BUILD_TYPE=Debug -DWERROR=ON -DCOVERAGE=ON .. + - make -j4 all install + +build:ubuntu_python: + stage: build + needs: [] + tags: + - docker + + script: + # Download dependencies + - DEPENDENCY_JOB="build:ubuntu_python" + # aidge_core + - DEPENDENCY_NAME="aidge_core" + - !reference [.download_dependency, script] + # aidge_backend_cpu + - DEPENDENCY_NAME="aidge_backend_cpu" + - !reference [.download_dependency, script] + + - python3 -m pip install virtualenv + - virtualenv venv + - source venv/bin/activate + - python3 -m pip install -r requirements.txt + - python3 -m pip install . + + artifacts: + expire_in: 1 week + paths: + - venv/ + +# build:windows_cpp: +# stage: build +# needs: [] +# tags: +# - windows + +# image: buildtools +# before_script: +# # Install Chocolatey +# - Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) +# # Install dependencies +# - choco install cmake.install --installargs '"ADD_CMAKE_TO_PATH=System"' -Y +# - choco install git -Y +# - choco install python -Y +# - choco install cuda -Y +# # Update PATH +# - $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") +# script: +# # Download dependencies +# # aidge_core +# - 'curl "https://gitlab.eclipse.org/api/v4/projects/5139/jobs/artifacts/main/download?job=build:windows_cpp" -o build_artifacts.zip' +# - Expand-Archive -Path .\build_artifacts.zip -DestinationPath . -Force +# - Remove-Item .\build_cpp\ -Recurse +# # aidge_backend_cpu +# - 'curl "https://gitlab.eclipse.org/api/v4/projects/5140/jobs/artifacts/master/download?job=build:windows_cpp" -o build_artifacts.zip' +# - Expand-Archive -Path .\build_artifacts.zip -DestinationPath . -Force +# - Remove-Item .\build_cpp\ -Recurse + +# - $env:CMAKE_PREFIX_PATH = '../install_cpp' +# - mkdir -p build_cpp +# - cd build_cpp +# - cmake -DCMAKE_INSTALL_PREFIX:PATH=../install_cpp -DCMAKE_BUILD_TYPE=Debug .. +# - cmake --build . -j2 +# - cmake --install . --config Debug + +# artifacts: +# expire_in: 1 week +# paths: +# - build_cpp/ +# - install_cpp/ + +# build:windows_python: +# stage: build +# needs: [] +# tags: +# - windows + +# image: buildtools +# before_script: +# # Install Chocolatey +# - Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) +# # Install dependencies +# - choco install cmake.install --installargs '"ADD_CMAKE_TO_PATH=System"' -Y +# - choco install git -Y +# - choco install python -Y +# - choco install cuda -Y +# # Update PATH +# - $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") +# script: +# # Download dependencies +# # aidge_core (Python) +# - 'curl "https://gitlab.eclipse.org/api/v4/projects/5139/jobs/artifacts/main/download?job=build:windows_python" -o build_artifacts.zip' +# - Expand-Archive -Path .\build_artifacts.zip -DestinationPath . -Force +# # aidge_backend_cpu (Python) +# - 'curl "https://gitlab.eclipse.org/api/v4/projects/5140/jobs/artifacts/master/download?job=build:windows_python" -o build_artifacts.zip' +# - Expand-Archive -Path .\build_artifacts.zip -DestinationPath . -Force + +# - python -m pip install virtualenv +# - virtualenv venv +# - venv\Scripts\Activate.ps1 +# - python -m pip install -r requirements.txt +# - python -m pip install . +# artifacts: +# expire_in: 1 week +# paths: +# - venv/ diff --git a/.gitlab/ci/coverage.gitlab-ci.yml b/.gitlab/ci/coverage.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..33547fc3f52771c456fba3d34a6e8d96eebafd8a --- /dev/null +++ b/.gitlab/ci/coverage.gitlab-ci.yml @@ -0,0 +1,41 @@ +coverage:ubuntu_cpp: + stage: coverage + needs: ["build:ubuntu_cpp"] + tags: + - docker + script: + - cd build_cpp + - ctest --output-on-failure + # HTML report for visualization + - gcovr --html-details --exclude-unreachable-branches -o coverage.html --root ${CI_PROJECT_DIR} --filter '\.\./include/' --filter '\.\./src/' + # Coberta XML report for Gitlab integration + - gcovr --xml-pretty --exclude-unreachable-branches --print-summary -o coverage.xml --root ${CI_PROJECT_DIR} --filter '\.\./include/' --filter '\.\./src/' + coverage: /^\s*lines:\s*\d+.\d+\%/ + artifacts: + name: ${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHA} + expire_in: 2 days + reports: + coverage_report: + coverage_format: cobertura + path: build_cpp/coverage.xml + +coverage:ubuntu_python: + stage: coverage + needs: ["build:ubuntu_python"] + tags: + - docker + script: + - source venv/bin/activate + - python3 -m pip install numpy coverage + - cd ${CI_PROJECT_NAME} + # Retrieve the installation path of the module, since it is installed with pip. + - export MODULE_LOCATION=`python -c "import ${CI_PROJECT_NAME} as _; print(_.__path__[0])"` + - python3 -m coverage run --source=$MODULE_LOCATION -m unittest discover -s unit_tests/ -v -b + - python3 -m coverage report + - python3 -m coverage xml + coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/' + artifacts: + reports: + coverage_report: + coverage_format: cobertura + path: ${CI_PROJECT_NAME}/coverage.xml diff --git a/.gitlab/ci/test.gitlab-ci.yml b/.gitlab/ci/test.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..5176feb0a2834f85fdea1b9a0922d0cf334e5d5e --- /dev/null +++ b/.gitlab/ci/test.gitlab-ci.yml @@ -0,0 +1,49 @@ +test:ubuntu_cpp: + stage: test + needs: ["build:ubuntu_cpp"] + tags: + - docker + script: + - cd build_cpp + - ctest --output-junit ctest-results.xml --output-on-failure + artifacts: + reports: + junit: build_cpp/ctest-results.xml + +test:ubuntu_python: + stage: test + needs: ["build:ubuntu_python"] + tags: + - docker + script: + - source venv/bin/activate + - cd ${CI_PROJECT_NAME} + - python3 -m pip install numpy unittest-xml-reporting + - python3 -m pip list + # Run on discovery all tests located in core/unit_tests/python + - python3 -m xmlrunner discover -s unit_tests/ -v -b --output-file xmlrunner-results.xml + artifacts: + reports: + junit: ${CI_PROJECT_NAME}/xmlrunner-results.xml + +# test:windows_cpp: +# stage: test +# needs: ["build:windows_cpp"] +# tags: +# - windows +# image: buildtools +# before_script: +# # Install Chocolatey +# - Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) +# # Install dependencies +# - choco install cmake.install --installargs '"ADD_CMAKE_TO_PATH=System"' -Y +# - choco install python -Y +# # Update PATH +# - $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") +# script: +# - cd build_cpp +# - ctest --output-junit ctest-results.xml --output-on-failure +# artifacts: +# reports: +# junit: build_cpp/ctest-results.xml +