variables:
  CCACHE_COMPILERCHECK: content
  CCACHE_DIR: "${CI_PROJECT_DIR}/.ccache"


build:
  stage: build
  image: alpine:latest
  tags: [docker]
  before_script:
    - echo 'https://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories
    - apk update && apk add clang-extra-tools meson git python3 py3-pip py3-flask lcov gcovr curl-dev libevent-dev spdlog-dev grep g++ cmake pkgconf openssl
    - export PATH="$PATH:/root/.local/bin"
    - pip3 install --user reuse
    - ./scripts/run_tls_testserver.sh &
    - ./scripts/run_testserver.sh &
  script:
    - meson setup builddir -Db_coverage=true -Dtests=true -Dexamples=true
    - meson compile -C builddir
    - ./builddir/tests/requests_tls -d --reporters=junit --out=https.xml
    - ./builddir/tests/requests -d --reporters=junit --out=http.xml
    - ./builddir/examples/coeurl_example
    - ninja -C builddir coverage-text
    - grep TOTAL builddir/meson-logs/coverage.txt
  artifacts:
    reports:
      junit: http*.xml

build-with-wraps:
  stage: build
  image: alpine:latest
  tags: [docker]
  before_script:
    - echo 'https://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories
    - apk update && apk add clang-extra-tools meson git python3 py3-pip py3-flask curl-dev g++ cmake pkgconf openssl make
    - export PATH="$PATH:/root/.local/bin"
    - pip3 install --user reuse
    - ./scripts/run_tls_testserver.sh &
    - ./scripts/run_testserver.sh &
  script:
    - meson setup builddir -Dtests=true -Dexamples=true --wrap-mode=forcefallback -Ddefault_library=static
    - meson compile -C builddir
    - ./builddir/tests/requests_tls -d --reporters=junit --out=https.xml
    - ./builddir/tests/requests -d --reporters=junit --out=http.xml
    - ./builddir/examples/coeurl_example
  artifacts:
    reports:
      junit: http*.xml

build-cmake:
  stage: build
  image: alpine:latest
  tags: [docker]
  before_script:
    - apk update && apk add git curl-dev libevent-dev spdlog-dev g++ cmake pkgconf openssl samurai
  script:
    - cmake -GNinja -S . -B build
    - ninja -C build

build-hunter:
  stage: build
  image: alpine:latest
  tags: [docker]
  before_script:
    - apk update && apk add git curl-dev libevent-dev spdlog-dev g++ cmake pkgconf openssl samurai perl make linux-headers
  script:
    - cmake -GNinja -S . -B build -DHUNTER_ENABLED=ON
    - ninja -C build
