<commit_before># vim: set expandtab shiftwidth=2 tabstop=8:
libratbag_references:
  default_settings: &default_settings
    working_directory: ~/libratbag
    environment:
      LANG: C.UTF-8
  build_default: &build_default
    name: Build
    command: |
      rm -rf build
      meson build ${MESON_PARAMS}
      meson configure build
      ninja -v -C build ${NINJA_ARGS}
    environment:
      MESON_PARAMS: --prefix=/usr
  build_buildtype_plain: &build_buildtype_plain
    run:
      <<: *build_default
      name: Build with buildtype plain
      environment:
        MESON_PARAMS: --prefix=/usr -Dbuildtype=plain
  build_buildtype_release: &build_buildtype_release
    run:
      <<: *build_default
      name: Build with buildtype release
      environment:
        MESON_PARAMS: --prefix=/usr -Dbuildtype=release
  build_and_test: &build_and_test
    run:
      <<: *build_default
      name: Build and test
      environment:
        NINJA_ARGS: test
  build_with_docs: &build_with_docs
    run:
      <<: *build_default
      name: Build with documentation
      environment:
        MESON_PARAMS: -Ddocumentation=true
  install: &install
    run:
      name: Installing
      command: ninja -C build install
  check_install: &check_install
    run:
      name: Checking installation
      command: |
        PREFIX=/usr/local/
        diff -u <(cd data/devices; ls *.device) <(cd $PREFIX/share/libratbag; ls *.device)
  check_uninstall: &check_uninstall
    run:
      name: Checking if any files are left after uninstall
      command: |
        PREFIX=/root/test_install
        # workaround until https://github.com/mesonbuild/meson/pull/2033 is merged
        # and a new release appears
        git clone https://github.com/whot/meson -b wip/remove-directories-on-uninstall
        ./meson/meson.py build_install --prefix=$PREFIX
        ninja -C build_install install
        ninja -C build_install uninstall
        if [ -d $PREFIX ]
        then
          tree $PREFIX
          exit 1
        fi
  export_logs: &export_logs
    store_artifacts:
      path: ~/libratbag/build/meson-logs
  start_dbus: &start_dbus
    run:
      name: Start dbus daemon
      command: |
        mkdir /run/dbus
        /usr/bin/dbus-daemon --system --fork

