language: julia

julia:
  # - 1.0
  # - 1.4
  - nightly

os:
  - linux
  - osx

env:
- JULIA_PKG_SERVER="https://pkg.julialang.org"
- JULIA_PKG_SERVER=""

notifications:
  email: false

before_script:
  - export PATH=$HOME/.local/bin:$PATH

branches:
  only:
    - master
    - /^release-.*/
    - /^v[0-9]+\.[0-9]+\.[0-9]+$/ # version tags

stages:
  - name: test
  - name: docs

script:
  - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
  - julia test/pkg-uuid.jl
  - julia --project -e 'using UUIDs; write("Project.toml", replace(read("Project.toml", String), r"uuid = .*?\n" =>"uuid = \"$(uuid4())\"\n"));'
  - julia --project --check-bounds=yes -e 'import Pkg; Pkg.build(); Pkg.test(; coverage=true)'

jobs:
  include:
    - stage: docs
      julia: nightly
      os: linux
      script:
        - julia -e 'using UUIDs; write("Project.toml", replace(read("Project.toml", String), r"uuid = .*?\n" =>"uuid = \"$(uuid4())\"\n"))'
        - julia --project -e 'using Pkg; Pkg.activate("docs"); Pkg.instantiate(); Pkg.develop(PackageSpec(path = pwd()))'
        - julia --project=docs --color=yes docs/make.jl pdf
      after_success: skip

after_success:
  - julia --project=test/coverage -e 'using Pkg; Pkg.instantiate();
        using Coverage; Codecov.submit(Codecov.process_folder())'
