Skip to content

Pre-tasks and configuration do not mesh well #116

@bitprophet

Description

@bitprophet

Scenario:

  • Using a configured task/tree such as invocation.docs
  • Some other 'vanilla' task in the tree specifies one of those configured tasks in its pre-tasks list (e.g. @task('docs'))
  • Expected: the pre-task is able to find its configuration parameters, just as if it had been called by itself on the CLI
  • Instead: the pre-task is unable to find any config parameters.

Digging:

  • Config lookup is done based on the "name" of the task being executed
  • Right now that is always the actual task specified on the CLI; that may not be entirely accurate and should probably change to be the actual task being called (this is within the loop across "all tasks", aka post-expansion of pre/post tasks.
  • Further confusing things is that in my specific use case, I am calling a 'default' task and its name gets expanded at CLI parse time (probably due to use of aliases/Lexicons) when it's called directly, but this does not occur when it's used as a pre-task.
    • So e.g. $ inv docs has a "name" at execution time of docs.build, but when used as a pre-task it comes out as just build
  • Config lookup uses the "directory" or "package" level of a task name, so e.g. in the direct case, we see configuration('docs') called, but in the indirect case, it's configuration('').
  • I haven't gone past this yet but suspect this is the key, the config options are likely stored on the docs namespace and so any configuration() call not using docs won't load them.
  • So perhaps we need to do more seeking back up the object ref chain so a task knows where it is currently living/stored & thus which config to load?
    • Needs to not break existing config overriding patterns...
    • Feels like another way of saying "parser seeing docs and turning up docs.build needs to match the pre-task machinery seeing docs and ensure it also turns up docs.build"?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions