---
variables:
  DUNECI_CMAKE_FLAGS: "-DDUNE_PYTHON_FORCE_PYTHON3=TRUE"

before_script: &before
  - duneci-install-module https://gitlab.dune-project.org/fufem/dune-matrix-vector.git
  - duneci-install-module https://git.imp.fu-berlin.de/agnumpde/dune-solvers.git
  - duneci-install-module https://gitlab.dune-project.org/extensions/dune-vtk.git
  - duneci-install-module https://gitlab.dune-project.org/fufem/dune-fufem.git
  - duneci-install-module https://gitlab.dune-project.org/extensions/dune-gmsh4

#  Tests with the 2.9 release.  That's the one in Debian bookworm
#--------------------------------------------------------------------
dune:2.9 gcc:
  variables:
    DUNECI_BRANCH: releases/2.9
  image: registry.dune-project.org/docker/ci/dune:2.9-debian-11-gcc-10-20
  before_script:
  - *before
  script: duneci-standard-test

dune:2.9 dune-elasticity gcc:
  variables:
    DUNECI_BRANCH: releases/2.9
  image: registry.dune-project.org/docker/ci/dune:2.9-debian-11-gcc-10-20
  before_script:
  - *before
  - duneci-install-module https://gitlab.mn.tu-dresden.de/ag-sander/dune/dune-elasticity.git
  script: duneci-standard-test

#  Tests with the 2.10 release.  That's the one in Debian trixie
#--------------------------------------------------------------------
dune:2.10 gcc-10:
  image: registry.dune-project.org/docker/ci/dune:2.10-debian-11-gcc-10-20
  variables:
    DUNECI_BRANCH: releases/2.10
  before_script:
  - *before
  script: duneci-standard-test

dune:2.10 dune-elasticity gcc-10:
  image: registry.dune-project.org/docker/ci/dune:2.10-debian-11-gcc-10-20
  variables:
    DUNECI_BRANCH: releases/2.10
  before_script:
  - *before
  - duneci-install-module https://gitlab.mn.tu-dresden.de/ag-sander/dune/dune-elasticity.git
  script: duneci-standard-test

dune:2.10 dune-curvedgrid dune-foamgrid gcc-10 C++20:
  image: registry.dune-project.org/docker/ci/dune:2.10-debian-11-gcc-10-20
  variables:
    DUNECI_BRANCH: releases/2.10
  before_script:
  - *before
  - duneci-install-module https://gitlab.dune-project.org/extensions/dune-curvedgeometry.git
  - duneci-install-module https://gitlab.dune-project.org/extensions/dune-curvedgrid.git
  - duneci-install-module https://gitlab.dune-project.org/extensions/dune-foamgrid.git
  script: duneci-standard-test

dune:2.10 dune-parmg dune-curvedgrid dune-foamgrid dune-elasticity gcc-10 C++20:
  image: registry.dune-project.org/docker/ci/dune:2.10-debian-11-gcc-10-20
  variables:
    DUNECI_BRANCH: releases/2.10
  before_script:
  - *before
  - duneci-install-module https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.mn.tu-dresden.de/paraphase/dune-parmg.git
  - duneci-install-module https://gitlab.dune-project.org/extensions/dune-curvedgeometry.git
  - duneci-install-module https://gitlab.dune-project.org/extensions/dune-curvedgrid.git
  - duneci-install-module https://gitlab.dune-project.org/extensions/dune-foamgrid.git
  - duneci-install-module https://gitlab.mn.tu-dresden.de/ag-sander/dune/dune-elasticity.git
  script: duneci-standard-test

# Full tests again, but this time with clang.
dune:2.10 dune-parmg dune-curvedgrid dune-foamgrid dune-elasticity clang-11 C++20:
  image: registry.dune-project.org/docker/ci/dune:2.10-debian-11-clang-11-20
  variables:
    DUNECI_BRANCH: releases/2.10
  before_script:
  - *before
  - duneci-install-module https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.mn.tu-dresden.de/paraphase/dune-parmg.git
  - duneci-install-module https://gitlab.dune-project.org/extensions/dune-curvedgeometry.git
  - duneci-install-module https://gitlab.dune-project.org/extensions/dune-curvedgrid.git
  - duneci-install-module https://gitlab.dune-project.org/extensions/dune-foamgrid.git
  - duneci-install-module https://gitlab.mn.tu-dresden.de/ag-sander/dune/dune-elasticity.git
  script: duneci-standard-test


