Skip to content
This repository has been archived by the owner on Dec 15, 2020. It is now read-only.

explore options for value expansion #35

Closed
mattsb42-aws opened this issue May 15, 2019 · 1 comment
Closed

explore options for value expansion #35

mattsb42-aws opened this issue May 15, 2019 · 1 comment

Comments

@mattsb42-aws
Copy link
Contributor

There are many cases where what you want to define is "everything the same for each of these [X] actions, but change this one thing".

Ideally, this should not require someone to re-write the entire action definition, but instead simply provide some syntax to expand.

Some prior art for this type of behavior includes Tox's factor expansion[1] and Travis CI's build matrix[2].

There are a few different options that I am considering for how to support this.

We need to determine what route we want to take here and how to approach that.

List Expansion

List expansion works similarly to Tox's factor expansion.

If a string that is a member of a list contains values enclosed by braces, that string is removed from the list and replaced with a member for each possible combination of values defined in the original string.

# Source
value:
  - 3.5.{4,5,6}
  - 3.{6,7}.{0,1}
 
# Result
value:
  - 3.5.4
  - 3.5.5
  - 3.5.6
  - 3.6.0
  - 3.6.1
  - 3.7.0
  - 3.7.1

List Expansion

List expansion is more like an in-line version of Travis CI's build matrix.

Any values that expect strings and are provided lists of strings are used to all possible combinations.

# Source
example:
  name: MyName
  value:
    - value 1
    - value 2
  another:
    - value 3
    - value 4
 
# Result
example:
  -
    name: MyName
    value: value 1
    another: value 3
  -
    name: MyName
    value: value 1
    another: value 4
  -
    name: MyName
    value: value 2
    another: value 3
  -
    name: MyName
    value: value 2
    another: value 3

Template Definitions

Provide a way of defining an action template, then provide an action plugin (dependent on #27) that takes a template name an a list of values.

templates:
    run-python:
        parameters:
            - toxenv
            - image
        template:
            provider: CodeBuild
            image: {PARAMETER:image}
            buildspec: buildspec.yaml
            env:
                TOXENV: {PARAMETER:toxenv}
            inputs:
                - SourceOutput

pipeline:
    source:
        ...
    build:
        - provider: TemplateLoader
          template: run-python
          parameters:
              - toxenv: py36-local
                image: aws/codebuild/python:3.6.5
              - toxenv: py36-integ
                image: aws/codebuild/python:3.6.5

[1] https://tox.readthedocs.io/en/latest/config.html#complex-factor-conditions
[2] https://docs.travis-ci.com/user/build-matrix/

@mattsb42-aws
Copy link
Contributor Author

Closing down project: #52

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant