language: julia

julia:
  # - 1.0
  - 1.3
  - nightly

os:
  - linux
  - osx

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
    # build docs on master and for tags
    if: (branch = master AND type = push) OR tag IS present

script:
  - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
  - 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
    - name: TOML (Julia 1.3)
      stage: test
      os: linux
      julia: 1.3
      script:
        - julia --project=ext/TOML -e 'using Pkg; Pkg.test()'
      after_success: skip
    - name: TOML (Julia nightly)
      stage: test
      os: linux
      julia: nightly
      script:
        - julia --project=ext/TOML -e 'using Pkg; Pkg.test()'
      after_success: skip

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