<commit_before>version: 2.1

orbs:
  codecov: codecov/codecov@1.1.1

notify:
  webhooks:
    # Unfortunately Gitter messages are too verbose (one five-line message per
    # each job in the build matrix) and thus not wanted
    #- url: https://webhooks.gitter.im/e/cfbadbd34d28708a57c6

executors:
  python-3_06:
    docker:
    - image: python:3.6.15
  python-3_07:
    docker:
    - image: python:3.7.12
  python-3_08:
    docker:
    - image: python:3.8.12
  python-3_09:
    docker:
    - image: python:3.9.8
  python-3_10:
    docker:
    - image: python:3.10.1
  node-10:
    docker:
    - image: node:10.24.0-buster-slim

commands:
  install-base:
    parameters:
      extra:
        type: string
        default: ""
    steps:
    - run:
        name: Update apt and install base packages
        # Git needed always for verifying we have up-to-date generated files
        command: |
          apt update
          apt install -y git << parameters.extra >>

  install-python-deps:
    parameters:
      extra:
        type: string
        default: ""
      matplotlib-version:
        type: string
        default: ""
    steps:
    - run:
        name: Install Python dependencies
        # Pyphen 0.10 has significantly different hyphenation results, staying
        # on an  older version until I can investigate
        # Matplotlib 3.4.1 has different output AGAIN, staying on something
        # older until I can investigate; on Py3.5 there's only 3.0 so this is
        # being set explicitly in py36 and py37 build
        # Attrs 20.3 add some new properties that I need to ignore first, using
        # 19.3 instead
        command: |
          pip install jinja2 pelican Pyphen==0.9.5 Pillow coverage codecov qrcode matplotlib<< parameters.matplotlib-version >> << parameters.extra >>
    - run:
        name: Fix unheard-of cursed issues
        # otherwise i get Error: unsupported locale setting
        # https://stackoverflow.com/a/59637279
        command: |
          apt install -y locales
          sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen
          dpkg-reconfigure --frontend=noninteractive locales
          echo 'export LC_ALL=en_US.UTF-8' >> $BASH_ENV
          echo 'export LC_CTYPE=en_US.UTF-8' >> $BASH_ENV

  test-theme:
    steps:
    - run:
        name: Test the theme
        command: |
          cd pelican-theme
          python -m unittest -v
    - run:
        name: Verify compiled CSS is up-to-date
        command: |
          cd css
          ./postprocess.sh
          git diff --color=always . | cat
          git diff-index --exit-code HEAD -- .

  test-plugins:
    steps:
    - run:
        name: Test plugins
        # TODO: add tests for the math plugin as well
        command: |
          cd plugins
          coverage run -m unittest -v
          cp .coverage ../.coverage.plugins

  test-documentation-themes:
    parameters:
      pybind-version:
        type: string
      python-version:
        type: string
    steps:
    - run:
        name: Install Doxygen
        command: |
          mkdir -p $HOME/bin
          export PATH=$HOME/bin:$PATH
          echo 'export PATH=$HOME/bin:$PATH' >> $BASH_ENV
          wget https://sourceforge.net/projects/doxygen/files/rel-1.8.17/doxygen-1.8.17.linux.bin.tar.gz
          tar -xzf doxygen-1.8.17.linux.bin.tar.gz
          cp doxygen-1.8.17/bin/doxygen $HOME/bin
          doxygen -v
    - run:
        name: Install pybind11
        command: |
          apt update
          apt install -y cmake ninja-build
          wget --no-clobber https://github.com/pybind/pybind11/archive/v<< parameters.pybind-version >>.tar.gz
          tar -xzf v<< parameters.pybind-version >>.tar.gz

          cd pybind11-<< parameters.pybind-version >>
          mkdir -p build && cd build
          cmake .. \
            -DCMAKE_INSTALL_PREFIX=$HOME/pybind<< parameters.pybind-version >> \
            -DPYBIND11_PYTHON_VERSION=<< parameters.python-version >> \
            -DPYBIND11_TEST=OFF \
            -G Ninja
          ninja install
    - run:
        name: Build & test Python bindings code
        command: |
          cd documentation/test_python
          mkdir -p build && cd build
          cmake .. \
            -DCMAKE_PREFIX_PATH=$HOME/pybind<< parameters.pybind-version >> \
            -DPYBIND11_PYTHON_VERSION=<< parameters.python-version >> \
            -G Ninja
          ninja
    - run:
        name: Test documentation themes
        command: |
          cd documentation
          coverage run -m unittest -v
          cp .coverage ../.coverage.documentation

  test-search:
    steps:
    - run:
        name: Install Node.js dependencies
        command: |
          npm install istanbul codecov
    - run:
        name: Test JavaScript search
        command: |
          cd documentation
          node ../node_modules/istanbul/lib/cli.js cover test/test-search.js
    - run:
        name: Verify JavaScript search data are up-to-date
        command: |
          cd documentation/test
          ./populate-js-test-data.py
          git diff --color=always . | cat
          git diff-index --exit-code HEAD -- .

  coverage:
    steps:
    - run:
        name: Collect and upload code coverage
        command: |
          coverage combine
          codecov

jobs:
  py306:
    executor: python-3_06
    steps:
    - install-base:
        extra: graphviz cmake ninja-build wget
    - install-python-deps:
        matplotlib-version: ==3.3.4
        extra: attrs==19.3.0
    - checkout
    - test-theme
    - test-plugins
    - test-documentation-themes:
        python-version: "3.6"
        pybind-version: "2.2.4"
    - coverage

  py307:
    executor: python-3_07
    steps:
    - install-base:
        extra: graphviz cmake ninja-build wget
    - install-python-deps:
        matplotlib-version: ==3.3.4
        extra: attrs==19.3.0
    - checkout
    - test-theme
    - test-plugins
    - test-documentation-themes:
        python-version: "3.7"
        pybind-version: "2.3.0"
    - coverage

  py308:
    executor: python-3_08
    steps:
    - install-base:
        extra: graphviz cmake ninja-build wget
    - install-python-deps:
        matplotlib-version: ==3.3.4
        extra: attrs==19.3.0
    - checkout
    - test-theme
    - test-plugins
    - test-documentation-themes:
        python-version: "3.8"
        # 2.4.1 fixes a Py3.8-specific bug, so the 2.3 versions are probably
        # not wise to use here
        pybind-version: "2.4.3"
    - coverage

  py309:
    executor: python-3_09
    steps:
    - install-base:
        extra: graphviz cmake ninja-build wget
    - install-python-deps:
        matplotlib-version: ==3.3.4
        extra: attrs==19.3.0
    - checkout
    - test-theme
    - test-plugins
    - test-documentation-themes:
        python-version: "3.9"
        # 2.5.0 is the first that properly searches for Python 3.9 in CMake, so
        # anything before that probably won't work at all.
        pybind-version: "2.5.0"
    - coverage

  py310:
    executor: python-3_10
    steps:
    - install-base:
        extra: graphviz cmake ninja-build wget
    - install-python-deps:
        matplotlib-version: ==3.3.4
        extra: attrs==19.3.0
    - checkout
    - test-theme
    - test-plugins
    - test-documentation-themes:
        python-version: "3.10"
        # Python 3.10 and Pybind 2.8 were both released on 2021-10-04, so
        # assume anything older won't really work there.
        pybind-version: "2.8.0"
    - coverage

  js:
    executor: node-10
    steps:
    - install-base:
        extra: python3 curl
    - checkout
    - test-search
    # This FUCKING DAMN THING doesn't propagate a failure if curl doesn't exist
    # WHAT THE FUCK
    - codecov/upload

workflows:
  version: 2
  build:
    jobs:
    - py306
    - py307
    - py308
    - py309
    - py310
    - js
<commit_msg>package/ci: use older qrcode package until I update the regexes.<commit_after>version: 2.1

orbs:
  codecov: codecov/codecov@1.1.1

