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

Automatic update examples with correct version of the orb #134

Open
Gaardsholt opened this issue Mar 19, 2022 · 3 comments
Open

Automatic update examples with correct version of the orb #134

Gaardsholt opened this issue Mar 19, 2022 · 3 comments

Comments

@Gaardsholt
Copy link
Contributor

Describe Request:

It would be great if we could use a template value/variable to always have the examples show the correct version of the orb.

Examples:

Instead of writing the examples like this:

usage:
  version: 2.1
  orbs:
    my-orb: my-namespace/my-orb@dev:1.2.3

We could do something like this:

usage:
  version: 2.1
  orbs:
    my-orb: my-namespace/my-orb@${{ORB_VERSION}}

Supporting Documentation Links:

@KyleTryon
Copy link
Contributor

I am interested. Highly considering this.

A few questions / considerations.

  1. What would you expect to happen if you used ${{ORB_VERSION}} (we would like use a syntax similar to << orb.prod.version >>) in an orb that was not your own in the situation where more than one orb is used.
  2. In the event a major change is made, the usage examples may incorrectly show out-of-date examples.
    a. If you hard code the version numbers we could at least state that usage example is accurate to the version displayed
    b. Counter-point, if you already use an x.y.z structure as we often do, there is no reason not to.
  3. We may need to consider what will be valid when running circleci config validate against the example.
  4. Would we want to enforce this as a new "RC" review check?

I think this is feasible. The publish job would use the CircleCI tag when publishing the orb to make an on-the-fly replacement of the template text. I think an expectation would need to be set that this is simply using the tag version in the pipeline and would only be valid on the orb being built, and should not be used on another orb.

Examples

#2da44e GOOD

usage:
  version: 2.1
  orbs:
    my-orb: my-namespace/my-orb@<< orb.prod.version >>

#cf222e BAD

usage:
  version: 2.1
  orbs:
    my-orb: my-namespace/my-orb@<< orb.prod.version >>
    jq: circleci/jq@<< orb.prod.version >>

It should be possible to warn the user if we know the orb name and namespace, and ensure it is only used on matching lines.

@Gaardsholt
Copy link
Contributor Author

Sorry for not replying, I totally forgot about this issue !

My comments on your points:

  1. I would expect it to be replaced with the published version - I don't care if we use ${{ORB_VERSION}} or @<< orb.prod.version >>.
  2. I would say that it is up to the orb author to make sure the examples are updated when doing a major change.

@Gaardsholt
Copy link
Contributor Author

Is this something that is being worked on?

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

No branches or pull requests

2 participants