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

stages:
    - build
    - test
    - analyze

################################################################################
# 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
################################################################################

# Linux

## Build and test

build:fedora33:
    extends:
        - .fedora33
        - .cmake_build_linux
        - .cmake_build_artifacts
        - .linux_builder_tags
        - .run_automatically

test:fedora33:
    extends:
        - .fedora33
        - .cmake_test_linux
        - .linux_test_tags
        - .run_automatically
    dependencies:
        - build:fedora33
    needs:
        - build:fedora33

build:fedora33-vtk-python3:
    extends:
        - .fedora33_vtk_python3
        - .cmake_build_linux
        - .cmake_build_artifacts
        - .linux_builder_tags
        - .run_automatically

test:fedora33-vtk-python3:
    extends:
        - .fedora33_vtk_python3
        - .cmake_test_linux
        - .linux_test_tags
        - .run_automatically
    dependencies:
        - build:fedora33-vtk-python3
    needs:
        - build:fedora33-vtk-python3

build:fedora33-paraview:
    extends:
        - .fedora33_paraview
        - .cmake_build_linux
        - .cmake_build_artifacts
        - .linux_builder_tags
        - .run_automatically

test:fedora33-paraview:
    extends:
        - .fedora33_paraview
        - .cmake_test_linux
        - .linux_test_tags
        - .run_automatically
    dependencies:
        - build:fedora33-paraview
    needs:
        - build:fedora33-paraview

build:fedora33-nodata:
    extends:
        - .fedora33_nodata
        - .cmake_build_linux
        - .cmake_build_artifacts
        - .linux_builder_tags
        - .run_automatically

test:fedora33-nodata:
    extends:
        - .fedora33_nodata
        - .cmake_test_linux
        - .linux_test_tags
        - .run_automatically
    dependencies:
        - build:fedora33-nodata
    needs:
        - build:fedora33-nodata

## Lint builds

build:fedora33-asan:
    extends:
        - .fedora33_asan
        - .cmake_build_linux
        - .cmake_build_artifacts
        - .linux_builder_tags
        - .run_automatically

test:fedora33-asan:
    extends:
        - .fedora33_asan
        - .cmake_memcheck_linux
        - .linux_test_priv_tags
        - .run_automatically
    dependencies:
        - build:fedora33-asan
    needs:
        - build:fedora33-asan

build:fedora33-ubsan:
    extends:
        - .fedora33_ubsan
        - .cmake_build_linux
        - .cmake_build_artifacts
        - .linux_builder_tags
        - .run_automatically

test:fedora33-ubsan:
    extends:
        - .fedora33_ubsan
        - .cmake_memcheck_linux
        - .linux_test_priv_tags
        - .run_automatically
    dependencies:
        - build:fedora33-ubsan
    needs:
        - build:fedora33-ubsan

build:fedora33-tidy:
    extends:
        - .fedora33_tidy
        - .cmake_build_linux_tidy
        - .cmake_build_artifacts
        - .linux_builder_tags
        - .run_automatically

build:fedora33-coverage:
    extends:
        - .fedora33_coverage
        - .cmake_build_linux
        - .cmake_build_artifacts
        - .linux_builder_tags
        - .run_automatically

test:fedora33-coverage:
    extends:
        - .fedora33_coverage
        - .cmake_test_linux
        - .linux_test_tags
        - .cmake_coverage_artifacts
        - .run_automatically
    dependencies:
        - build:fedora33-coverage
    needs:
        - build:fedora33-coverage

analyze:fedora33-coverage:
    extends:
        - .fedora33_coverage
        - .cmake_coverage_linux
        - .linux_builder_tags
        - .run_automatically
    dependencies:
        - test:fedora33-coverage
    needs:
        - test:fedora33-coverage

# macOS

## Build and test

build:macos-plain:
    extends:
        - .macos_plain
        - .cmake_build_macos
        - .cmake_build_artifacts
        - .macos_builder_tags
        - .run_automatically

test:macos-plain:
    extends:
        - .macos_plain
        - .cmake_test_macos
        - .macos_builder_tags
        - .run_automatically
    dependencies:
        - build:macos-plain
    needs:
        - build:macos-plain

# Windows

## Build and test

build:windows-vs2019-ninja:
    extends:
        - .windows_vs2019_ninja
        - .cmake_build_windows
        - .cmake_build_artifacts
        - .windows_builder_tags
        - .run_automatically

test:windows-vs2019-ninja:
    extends:
        - .windows_vs2019_ninja
        - .cmake_test_windows
        - .windows_builder_tags
        - .run_automatically
    dependencies:
        - build:windows-vs2019-ninja
    needs:
        - build:windows-vs2019-ninja
    # XXX: Some tests spuriously fail, likely for CI-related reasons. At least
    # let the build do its thing in CI though.
    allow_failure: true