notify:
  webhooks:
    # Unfortunately Gitter messages are too verbose (one five-line message per
    # each job in the build matrix) and thus not wanted
    #- url: https://webhooks.gitter.im/e/cfbadbd34d28708a57c6

executors:
  python-3_06:
    docker:
    - image: python:3.6.15
  python-3_07:
    docker:
    - image: python:3.7.12
  python-3_08:
    docker:
    - image: python:3.8.12
  python-3_09:
    docker:
    - image: python:3.9.8
  python-3_10:
    docker:
    - image: python:3.10.1
  node-10:
    docker:
    - image: node:10.24.0-buster-slim

commands:
  install-base:
    parameters:
      extra:
        type: string
        default: ""
    steps:
    - run:
        name: Update apt and install base packages
        # Git needed always for verifying we have up-to-date generated files
        command: |
          apt update
          apt install -y git << parameters.extra >>

  install-python-deps:
    parameters:
      extra:
        type: string
        default: ""
      matplotlib-version:
        type: string
        default: ""
    steps:
    - run:
        name: Install Python dependencies
        # Pyphen 0.10 has significantly different hyphenation results, staying
        # on an  older version until I can investigate
        # Matplotlib 3.4.1 has different output AGAIN, staying on something
        # older until I can investigate; on Py3.5 there's only 3.0 so this is
        # being set explicitly in py36 and py37 build
        # Attrs 20.3 add some new properties that I need to ignore first, using
        # 19.3 instead
        # New qrcode (7.3? or the older ones as well?) chages the SVG preamble
        # so the current regex no longer works. I have to update it.
        command: |
          pip install jinja2 pelican Pyphen==0.9.5 Pillow coverage codecov qrcode==6.1 matplotlib<< parameters.matplotlib-version >> << parameters.extra >>
    - run:
        name: Fix unheard-of cursed issues
        # otherwise i get Error: unsupported locale setting
        # https://stackoverflow.com/a/59637279
        command: |
          apt install -y locales
          sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen
          dpkg-reconfigure --frontend=noninteractive locales
          echo 'export LC_ALL=en_US.UTF-8' >> $BASH_ENV
          echo 'export LC_CTYPE=en_US.UTF-8' >> $BASH_ENV

  test-theme:
    steps:
    - run:
        name: Test the theme
        command: |
          cd pelican-theme
          python -m unittest -v
    - run:
        name: Verify compiled CSS is up-to-date
        command: |
          cd css
          ./postprocess.sh
          git diff --color=always . | cat
          git diff-index --exit-code HEAD -- .

  test-plugins:
    steps:
    - run:
        name: Test plugins
        # TODO: add tests for the math plugin as well
        command: |
          cd plugins
          coverage run -m unittest -v
          cp .coverage ../.coverage.plugins

  test-documentation-themes:
    parameters:
      pybind-version:
        type: string
      python-version:
        type: string
    steps:
    - run:
        name: Install Doxygen
        command: |
          mkdir -p $HOME/bin
          export PATH=$HOME/bin:$PATH
          echo 'export PATH=$HOME/bin:$PATH' >> $BASH_ENV
          wget https://sourceforge.net/projects/doxygen/files/rel-1.8.17/doxygen-1.8.17.linux.bin.tar.gz
          tar -xzf doxygen-1.8.17.linux.bin.tar.gz
          cp doxygen-1.8.17/bin/doxygen $HOME/bin
          doxygen -v
    - run:
        name: Install pybind11
        command: |
          apt update
          apt install -y cmake ninja-build
          wget --no-clobber https://github.com/pybind/pybind11/archive/v<< parameters.pybind-version >>.tar.gz
          tar -xzf v<< parameters.pybind-version >>.tar.gz

          cd pybind11-<< parameters.pybind-version >>
          mkdir -p build && cd build
          cmake .. \
            -DCMAKE_INSTALL_PREFIX=$HOME/pybind<< parameters.pybind-version >> \
            -DPYBIND11_PYTHON_VERSION=<< parameters.python-version >> \
            -DPYBIND11_TEST=OFF \
            -G Ninja
          ninja install
    - run:
        name: Build & test Python bindings code
        command: |
          cd documentation/test_python
          mkdir -p build && cd build
          cmake .. \
            -DCMAKE_PREFIX_PATH=$HOME/pybind<< parameters.pybind-version >> \
            -DPYBIND11_PYTHON_VERSION=<< parameters.python-version >> \
            -G Ninja
          ninja
    - run:
        name: Test documentation themes
        command: |
          cd documentation
          coverage run -m unittest -v
          cp .coverage ../.coverage.documentation

  test-search:
    steps:
    - run:
        name: Install Node.js dependencies
        command: |
          npm install istanbul codecov
    - run:
        name: Test JavaScript search
        command: |
          cd documentation
          node ../node_modules/istanbul/lib/cli.js cover test/test-search.js
    - run:
        name: Verify JavaScript search data are up-to-date
        command: |
          cd documentation/test
          ./populate-js-test-data.py
          git diff --color=always . | cat
          git diff-index --exit-code HEAD -- .

  coverage:
    steps:
    - run:
        name: Collect and upload code coverage
        command: |
          coverage combine
          codecov

