include:
    # Metadata shared my many jobs
    - local: .gitlab/rules.yml
    - local: .gitlab/artifacts.yml

    # OS builds.
    - local: .gitlab/os-linux.yml
    - local: .gitlab/os-macos.yml
    - local: .gitlab/os-windows.yml

    # Post-build steps
    - local: .gitlab/upload.yml

stages:
    - prep
    - build
    - test
    - test-ext
    - upload

################################################################################
# Job declarations
#
# Each job must pull in each of the following keys:
#
#   - a "base image"
#   - a build script
#   - tags for the jobs
#   - rules for when to run the job
#
# Additionally, jobs may also contain:
#
#   - artifacts
#   - dependency/needs jobs for required jobs
################################################################################

# Prep jobs

prep:source-package:
    extends:
        - .linux_prep_source
        - .cmake_prep_source_linux
        - .linux_builder_tags
        - .cmake_release_artifacts
        - .run_only_for_package

prep:doc-package:
    extends:
        - .fedora33_sphinx_package
        - .cmake_prep_doc_linux
        - .linux_builder_tags_qt
        - .cmake_doc_artifacts
        - .run_only_for_package

upload:source-package:
    extends:
        - .rsync_upload
        - .run_only_for_package
    dependencies:
        - prep:source-package
    needs:
        - prep:source-package
    variables:
        RSYNC_DESTINATION: dev

# Lint builds

build:debian10-iwyu:
    extends:
        - .debian10_iwyu
        - .cmake_build_linux
        - .linux_builder_tags
        - .run_automatically

build:fedora33-tidy:
    extends:
        - .fedora33_tidy
        - .cmake_build_linux
        - .linux_builder_tags_qt
        - .run_automatically

build:fedora33-sphinx:
    extends:
        - .fedora33_sphinx
        - .cmake_build_linux
        - .linux_builder_tags_qt
        - .run_automatically
    variables:
        CMAKE_CI_JOB_CONTINUOUS: "true"
        CMAKE_CI_JOB_HELP: "true"

# Linux builds

build:centos6-x86_64:
    extends:
        - .linux_release_x86_64
        - .cmake_build_linux_release
        - .cmake_release_artifacts
        - .linux_builder_tags
        - .run_manually

build:centos7-aarch64:
    extends:
        - .linux_release_aarch64
        - .cmake_build_linux_release
        - .cmake_release_artifacts
        - .linux_builder_tags_aarch64
        - .run_manually
    variables:
        CMAKE_CI_NO_MR: "true"

test:debian10-ninja:
    extends:
        - .debian10_ninja
        - .cmake_test_linux_release
        - .linux_builder_tags_qt
        - .run_dependent
    dependencies:
        - build:centos6-x86_64
    needs:
        - build:centos6-x86_64

test:debian10-aarch64-ninja:
    extends:
        - .debian10_aarch64_ninja
        - .cmake_test_linux_release
        - .linux_builder_tags_aarch64_qt
        - .run_dependent
    dependencies:
        - build:centos7-aarch64
    needs:
        - build:centos7-aarch64
    variables:
        CMAKE_CI_NO_MR: "true"

test:fedora33-makefiles:
    extends:
        - .fedora33_makefiles
        - .cmake_test_linux_release
        - .linux_builder_tags_qt
        - .run_dependent
    dependencies:
        - build:centos6-x86_64
    needs:
        - build:centos6-x86_64

test:cuda10.2-nvidia:
    extends:
        - .cuda10.2_nvidia
        - .cmake_test_linux_release
        - .linux_builder_tags_cuda
        - .run_dependent
    dependencies:
        - build:centos6-x86_64
    needs:
        - build:centos6-x86_64

build:fedora33-ninja:
    extends:
        - .fedora33_ninja
        - .cmake_build_linux
        - .cmake_build_artifacts
        - .linux_builder_tags_qt
        - .run_manually

test:fedora33-ninja:
    extends:
        - .fedora33_ninja
        - .cmake_test_linux
        - .linux_builder_tags_x11
        - .cmake_test_artifacts
        - .run_dependent
    dependencies:
        - build:fedora33-ninja
    needs:
        - build:fedora33-ninja

test:fedora33-ninja-multi:
    extends:
        - .fedora33_ninja_multi
        - .cmake_test_linux_external
        - .linux_builder_tags_qt
        - .run_dependent
    dependencies:
        - test:fedora33-ninja
    needs:
        - test:fedora33-ninja

