<commit_before>env:
  BUILD_DIR: build

container:
  memory: 12
  cpu: 4

# We store common commands here, so we can reference them in the build jobs below.
commands:
  - &print_cmake_options |
      printf '—— CMake Config ——\n'
      for option; do printf '%s\n' "$option"; done
  - &generate | # We need to specify the source directory (`.`) explicitly for Alpine linux (`🔗 Check`).
    cmake "$@" -G Ninja -B "$BUILD_DIR" .
  - &build cmake --build "$BUILD_DIR"
  - &install output="$(cmake --build "$BUILD_DIR" --target install 2>&1)" || printf '%s' "$output"
  - &run_tests | # Run tests
    if [ "$ENABLE_ASAN" = 'ON' ]; then
      cmake --build "$BUILD_DIR" --target run_nocheckshell
    else
      [ "$BUILD_FULL" = 'ON' ] && KDB=kdb-full || KDB=kdb
      # While the command `|| false` is in theory unnecessary, somehow the whole `if`-statement always reports success,
      # if we do not add the alternative `false`.
      cmake --build "$BUILD_DIR" --target run_all && "$KDB" run_all || false
    fi

bsd_task:
  matrix:

    - name: 😈 FreeBSD 11
      freebsd_instance:
        image_family: freebsd-11-4

    - name: 😈 FreeBSD 12
      freebsd_instance:
        image_family: freebsd-12-2

    - name: 😈 ASAN
      freebsd_instance:
        image_family: freebsd-12-2
      env:
        ENABLE_ASAN: ON

  install_script:
    - >
      pkg install -y
      bison
      cmake
      flex
      git
      libgit2
      llvm11
      ninja
      yajl
      yaml-cpp

  script:
    - > # We use `-std=c11`, since the header `math.h` on FreeBSD requires C11 features
      set --
      -DCMAKE_C_COMPILER=clang11
      -DCMAKE_CXX_COMPILER=clang++11
      -DBINDINGS='ALL;-io_glib'
      -DINSTALL_SYSTEM_FILES=ON
      -DCMAKE_SKIP_INSTALL_RPATH=ON
      -DCOMMON_FLAGS=-Werror
      -DC_STD=-std=c11
      -DENABLE_ASAN="${ENABLE_ASAN:-OFF}"
      -DPLUGINS='ALL'
      -DTARGET_PLUGIN_FOLDER=''
    - *print_cmake_options
    - *generate
    - *build
    - *install

  tests_script:
    # Work around stalled process plugin and library problems on FreeBSD: https://issues.libelektra.org/2323
    - sudo mount -t fdescfs fdesc /dev/fd
    - *run_tests

mac_task:
  env:
    INSTALL_DIR: install
    HOMEBREW_NO_INSTALL_CLEANUP: 1

  matrix:

    - name: 🍎 Clang
      osx_instance:
        image: catalina-xcode
      env:
        ENABLE_LOGGER: ON
        TOOLS: ALL;web
        PLUGINS: ALL;-curlget # The curlget tests fail: https://github.com/ElektraInitiative/libelektra/issues/3382

    - name: 🍎 Clang ASAN
      osx_instance:
        image: catalina-xcode
      env:
        ASAN_OPTIONS: 'detect_leaks=1'
        BINDINGS: cpp
        ENABLE_ASAN: ON
        TOOLS: kdb
        PLUGINS: ALL;-curlget # The curlget tests fail: https://github.com/ElektraInitiative/libelektra/issues/3382
        DBUS_BUG: ON # dbus tests on cirrus are failing: https://github.com/ElektraInitiative/libelektra/issues/3635

    - name: 🍎 FULL
      osx_instance:
        image: catalina-xcode
      env:
        BUILD_FULL: ON
        BUILD_SHARED: OFF
        PLUGINS: ALL;-curlget # The curlget tests fail: https://github.com/ElektraInitiative/libelektra/issues/3382

    - name: 🍎 MMap
      osx_instance:
        image: catalina-xcode
      env:
        KDB_DEFAULT_STORAGE: mmapstorage
        KDB_DB_FILE: default.mmap
        KDB_DB_INIT: elektra.mmap
        PLUGINS: ALL;-curlget # The curlget tests fail: https://github.com/ElektraInitiative/libelektra/issues/3382

  install_script:
    - | # Install Homebrew formulas
      brew update
      brew config
      brew install openjdk
      brew install antlr
      brew install antlr4-cpp-runtime
      brew install augeas
      brew install bison
      brew install boost
      brew install clang-format
      brew install dbus
      brew install discount
      brew install doxygen
      brew install flex
      brew install glib
      brew install go
      brew install gpgme
      brew install graphviz
      brew install libev
      brew install libgcrypt
      brew install libgit2
      brew install libuv
      brew install llvm
      brew install lua
      brew install maven
      brew install moreutils
      brew install ninja
      brew install oclint/formulae/oclint
      brew install npm
      brew install openssl
      brew install pkg-config
      brew install qt
      brew install shfmt
      brew install swig
      brew install tree
      brew install xerces-c
      brew install yajl
      brew install yaml-cpp
      brew install zeromq
    - > # Try to install `checkbashisms` (The file server that hosts the package is unfortunately quite unreliable.)
      brew install checkbashisms || >&2 printf 'Warning: Unable to install `checkbashims`\n'
    - | # Start D-Bus session bus
      brew tap homebrew/services
      brew update # Work around for [Homebrew Services issue 206](https://github.com/Homebrew/homebrew-services/issues/206)
      brew services restart dbus
    - | # Install Python
      brew install python@3.8 || brew upgrade python@3.8
      export PATH="/usr/local/opt/python@3.8/bin:$PATH"
    - | # Install Python packages
      pip3 install cmake-format[yaml]==0.6.3
    - | # Install Ruby (We use the Homebrew version of Ruby to install gems, since compiling `ronn` fails with the macOs version of Ruby.)
      brew install ruby
      export PATH="/usr/local/opt/ruby/bin:/usr/local/lib/ruby/gems/3.0.0/bin:$PATH"
    - | # Install Ruby gems
      sudo gem install ronn test-unit --no-document<commit_msg>cirrus: upgrade macOS images and test dbus session<commit_after>env:
  BUILD_DIR: build

container:
  memory: 12
  cpu: 4

# We store common commands here, so we can reference them in the build jobs below.
commands:
  - &print_cmake_options |
      printf '—— CMake Config ——\n'
      for option; do printf '%s\n' "$option"; done
  - &generate | # We need to specify the source directory (`.`) explicitly for Alpine linux (`🔗 Check`).
    cmake "$@" -G Ninja -B "$BUILD_DIR" .
  - &build cmake --build "$BUILD_DIR"
  - &install output="$(cmake --build "$BUILD_DIR" --target install 2>&1)" || printf '%s' "$output"
  - &run_tests | # Run tests
    if [ "$ENABLE_ASAN" = 'ON' ]; then
      cmake --build "$BUILD_DIR" --target run_nocheckshell
    else
      [ "$BUILD_FULL" = 'ON' ] && KDB=kdb-full || KDB=kdb
      # While the command `|| false` is in theory unnecessary, somehow the whole `if`-statement always reports success,
      # if we do not add the alternative `false`.
      cmake --build "$BUILD_DIR" --target run_all && "$KDB" run_all || false
    fi

bsd_task:
  matrix:

    - name: 😈 FreeBSD 11
      freebsd_instance:
        image_family: freebsd-11-4

    - name: 😈 FreeBSD 12
      freebsd_instance:
        image_family: freebsd-12-2

    - name: 😈 ASAN
      freebsd_instance:
        image_family: freebsd-12-2
      env:
        ENABLE_ASAN: ON

  install_script:
    - >
      pkg install -y
      bison
      cmake
      flex
      git
      libgit2
      llvm11
      ninja
      yajl
      yaml-cpp

  script:
    - > # We use `-std=c11`, since the header `math.h` on FreeBSD requires C11 features
      set --
      -DCMAKE_C_COMPILER=clang11
      -DCMAKE_CXX_COMPILER=clang++11
      -DBINDINGS='ALL;-io_glib'
      -DINSTALL_SYSTEM_FILES=ON
      -DCMAKE_SKIP_INSTALL_RPATH=ON
      -DCOMMON_FLAGS=-Werror
      -DC_STD=-std=c11
      -DENABLE_ASAN="${ENABLE_ASAN:-OFF}"
      -DPLUGINS='ALL'
      -DTARGET_PLUGIN_FOLDER=''
    - *print_cmake_options
    - *generate
    - *build
    - *install

  tests_script:
    # Work around stalled process plugin and library problems on FreeBSD: https://issues.libelektra.org/2323
    - sudo mount -t fdescfs fdesc /dev/fd
    - *run_tests