jobs:
  py306:
    executor: python-3_06
    steps:
    - install-base:
        extra: graphviz cmake ninja-build wget
    - install-python-deps:
        matplotlib-version: ==3.3.4
        extra: attrs==19.3.0
    - checkout
    - test-theme
    - test-plugins
    - test-documentation-themes:
        python-version: "3.6"
        pybind-version: "2.2.4"
    - coverage

  py307:
    executor: python-3_07
    steps:
    - install-base:
        extra: graphviz cmake ninja-build wget
    - install-python-deps:
        matplotlib-version: ==3.3.4
        extra: attrs==19.3.0
    - checkout
    - test-theme
    - test-plugins
    - test-documentation-themes:
        python-version: "3.7"
        pybind-version: "2.3.0"
    - coverage

  py308:
    executor: python-3_08
    steps:
    - install-base:
        extra: graphviz cmake ninja-build wget
    - install-python-deps:
        matplotlib-version: ==3.3.4
        extra: attrs==19.3.0
    - checkout
    - test-theme
    - test-plugins
    - test-documentation-themes:
        python-version: "3.8"
        # 2.4.1 fixes a Py3.8-specific bug, so the 2.3 versions are probably
        # not wise to use here
        pybind-version: "2.4.3"
    - coverage

  py309:
    executor: python-3_09
    steps:
    - install-base:
        extra: graphviz cmake ninja-build wget
    - install-python-deps:
        matplotlib-version: ==3.3.4
        extra: attrs==19.3.0
    - checkout
    - test-theme
    - test-plugins
    - test-documentation-themes:
        python-version: "3.9"
        # 2.5.0 is the first that properly searches for Python 3.9 in CMake, so
        # anything before that probably won't work at all.
        pybind-version: "2.5.0"
    - coverage

  py310:
    executor: python-3_10
    steps:
    - install-base:
        extra: graphviz cmake ninja-build wget
    - install-python-deps:
        matplotlib-version: ==3.3.4
        extra: attrs==19.3.0
    - checkout
    - test-theme
    - test-plugins
    - test-documentation-themes:
        python-version: "3.10"
        # Python 3.10 and Pybind 2.8 were both released on 2021-10-04, so
        # assume anything older won't really work there.
        pybind-version: "2.8.0"
    - coverage

  js:
    executor: node-10
    steps:
    - install-base:
        extra: python3 curl
    - checkout
    - test-search
    # This FUCKING DAMN THING doesn't propagate a failure if curl doesn't exist
    # WHAT THE FUCK
    - codecov/upload

workflows:
  version: 2
  build:
    jobs:
    - py306
    - py307
    - py308
    - py309
    - py310
    - js

{'fraction_non_alphanumeric': 0.09900062460961899, 'fraction_numerical': 0.03235477826358526, 'mean_word_length': 1.7308545113423162, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 55, 'https://': 8, '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': '1169567', 'n_tokens_mistral': 5360, 'n_tokens_neox': 5032, 'n_words': 1348}