Skip to content
Snippets Groups Projects
.gitlab-ci.yml 6.45 KiB
Newer Older
Wuttke, Joachim's avatar
Wuttke, Joachim committed
stages:
  - build

# global variables
variables:
  GIT_DEPTH: "1"

.linux_build: &linux_build
  stage: build
  artifacts:
    paths:
    - build/installer/BornAgain*.sh
    - build/py/wheel/manylinux/*.whl
    expire_in: 3 days

native_Debian:
Wuttke, Joachim's avatar
Wuttke, Joachim committed
  tags:
  <<: *linux_build
  before_script: &native_before
    - export CC=gcc; export CXX=g++
    - export CHECK_FLAGS="-DZERO_TOLERANCE=ON -DDEVELOPER_CHECKS=ON"
AlQuemist's avatar
AlQuemist committed
    # avoid using the default Debian Qt framework
    - QTCMAKE="/usr/local/Qt6/6.2.3/gcc_64/lib/cmake"
Wuttke, Joachim's avatar
Wuttke, Joachim committed
    - cmake --version
  script: &native_scr
Wuttke, Joachim's avatar
Wuttke, Joachim committed
    - mkdir build
    - cd build
    # NOTE: CMake's Ninja generator should not be used with CMake < 3.26 due to internal bugs.
    - time cmake .. -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_PREFIX_PATH="$QTCMAKE" -DBA_PY_PACK=ON $CHECK_FLAGS
    - time make -j16
    - time make ba_wheel
    - time ctest -j16 --output-on-failure
Wuttke, Joachim's avatar
Wuttke, Joachim committed
    - time cpack -V -B ./installer
.compile_dependency: &compile_dependency
Wuttke, Joachim's avatar
Wuttke, Joachim committed
  - mkdir build
  - cd build
  - cmake .. -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
  - make -j4
  - ctest
  - make install

.debian_oldstable_py311: &debian_oldstable
  rules:
    - if: $CI_PIPELINE_SOURCE == "schedule"
    - LinuxDocker
  <<: *linux_build
Wuttke, Joachim's avatar
Wuttke, Joachim committed
  image: scg-debian-oldstable:latest
Wuttke, Joachim's avatar
Wuttke, Joachim committed
  script: &docker_build
    - export CHECK_FLAGS=""
    - ORIGINAL_DIR=$(pwd)
    - export CC=gcc; export CXX=g++
    - export MPLBACKEND=Agg
    - ldd --version
    - cmake --version
    - eval "$(pyenv init -)"
Wuttke, Joachim's avatar
Wuttke, Joachim committed
    - python --version
Wuttke, Joachim's avatar
Wuttke, Joachim committed
    - cd /libheinz
Wuttke, Joachim's avatar
Wuttke, Joachim committed
    - *compile_dependency
Wuttke, Joachim's avatar
Wuttke, Joachim committed
    - cd /libcerf
Wuttke, Joachim's avatar
Wuttke, Joachim committed
    - *compile_dependency
Wuttke, Joachim's avatar
Wuttke, Joachim committed
    - cd /libformfactor
Wuttke, Joachim's avatar
Wuttke, Joachim committed
    - *compile_dependency
    - cd $ORIGINAL_DIR
Wuttke, Joachim's avatar
Wuttke, Joachim committed
    - *native_scr
debian_oldstable_py311:
  <<: *debian_oldstable
  before_script:
    - pyenv global 3.11

debian_oldstable_py310:
  <<: *debian_oldstable
  before_script:
    - pyenv global 3.10

debian_oldstable_py39:
  <<: *debian_oldstable
  before_script:
    - pyenv global 3.9

debian_oldstable_py38:
  <<: *debian_oldstable
  before_script:
    - pyenv global 3.8

  rules:
  - if: '$CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH'
  before_script: *native_before
  stage: build
  script:
    - hugo version
    - mkdir build
    - cd build
Wuttke, Joachim's avatar
Wuttke, Joachim committed
    - time cmake .. -GNinja -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DBA_GUI=OFF
    - time ninja -j8
    - time ninja -j8 webdoc
Wuttke, Joachim's avatar
Wuttke, Joachim committed
    - rm -rf ~www/ba/git-main/hugo-public
Wuttke, Joachim's avatar
Wuttke, Joachim committed
    - cp -r ../hugo/public ~www/ba/git-main/hugo-public
  - mac_x64_cloud
  stage: build
  before_script:
Wuttke, Joachim's avatar
Wuttke, Joachim committed
    - NPROC=12 # number of logical CPUs obtained from `sysctl hw.logicalcpu`
    - BREWDIR="/opt/homebrew-x86"
    - QTDIR="$BREWDIR/Cellar/qt/6.6.0"
    - PYPLAT="/Users/qtisas/.pyenv/versions/3.11.6/"
    - PATH="$BREWDIR:$PATH"
  script:  &mac_script
    - OPTDIR="/Users/Shared/Software/scg"
    - CCACHE="$BREWDIR/bin/ccache"
    - mkdir build
    - cd build
    - cmake --version
Wuttke, Joachim's avatar
Wuttke, Joachim committed
    - >
      cmake .. -DCMAKE_PREFIX_PATH="$OPTDIR;$QTDIR/lib/cmake;$BREWDIR" -DCMAKE_BUILD_TYPE=Release
      -DPython3_ROOT_DIR="$PYPLAT" -DCMAKE_CXX_COMPILER_LAUNCHER="$CCACHE" -DBA_APPLE_BUNDLE=ON
      -DCMAKE_OSX_DEPLOYMENT_TARGET=11 -DBA_PY_PACK=ON -DZERO_TOLERANCE=ON
    - make -j$NPROC
    - ctest -j3 --output-on-failure
    - make ba_wheel
Wuttke, Joachim's avatar
Wuttke, Joachim committed
    - cpack -V -B ./installer
  artifacts: &mac_artifacts
    paths:
    - build/py/wheel/*.whl
    expire_in: 10 days

# mac_arm:
#   tags:
#   - mac_arm
#   stage: build
#   before_script:
#     - NPROC=14 # number of logical CPUs obtained from `sysctl hw.logicalcpu`
#     - BREWDIR="/opt/homebrew"
#     - QTDIR="$BREWDIR/opt/qt"
#     - PYPLAT="/Users/qtisas/.pyenv/versions/3.11.6/"
#   script: *mac_script
#   artifacts: *mac_artifacts
# To test the GitLab process _locally_ on MS-Windows with powershell (pwsh),
# go to the root Git directory, and run:
# C:\GitLab-Runner\gitlab-runner.exe exec shell --shell pwsh --builds-dir <gitlab build-dir> <job-name>

windows:
  tags:
    - Windows
  stage: build
  cache:
  #  key: build-cache
  #  paths:
  #    - build/
  script:
    - $OPT_DIR = "C:/opt/x64"
    - $BOOST_DIR = "$OPT_DIR/boost_current"
    - $QT_MSVC_DIR = "C:/Qt/6.2.4/msvc2019_64"
    - $QTCMake_DIR = "$QT_MSVC_DIR/lib/cmake"
    - $PY_PLATFORM_DIR = "C:/Users/admin/.pyenv/pyenv-win/versions/3.11.5/"
    - $BUILD_DIR = "build"
    # list powershell properties
    - echo "# Path '<$Env:Path>'"
    - echo "# PythonPath '<$Env:PYTHONPATH>'"
    - echo "# Powershell <$PSHOME>`n  PS Profile <$PROFILE>`n  PS Command-Path <$PSCOMMANDPATH>"
    # Visual Studio path <https://github.com/microsoft/vswhere/wiki/Find-VC>
Wuttke, Joachim's avatar
Wuttke, Joachim committed
    - >
      $vsPath = &"${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
      -latest -products *
      -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationpath
    - echo "Microsoft Visual Studio path = '$vsPath'"
Wuttke, Joachim's avatar
Wuttke, Joachim committed
    - >
      Import-Module
      (Get-ChildItem $vsPath -Recurse -File -Filter Microsoft.VisualStudio.DevShell.dll).FullName
    - Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments '-arch=x64'
    - Set-Item -Path "env:CC" -Value "cl.exe"
    - Set-Item -Path "env:CXX" -Value "cl.exe"
    # list all environmental variables
    - 'dir Env:'
    # make the CMake build directory
    - if($CI_PIPELINE_SOURCE -eq "schedule") { mkdir -Force $BUILD_DIR; echo "scheduled build" }
    - if(!(Test-Path -path $BUILD_DIR)) { mkdir -Force $BUILD_DIR; echo "build from scratch" }
    - cd $BUILD_DIR
    - Remove-Item CM* -Recurse
    - pwd
    # configure, make, test, pack
    - cmake --version
Wuttke, Joachim's avatar
Wuttke, Joachim committed
    - >
      cmake .. -G "Ninja" -DCMAKE_BUILD_TYPE=Release
Wuttke, Joachim's avatar
Wuttke, Joachim committed
      -DCMAKE_PREFIX_PATH="$OPT_DIR;$QTCMake_DIR;$BOOST_DIR"
      -DPython3_ROOT_DIR="$PY_PLATFORM_DIR" -DBA_PY_PACK=ON
Wuttke, Joachim's avatar
Wuttke, Joachim committed
      -DCPACK_IFW_ROOT="C:/Qt/Tools/QtInstallerFramework/4.5"
      -DCMAKE_C_COMPILER_LAUNCHER="buildcache.exe"
      -DCMAKE_CXX_COMPILER_LAUNCHER="buildcache.exe"
Wuttke, Joachim's avatar
Wuttke, Joachim committed
    - >
      if($CI_PIPELINE_SOURCE -eq "schedule")
      { cmake --build . --target clean; echo "redundant target purge done" }
    - cmake --build . -j20 --config Release
    - cmake --build . --config Release --target ba_wheel
Wuttke, Joachim's avatar
Wuttke, Joachim committed
    - >
      $env:PYTHONPATH += "$CI_PROJECT_DIR/build/lib";
      $env:PATH = "$QT_MSVC_DIR/bin;$env:PATH";
      ctest -C Release --parallel 20 --output-on-failure
Wuttke, Joachim's avatar
Wuttke, Joachim committed
    - cpack -V -C Release -B ./installer
  artifacts:
    paths:
    - build/installer/BornAgain*.exe
    - build/py/wheel/*.whl
    expire_in: 10 days