Feature request: inheriting workflows

Right now CMake workflows doesn’t have ability to inherit the another workflow.
It forces to copy-paste a lot of code in some scenarios when the workflows use slightly different configure steps.
Consider this part from one of my presets for building project in docker:

 "workflowPresets":
      [
        {
          "name": "docker",
          "description": "Base docker configure/build workflow",
          "steps": [
            {
              "type": "configure",
              "name": "docker"
            },
            {
              "type": "build",
              "name": "docker"
            }
          ]

        },
        {
          "name": "docker-build-gcc",
          "description": "Synonim for \"docker\" workflow for conditional build in Dockerfile",
          "steps": [
            {
              "type": "configure",
              "name": "docker"
            },
            {
              "type": "build",
              "name": "docker"
            }
          ]
        },
        {
          "name": "docker-build-clang",
          "description": "Synonim for \"docker-clang\" workflow for conditional build in Dockerfile",
          "steps": [
            {
              "type": "configure",
              "name": "docker-clang"
            },
            {
              "type": "build",
              "name": "docker-clang"
            }
          ]
        },
        {
          "name": "docker-dev",
          "description": "Base docker dev environment (similar to GCC build), only configure project for ability to exec build/test manually",
          "steps": [
            {
              "type": "configure",
              "name": "docker"
            }
          ]
        },
        {
          "name": "docker-dev-gcc",
          "description": "Base docker dev environment for GCC build, only configure project for ability to exec build/test manually",
          "steps": [
            {
              "type": "configure",
              "name": "docker"
            }
          ]
        },
        {
          "name": "docker-dev-clang",
          "description": "Base docker dev environment for Clang build, only configure project for ability to exec build/test manually",
          "steps": [
            {
              "type": "configure",
              "name": "docker-clang"
            }
          ]
        }

      ]

The “docker-dev-" presets just configure CMake and are designed for “dev containers” environment.
The "docker-build-
” presets reuse the “docker-dev-*” configure steps and add build steps (for now they just copy-paste similar steps).

With inheriting this example could looks like:

 "workflowPresets":
      [
        {
          "name": "docker-dev",
          "description": "Base docker dev env configure workflow with GCC",
          "steps": [
            {
              "type": "configure",
              "name": "docker"
            }
          ]
        },
        {
          "name": "docker-dev-gcc",
          "description": "Synonym for \"docker-dev\" workflow for conditional build in Dockerfile",
          "inherits": [ "docker-dev"]
        },
        {
          "name": "docker-dev-clang",
          "description": "Base docker dev env configure workflow with Clang",
          "steps": [
            {
              "type": "configure",
              "name": "docker-clang"
            }
          ]
        },
        {
          "name": "docker-build",
          "description": "Base docker build workflow with GCC",
          "inherits": [ "docker-dev" ],
          "steps": [
            {
              "type": "build",
              "name": "docker"
            }
          ]
        },
        {
          "name": "docker-build-gcc",
          "description": "Synonym for \"docker-build\" workflow for conditional build in Dockerfile with GCC",
          "inherits": [ "docker-build" ],
        },
        {
          "name": "docker-build-clang",
          "description": "Base docker build workflow with Clang",
          "inherits": [ "docker-dev-clang" ],
          "steps": [
            {
              "type": "build",
              "name": "docker-clang"
            }
          ]
        },
      ]
1 Like

I’d question that. What would inheriting a workflow preset even mean? A workflow is essentially just a sequence of operations. If you inherited a workflow and added steps in the inheriting workflow preset, how should the set of steps be combined? Should the inheriting preset’s steps be appended to the inherited steps? Should they replace the inherited steps somehow? I don’t think an inheriting relationship makes sense for workflows.

As workflow could contain only one kind of step, I think that overriding (like in “OO”-style) is OK

Would having a step of type “workflow” not work aswell, instead of inheritance? This would avoid the having to define how merging an inherited workflow works. And it would allow to reuse various parts of workflows not just the configure step. I believe this would need an option to allow a workflow to be defined as partial, such that it does not need a configure step.

2 Likes