<commit_before>image: fedora:34

stages:
  - build
  - docs
  - deploy

.build-default:
  before_script:
    - dnf install -y ${FEDORA_DEPS}
    - pip3 install --user meson==${MESON_VERSION}
    - export PATH="$PATH:$HOME/.local/bin"
  script:
    - meson setup ${MESON_EXTRA_FLAGS} --prefix /usr _build .
    - meson compile -C _build
    - meson test -C _build
    - meson install -C _build
  artifacts:
    when: always
    name: "json-glib-${CI_COMMIT_REF_NAME}"
    paths:
      - "${CI_PROJECT_DIR}/_build/meson-logs"

fedora-x86_64:
  extends: .build-default
  stage: build
  needs: []
  variables:
    FEDORA_DEPS:
      gcc
      gettext
      git
      glib2-devel
      gobject-introspection-devel
      ninja-build
      python3
      python3-pip
      python3-wheel
      redhat-rpm-config
    MESON_VERSION: "0.55.3"
    MESON_EXTRA_FLAGS: "--buildtype=debug --default-library=both -Dwerror=true -Dglib:werror=false -Dintrospection=enabled"

reference:
  extends: .build-default
  stage: docs
  needs: []
  variables:
    FEDORA_DEPS:
      docbook-style-xsl
      gcc
      gettext
      git
      glib2-devel
      gobject-introspection-devel
      graphviz
      ninja-build
      python3
      python3-jinja2
      python3-markdown
      python3-markupsafe
      python3-pip
      python3-pygments
      python3-toml
      python3-typogrify
      python3-wheel
      redhat-rpm-config
      libxslt
    MESON_VERSION: "0.55.3"
    MESON_EXTRA_FLAGS: "-Dgtk_doc=enabled -Dman=true -Dintrospection=enabled"
  after_script:
    - mkdir _reference
    - mv _build/doc/json-glib-1.0/ _reference/
  artifacts:
    paths:
      - _reference

pages:
  stage: deploy
  needs: ['reference']
  script:
    - mv _reference public
  artifacts:
    paths:
      - public
  only:
    - master<commit_msg>ci: Use a separate template for the reference job<commit_after>image: fedora:34

stages:
  - build
  - docs
  - deploy

.build-default:
  before_script:
    - dnf install -y ${FEDORA_DEPS}
    - pip3 install --user meson==${MESON_VERSION}
    - export PATH="$PATH:$HOME/.local/bin"
  script:
    - meson setup ${MESON_EXTRA_FLAGS} --prefix /usr _build .
    - meson compile -C _build
    - meson test -C _build
    - meson install -C _build
  artifacts:
    when: always
    name: "json-glib-${CI_COMMIT_REF_NAME}"
    paths:
      - "${CI_PROJECT_DIR}/_build/meson-logs"

.gidocgen-build:
  image: fedora:latest
  before_script:
    - export PATH="$HOME/.local/bin:$PATH"
    - dnf install -y python3 python3-pip python3-wheel gobject-introspection-devel graphviz ninja-build redhat-rpm-config
    - dnf install -y ${PROJECT_DEPS}
    - pip3 install --user meson==${MESON_VERSION} gi-docgen jinja2 Markdown markupsafe pygments toml typogrify
  script:
    - meson setup ${MESON_EXTRA_FLAGS} ${DOCS_FLAGS} _docs .
    - meson compile -C _docs
    - |
      pushd "_docs/${DOCS_PATH}" > /dev/null
      tar cf ${CI_PROJECT_NAME}-docs.tar .
      popd > /dev/null
    - mv _docs/${DOCS_PATH}/${CI_PROJECT_NAME}-docs.tar .
  artifacts:
    when: always
    name: 'Documentation'
    expose_as: 'Download the API reference'
    paths:
      - ${CI_PROJECT_NAME}-docs.tar

fedora-x86_64:
  extends: .build-default
  stage: build
  needs: []
  variables:
    FEDORA_DEPS:
      gcc
      gettext
      git
      glib2-devel
      gobject-introspection-devel
      ninja-build
      python3
      python3-pip
      python3-wheel
      redhat-rpm-config
    MESON_VERSION: "0.55.3"
    MESON_EXTRA_FLAGS: "--buildtype=debug --default-library=both -Dwerror=true -Dglib:werror=false -Dintrospection=enabled"

reference:
  extends: .gidocgen-build
  stage: docs
  needs: []
  variables:
    PROJECT_DEPS:
      docbook-style-xsl
      gcc
      gettext
      git
      glib2-devel
      libxslt
    MESON_VERSION: "0.55.3"
    MESON_EXTRA_FLAGS: "-Dman=true -Dintrospection=enabled"
    DOCS_FLAGS: -Dgtk_doc=enabled
    DOCS_PATH: doc/json-glib-1.0
{'fraction_non_alphanumeric': 0.10697084917617238, 'fraction_numerical': 0.014955640050697085, 'mean_word_length': 2.434290687554395, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '293337', 'n_tokens_mistral': 1504, 'n_tokens_neox': 1447, 'n_words': 289}