mac_task:
  env:
    INSTALL_DIR: install
    HOMEBREW_NO_INSTALL_CLEANUP: 1

  matrix:

    - name: 🍎 Clang
      osx_instance:
        image: big-sur-xcode
      env:
        ENABLE_LOGGER: ON
        TOOLS: ALL;web
        PLUGINS: ALL;-curlget # The curlget tests fail: https://github.com/ElektraInitiative/libelektra/issues/3382

    - name: 🍎 Clang ASAN
      osx_instance:
        image: big-sur-xcode
      env:
        ASAN_OPTIONS: 'detect_leaks=1'
        BINDINGS: cpp
        ENABLE_ASAN: ON
        TOOLS: kdb
        PLUGINS: ALL;-curlget # The curlget tests fail: https://github.com/ElektraInitiative/libelektra/issues/3382
        DBUS_BUG: ON # dbus tests on cirrus are failing: https://github.com/ElektraInitiative/libelektra/issues/3635

    - name: 🍎 FULL
      osx_instance:
        image: big-sur-xcode
      env:
        BUILD_FULL: ON
        BUILD_SHARED: OFF
        PLUGINS: ALL;-curlget # The curlget tests fail: https://github.com/ElektraInitiative/libelektra/issues/3382

    - name: 🍎 MMap
      osx_instance:
        image: big-sur-xcode
      env:
        KDB_DEFAULT_STORAGE: mmapstorage
        KDB_DB_FILE: default.mmap
        KDB_DB_INIT: elektra.mmap
        PLUGINS: ALL;-curlget # The curlget tests fail: https://github.com/ElektraInitiative/libelektra/issues/3382

  install_script:
    - | # Install Homebrew formulas
      brew update
      brew config
      brew install openjdk
      brew install antlr
      brew install antlr4-cpp-runtime
      brew install augeas
      brew install bison
      brew install boost
      brew install clang-format
      brew install dbus
      brew upgrade dbus
      brew install discount
      brew install doxygen
      brew install flex
      brew install glib
      brew install go
      brew install gpgme
      brew install graphviz
      brew install libev
      brew install libgcrypt
      brew install libgit2
      brew install libuv
      brew install llvm
      brew install lua
      brew install maven
      brew install moreutils
      brew install ninja
      brew install oclint/formulae/oclint
      brew install npm
      brew install openssl
      brew install pkg-config
      brew install qt
      brew install shfmt
      brew install swig
      brew install tree
      brew install xerces-c
      brew install yajl
      brew install yaml-cpp
      brew install zeromq
    - > # Try to install `checkbashisms` (The file server that hosts the package is unfortunately quite unreliable.)
      brew install checkbashisms || >&2 printf 'Warning: Unable to install `checkbashims`\n'
    - | # Start D-Bus session bus
      brew tap homebrew/services
      brew update # Work around for [Homebrew Services issue 206](https://github.com/Homebrew/homebrew-services/issues/206)
      brew services restart dbus
      launchctl getenv DBUS_LAUNCHD_SESSION_BUS_SOCKET
      ls -l /private/tmp/com.apple.launchd*
    - | # Install Python
      brew install python@3.8 || brew upgrade python@3.8
      export PATH="/usr/local/opt/python@3.8/bin:$PATH"
    - | # Install Python packages
      pip3 install cmake-format[yaml]==0.6.3
    - | # Install Ruby (We use the Homebrew version of Ruby to install gems, since compiling `ronn` fails with the macOs version of Ruby.)
      brew install ruby
      export PATH="/usr/local/opt/ruby/bin:/usr/local/lib/ruby/gems/3.0.0/bin:$PATH"
    - | # Install Ruby gems
      sudo gem install ronn test-unit --no-document
{'fraction_non_alphanumeric': 0.08822476735862562, 'fraction_numerical': 0.014137437365783823, 'mean_word_length': 2.3394084254556318, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 14, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5056607', 'n_tokens_mistral': 3841, 'n_tokens_neox': 3568, 'n_words': 1039}