build:linux-x86_64-package:
    extends:
        - .linux_package
        - .linux_release_x86_64
        - .cmake_build_linux_release
        - .cmake_release_artifacts
        - .linux_builder_tags
        - .run_only_for_package
    dependencies:
        - prep:doc-package
    needs:
        - prep:doc-package

upload:linux-x86_64-package:
    extends:
        - .rsync_upload
        - .run_only_for_package
    dependencies:
        - build:linux-x86_64-package
    needs:
        - build:linux-x86_64-package
    variables:
        RSYNC_DESTINATION: dev

build:linux-aarch64-package:
    extends:
        - .linux_package
        - .linux_release_aarch64
        - .cmake_build_linux_release
        - .cmake_release_artifacts
        - .linux_builder_tags_aarch64
        - .run_only_for_package
    dependencies:
        - prep:doc-package
    needs:
        - prep:doc-package

upload:linux-aarch64-package:
    extends:
        - .rsync_upload
        - .run_only_for_package
    dependencies:
        - build:linux-aarch64-package
    needs:
        - build:linux-aarch64-package
    variables:
        RSYNC_DESTINATION: dev

# macOS builds

build:macos-ninja:
    extends:
        - .macos_ninja
        - .cmake_build_macos
        - .cmake_build_artifacts
        - .macos_builder_tags
        - .run_manually

test:macos-ninja:
    extends:
        - .macos_ninja
        - .cmake_test_macos
        - .cmake_test_artifacts
        - .macos_builder_tags
        - .run_dependent
    dependencies:
        - build:macos-ninja
    needs:
        - build:macos-ninja

build:macos-makefiles:
    extends:
        - .macos_makefiles
        - .cmake_build_macos
        - .cmake_build_artifacts
        - .macos_builder_tags
        - .run_manually

test:macos-makefiles:
    extends:
        - .macos_makefiles
        - .cmake_test_macos
        - .macos_builder_tags
        - .run_dependent
    dependencies:
        - build:macos-makefiles
    needs:
        - build:macos-makefiles

test:macos-xcode:
    extends:
        - .macos_xcode
        - .cmake_test_macos_external
        - .macos_builder_ext_tags
        - .run_dependent
    dependencies:
        - test:macos-ninja
    needs:
        - test:macos-ninja

build:macos-package:
    extends:
        - .macos_package
        - .cmake_build_macos_package
        - .cmake_release_artifacts
        - .macos_builder_tags_package
        - .run_only_for_package
    dependencies:
        - prep:doc-package
    needs:
        - prep:doc-package

upload:macos-package:
    extends:
        - .rsync_upload
        - .run_only_for_package
    dependencies:
        - build:macos-package
    needs:
        - build:macos-package
    variables:
        RSYNC_DESTINATION: dev

build:macos10.10-package:
    extends:
        - .macos10.10_package
        - .cmake_build_macos_package
        - .cmake_release_artifacts
        - .macos_builder_tags_package
        - .run_only_for_package
    dependencies:
        - prep:doc-package
    needs:
        - prep:doc-package

upload:macos10.10-package:
    extends:
        - .rsync_upload
        - .run_only_for_package
    dependencies:
        - build:macos10.10-package
    needs:
        - build:macos10.10-package
    variables:
        RSYNC_DESTINATION: dev

# Windows builds

build:windows-vs2019-x64-ninja:
    extends:
        - .windows_vs2019_x64_ninja
        - .cmake_build_windows
        - .cmake_build_artifacts
        - .windows_builder_tags
        - .run_manually

test:windows-vs2019-x64-ninja:
    extends:
        - .windows_vs2019_x64_ninja
        - .cmake_test_windows
        - .windows_builder_tags
        - .cmake_test_artifacts
        - .run_dependent
    dependencies:
        - build:windows-vs2019-x64-ninja
    needs:
        - build:windows-vs2019-x64-ninja

test:windows-vs2019-x64:
    extends:
        - .windows_vs2019_x64
        - .cmake_test_windows_external
        - .windows_builder_ext_tags
        - .run_dependent
    dependencies:
        - test:windows-vs2019-x64-ninja
    needs:
        - test:windows-vs2019-x64-ninja