fedora_prep_cache: &fedora_prep_cache
  <<: *default_settings
  steps:
    - run:
        name: Initializing Fedora dnf cache
        command: dnf install -y --downloadonly libsolv tree git gcc gcc-c++ meson check-devel libudev-devel libevdev-devel valgrind python3-gobject python3-evdev glib2-devel python3-lxml libunistring-devel dbus-daemon json-glib-devel diffutils
    - persist_to_workspace:
        root: /var/cache/
        paths:
          - dnf/*

fedora_fetch_cache: &fedora_fetch_cache
  attach_workspace:
    at: /var/cache/

fedora_install: &fedora_install
  run:
    name: Install prerequisites
    command: |
        echo keepcache=1 >> /etc/dnf/dnf.conf
        dnf upgrade -y libsolv
        dnf install -y tree git gcc gcc-c++ meson check-devel libudev-devel libevdev-devel valgrind python3-gobject python3-evdev glib2-devel python3-lxml python3-devel swig libunistring-devel dbus-daemon json-glib-devel diffutils
        sed -i 's/systemd//' /etc/nsswitch.conf

fedora_settings: &fedora_settings
  <<: *default_settings
  steps:
    - *fedora_fetch_cache
    - *fedora_install
    - checkout
    - *start_dbus
    - *build_and_test
    - *install
    - *check_install
    - *check_uninstall
    - *build_buildtype_plain
    - *build_buildtype_release
    - *export_logs


ubuntu_settings: &ubuntu_settings
  <<: *default_settings
  steps:
    - run:
        name: Install prerequisites
        command: |
          apt-get update
          apt-get install -y software-properties-common
          apt-get remove -y libnss-systemd
          add-apt-repository universe
          apt-get update
          apt-get install -y tree git gcc g++ pkg-config meson check libudev-dev libevdev-dev libsystemd-dev valgrind python3-gi python3-evdev libglib2.0-dev python3-lxml python3-dev swig systemd libunistring-dev libjson-glib-dev
    - checkout
    - *start_dbus
    - *build_and_test
    - *install
    - *check_install
    - *check_uninstall
    - *build_buildtype_plain
    - *build_buildtype_release
    - *export_logs

doc_build: &doc_build
  <<: *default_settings
  steps:
    - *fedora_fetch_cache
    - *fedora_install
    - run:
        name: Install documentation build-deps
        command: dnf install -y python3-sphinx python3-sphinx_rtd_theme
    - checkout
    - *build_with_docs
    - *export_logs
    - store_artifacts:
        path: ~/libratbag/build/doc/html
    - persist_to_workspace:
        root: build
        paths:
          - doc/html/*
<commit_msg>CircleCI: use variables for dependencies<commit_after># vim: set expandtab shiftwidth=2 tabstop=8:
libratbag_references:
  build_dependencies: &build_dependencies
    FEDORA_DEP_BUILD: gcc gcc-c++ meson dbus-daemon glib2-devel json-glib-devel libevdev-devel libudev-devel libunistring-devel python3-devel python3-evdev swig
    FEDORA_DEP_TEST: check-devel python3-gobject python3-lxml valgrind
    FEDORA_DEP_DOC: python3-sphinx python3-sphinx_rtd_theme
    UBUNTU_DEP_BUILD: gcc g++ meson pkg-config systemd libevdev-dev libglib2.0-dev libjson-glib-dev libsystemd-dev libudev-dev libunistring-dev python3-dev python3-evdev swig
    UBUNTU_DEP_TEST: check python3-gi python3-lxml valgrind
  default_settings: &default_settings
    working_directory: ~/libratbag
    environment:
      LANG: C.UTF-8
  build_default: &build_default
    name: Build
    command: |
      rm -rf build
      meson build ${MESON_PARAMS}
      meson configure build
      ninja -v -C build ${NINJA_ARGS}
    environment:
      MESON_PARAMS: --prefix=/usr
  build_buildtype_plain: &build_buildtype_plain
    run:
      <<: *build_default
      name: Build with buildtype plain
      environment:
        MESON_PARAMS: --prefix=/usr -Dbuildtype=plain
  build_buildtype_release: &build_buildtype_release
    run:
      <<: *build_default
      name: Build with buildtype release
      environment:
        MESON_PARAMS: --prefix=/usr -Dbuildtype=release
  build_and_test: &build_and_test
    run:
      <<: *build_default
      name: Build and test
      environment:
        NINJA_ARGS: test
  build_with_docs: &build_with_docs
    run:
      <<: *build_default
      name: Build with documentation
      environment:
        MESON_PARAMS: -Ddocumentation=true
  install: &install
    run:
      name: Installing
      command: ninja -C build install
  check_install: &check_install
    run:
      name: Checking installation
      command: |
        PREFIX=/usr/local/
        diff -u <(cd data/devices; ls *.device) <(cd $PREFIX/share/libratbag; ls *.device)
  check_uninstall: &check_uninstall
    run:
      name: Checking if any files are left after uninstall
      command: |
        PREFIX=/root/test_install
        meson build_install --prefix=$PREFIX
        ninja -C build_install install
        ninja -C build_install uninstall
        if [ -d $PREFIX ]
        then
          tree $PREFIX
          exit 1
        fi
  export_logs: &export_logs
    store_artifacts:
      path: ~/libratbag/build/meson-logs
  start_dbus: &start_dbus
    run:
      name: Start dbus daemon
      command: |
        mkdir /run/dbus
        /usr/bin/dbus-daemon --system --fork

fedora_prep_cache: &fedora_prep_cache
  <<: *default_settings
  steps:
    - run:
        name: Initializing Fedora dnf cache
        command: dnf install -y --downloadonly git ${FEDORA_DEP_BUILD} ${FEDORA_DEP_TEST} ${FEDORA_DEP_DOC}
    - persist_to_workspace:
        root: /var/cache/
        paths:
          - dnf/*
  environment:
    *build_dependencies

fedora_fetch_cache: &fedora_fetch_cache
  attach_workspace:
    at: /var/cache/

fedora_install: &fedora_install
  run:
    name: Install prerequisites
    command: |
        echo keepcache=1 >> /etc/dnf/dnf.conf
        dnf install -y git ${FEDORA_DEP_BUILD} ${FEDORA_DEP_TEST}
        sed -i 's/systemd//' /etc/nsswitch.conf

fedora_settings: &fedora_settings
  <<: *default_settings
  steps:
    - *fedora_fetch_cache
    - *fedora_install
    - checkout
    - *start_dbus
    - *build_and_test
    - *install
    - *check_install
    - *check_uninstall
    - *build_buildtype_plain
    - *build_buildtype_release
    - *export_logs
  environment:
    *build_dependencies

ubuntu_settings: &ubuntu_settings
  <<: *default_settings
  steps:
    - run:
        name: Install prerequisites
        command: |
          apt-get update
          apt-get install -y software-properties-common
          apt-get remove -y libnss-systemd
          add-apt-repository universe
          apt-get update
          apt-get install -y git ${UBUNTU_DEP_BUILD} ${UBUNTU_DEP_TEST}
    - checkout
    - *start_dbus
    - *build_and_test
    - *install
    - *check_install
    - *check_uninstall
    - *build_buildtype_plain
    - *build_buildtype_release
    - *export_logs
  environment:
    *build_dependencies

doc_build: &doc_build
  <<: *default_settings
  steps:
    - *fedora_fetch_cache
    - *fedora_install
    - run:
        name: Install documentation build-deps
        command: dnf install -y ${FEDORA_DEP_DOC}
    - checkout
    - *build_with_docs
    - *export_logs
    - store_artifacts:
        path: ~/libratbag/build/doc/html
    - persist_to_workspace:
        root: build
        paths:
          - doc/html/*
  environment:
    *build_dependencies

{'fraction_non_alphanumeric': 0.08492747529955855, 'fraction_numerical': 0.004624763506411604, 'mean_word_length': 2.526686434395849, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 5}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4470428', 'n_tokens_mistral': 3257, 'n_tokens_neox': 3125, 'n_words': 708}