Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support additional metadata in Taskfile YAML schema #1916

Open
timrulebosch opened this issue Nov 11, 2024 · 1 comment
Open

Support additional metadata in Taskfile YAML schema #1916

timrulebosch opened this issue Nov 11, 2024 · 1 comment
Labels
state: needs triage Waiting to be triaged by a maintainer.

Comments

@timrulebosch
Copy link

We are using Taskfiles as input for an automation system (a VSCode extenstion). For that to operate we need to know additional domain specific information about the tasks in the Taskfile. Currently, the Taskfile schema prevents adding such metadata.

Suggestion is to add a metadata object to the schema for both the Taskfile (global) and individual tasks (per task). Something like this:

---
version: '3'

vars:
  foo: bar

metadata:
  annotations:
    generator:
      repo: https://github.com/go-foo/foo
      version: v1.2.3
  labels:
    internal-only: true

tasks:
  my-task:
    desc: This task is generated by foo for project fubar.
    metadata:
       annotations: 
          generator: foo
       labels:
         project: fubar
    cmds:
      - echo "generated by foo"

If there is interest we can provide a PR as the basis for implementation.

@task-bot task-bot added the state: needs triage Waiting to be triaged by a maintainer. label Nov 11, 2024
@timrulebosch
Copy link
Author

We decided to augment our Taskfile.yml with an additional file "Metadata.yml" (out of necessity, not because we wanted to). With that we can describe the tasks in a way that integrates with the VSCode plugin.

I think that describing this metadata within the Taskfile schema would be more practical, and would also allow some level of automated documentation generation.

As an example, here is a fragment of the metadata, and the associated Taskfile:

metadata:
  models:
    fmimcl:
      name: fmimcl
      displayName: dse.fmi.mcl
      path: dse/fmimcl
      workflows:
        - generate-fmimcl
        - patch-signalgroup
  tasks:
    generate-fmimcl:
      vars:
        FMU_DIR:
          required: true
          hint: URI identifying an FMU (select from 'uses' or manually enter a path).
        OUT_DIR:
          required: true
          hint: Directory where the model should be created (sim relative).
          default: out/model
        MCL_PATH:
          required: true
          hint: Path where the FMI MCL shared library is located.
        FMU_MODELDESC:
          required: false
          hint: Path where the FMI modelDescription.xml should be created.
          default: '{{.FMU_DIR}}/modelDescription.xml'
        SIGNAL_GROUP:
          required: false
          hint: Path where the associated Signal Group should be created.
          default: '{{.OUT_DIR}}/signalgroup.yaml'
tasks:

  generate-fmimcl:
    desc: Generate an FMI MCL from an existing FMU.
    run: always
    dir: '{{.USER_WORKING_DIR}}'
    label: dse:fmi:generate-fmimcl
    vars:
      FMU_DIR: '{{.FMU_DIR | default "FMU_DIR_NOT_SPECIFIED"}}'
      OUT_DIR: '{{.OUT_DIR | default "out/model"}}'
      MCL_PATH: '{{.MCL_PATH | default "MCL_PATH_NOT_SPECIFIED"}}'
      FMU_MODELDESC: '{{.FMU_DIR}}/modelDescription.xml'
      SIGNAL_GROUP: "{{if .SIGNAL_GROUP}}'{{.SIGNAL_GROUP}}'{{else}}'{{.OUT_DIR}}/signalgroup.yaml'{{end}}"
    cmds:
      - task: gen-mcl
        vars:
          FMU_DIR: '{{.FMU_DIR}}'
          OUT_DIR: '{{.OUT_DIR}}'
          MCL_PATH: '{{.MCL_PATH}}'
      - task: gen-signalgroup
        vars:
          INPUT: '{{.FMU_MODELDESC}}'
          OUTPUT: '{{.SIGNAL_GROUP}}'
    requires:
      vars: [FMU_DIR, MCL_PATH]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: needs triage Waiting to be triaged by a maintainer.
Projects
None yet
Development

No branches or pull requests

2 participants