CircleCI-Public / orb-tools-orb

Various tools for authoring and publishing CircleCI orbs
https://circleci.com/orbs/registry/orb/circleci/orb-tools
MIT License
51 stars 74 forks source link

Major: Orb Tools Version 12 #181

Closed KyleTryon closed 1 year ago

KyleTryon commented 1 year ago

Orb Tools 12

⭐ Dynamic Orb Injection Without Publication

The major goal of this PR is to decrease friction in orb contributions. Currently, in order to contribute to an orb, you must have access to a secured Restricted Context in CircleCI which contains a publishing token, so that a development version of the orb may be tested in the following dynamic workflow. This means, when a contributor opens a PR, they must wait for a maintainer to re-push the code for the proper permissions. This slows down the dev cycle a lot.

With this change, rather than publishing a new development version of the orb, we modify the dynamic config template to inject the orb source as an "internal" orb within the continue job. This has the same net-effect for testing your orbs but not longer requires access to secrets, eliminating blockers top the PR process.

Other Improvements

Blocked By

wyardley commented 1 year ago

Was it intentional to remove resource_class (e.g. from the publish step)?

KyleTryon commented 1 year ago

Hey @wyardley Yes! We changed away from statically defined images, where we were required to pass through parameters such as resource_class, simply to a parameterized executor. This gives a lot more flexibility outside of just resource class, but also any parameter that might exist for any executor you choose.

You should now be able to do something like looks like this:

orbs:
  orb-tools: circleci/orbtools@12
executors:
  my-exec:
    docker:
      - image: cimg/base:stable
    resource_class: small

workflows:
  example:
    jobs:
      - orb-tools/pack:
          executor: my-exec

Now the executor can come from anywhere, such as an orb, or be defined locally. When defined, or redefined locally, we can pass any parameters we want into the definition of the executor.

wyardley commented 1 year ago

Now the executor can come from anywhere, such as an orb, or be defined locally

Probably should have been called out in the migration guide and / or breaking changes for 12.x?

IIRC, this used to not be possible? Can you give an example of using an upstream orb, but overriding a parameter like resource_class?

For me, the following gives an error

orbs:
  orb-tools: circleci/orb-tools@12.0.0
executors:
  orb-tools:
    name: orb-tools/default
    resource_class: small
workflows:
  test-pack:
    jobs:
      - orb-tools/lint:
          executor: orb-tools
{2. [#/executors/orb-tools] extraneous key [name] is not permitted}

IIRC, this used to be impossible, but maybe something has changed and I just have the wrong syntax?

(and, if it's not possible anymore, what can https://github.com/CircleCI-Public/orb-tools-orb/blob/d82dc2573e58a893284a186bb2895ccceb89857e/src/executors/default.yml#L11-L15 be used for now?)