before_script:
  # workaround for https://github.com/JuliaDocs/Documenter.jl/issues/686
  - apt-get -qq update; apt-get -y install git
  - mkdir -p /root/.ssh && ssh-keyscan -H -t rsa git.km3net.de >> /root/.ssh/known_hosts

.script:
  script:
    - |
      julia -e '
        using Pkg
        Pkg.update()
        Pkg.Registry.add(RegistrySpec(url = "https://git.km3net.de/common/julia-registry"))'
      julia --project=@. -e '
        using Pkg
        Pkg.build()
        Pkg.test(coverage=true)'
.coverage:
  coverage: /Test coverage (\d+\.\d+%)/
  after_script:
    - |
      julia -e '
        using Pkg
        Pkg.update()
        Pkg.Registry.add(RegistrySpec(url = "https://git.km3net.de/common/julia-registry"))
        Pkg.add("Coverage")
        using Coverage
        c, t = get_summary(process_folder())
        using Printf
        @printf "Test coverage %.2f%%\n" 100c / t'
Julia 1.6:
  image: julia:1.6
  extends:
    - .script
    - .coverage
Julia 1.8:
  image: julia:1.8
  extends:
    - .script
    - .coverage
pages:
  image: julia:1.6
  stage: deploy
  script:
    - |
      julia --project=docs -e '
        using Pkg
        Pkg.update()
        Pkg.Registry.add(RegistrySpec(url = "https://git.km3net.de/common/julia-registry"))
        Pkg.develop(PackageSpec(path=pwd()))
        Pkg.instantiate()
        using Documenter: doctest
        using KM3io
        doctest(KM3io)
        include("docs/make.jl")'
    - mkdir -p public
    - mv docs/build public/dev
  artifacts:
    paths:
      - public
  only:
    - main