#  Tests with the git master branch
#  Some, but not all optional dependencies are made available.
#------------------------------------------------------------------
dune:git gcc-10 C++20:
  image: registry.dune-project.org/docker/ci/dune:git-debian-11-gcc-10-20
  before_script:
  - *before
  script: duneci-standard-test

dune:git clang-11 C++20:
  image: registry.dune-project.org/docker/ci/dune:git-debian-11-clang-11-20
  before_script:
  - *before
  script: duneci-standard-test

dune:git dune-elasticity gcc-10 C++20:
  image: registry.dune-project.org/docker/ci/dune:git-debian-11-gcc-10-20
  before_script:
  - *before
  - duneci-install-module https://gitlab.mn.tu-dresden.de/ag-sander/dune/dune-elasticity.git
  script: duneci-standard-test

dune:git dune-curvedgrid dune-foamgrid gcc-10 C++20:
  image: registry.dune-project.org/docker/ci/dune:git-debian-11-gcc-10-20
  before_script:
  - *before
  - duneci-install-module https://gitlab.dune-project.org/extensions/dune-curvedgeometry.git
  - duneci-install-module https://gitlab.dune-project.org/extensions/dune-curvedgrid.git
  - duneci-install-module https://gitlab.dune-project.org/extensions/dune-foamgrid.git
  script: duneci-standard-test

#  Tests with all optional dependencies
#-------------------------------------------
dune:git dune-parmg dune-curvedgrid dune-foamgrid dune-elasticity gcc-10 C++20:
  image: registry.dune-project.org/docker/ci/dune:git-debian-11-gcc-10-20
  before_script:
  - *before
  - duneci-install-module https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.mn.tu-dresden.de/paraphase/dune-parmg.git
  - duneci-install-module https://gitlab.dune-project.org/extensions/dune-curvedgeometry.git
  - duneci-install-module https://gitlab.dune-project.org/extensions/dune-curvedgrid.git
  - duneci-install-module https://gitlab.dune-project.org/extensions/dune-foamgrid.git
  - duneci-install-module https://gitlab.mn.tu-dresden.de/ag-sander/dune/dune-elasticity.git
  script: duneci-standard-test

dune:git dune-parmg dune-curvedgrid dune-foamgrid dune-elasticity clang-11 C++20:
  image: registry.dune-project.org/docker/ci/dune:git-debian-11-clang-11-20
  before_script:
  - *before
  - duneci-install-module https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.mn.tu-dresden.de/paraphase/dune-parmg.git
  - duneci-install-module https://gitlab.dune-project.org/extensions/dune-curvedgeometry.git
  - duneci-install-module https://gitlab.dune-project.org/extensions/dune-curvedgrid.git
  - duneci-install-module https://gitlab.dune-project.org/extensions/dune-foamgrid.git
  - duneci-install-module https://gitlab.mn.tu-dresden.de/ag-sander/dune/dune-elasticity.git
  script: duneci-standard-test

# Check for spelling mistakes in text
code-spelling-check:
  stage: .pre
  # Avoid the global 'before_script'
  before_script: ""
  image: registry.dune-project.org/docker/ci/debian:11
  script:
  - codespell
    --ignore-words-list numer

# Verify code-formatting rules
code-formatting-check:
  stage: .pre
  # Avoid the global 'before_script'
  before_script: ""
  image: registry.dune-project.org/docker/ci/debian:11
  script:
    # Format all *.cc and *.hh files using the uncrustify tool
    # We ignore the return value of 'uncrustify', because it is
    # apparently unreliable, and returns 'failure' without a reason.
    - uncrustify -l CPP -c dune-uncrustify.cfg --no-backup `find -name "*.cc" -o -name "*.hh"` || true

    # Did anything change?  That would indicate a violation of the formatting rules
    # But before, work around an issue where git doesn't recognize the source tree as a git directory.
    # See https://forum.gitlab.com/t/ci-cd-job-git-diff/76666
    - git config --global --add safe.directory "$(pwd)"
    - git diff --exit-code
