CircleCI-Public / circleci-cli

Use CircleCI from the command line
https://circleci-public.github.io/circleci-cli/
MIT License
411 stars 232 forks source link

Clarify `orb validate` and `config validate` scope of validation #937

Closed kelvintaywl closed 1 year ago

kelvintaywl commented 1 year ago

NOTE: this is not a BUG report, but just to clarify the behaviour of specific commands.

Meta:

CircleCI CLI Version:

$ circleci version
0.1.23489+901243e (homebrew)

Operating System:

Mac M1 (Ventura)

CircleCI CLI Diagnostic:

$ circleci diagnostic

---
CircleCI CLI Diagnostics
---
Debugger mode: false
Config found: /Users/kelvin/.circleci/cli.yml
API host: https://circleci.com
API endpoint: graphql-unstable
OK, got a token.
Trying an introspection query on API...
Ok.
Hello, Kelvin Tay.

Current behavior:

I'd like to just confirm/clarify, if both circleci config validate and circleci orb validate will validate steps even if the job steps is not supposed to run (e.g, condition: false).

Given the following file contents:

# .circleci/config.yml

version: 2.1

orbs:
  jira: circleci/jira@1.3.1

jobs:
  build:
    parallelism: 25
    docker:
      - image: cimg/base:current
    resource_class: small
    steps:
      - when:
          # NOTE: condition set to false, so the steps below would never run effectively
          condition: false
          steps:
            - jira/notify:
                # jira/notify only accepts certain values for environment_type, and "invalid" is not allowed
                environment_type: invalid

When we run validation checks:

$ circleci config validate
Error: Error calling workflow: 'workflow'
Error calling job: 'build'
Error calling command: 'jira/notify'
Type error for argument environment_type: expected type: enum ("production" "staging" "testing" "development" "unmapped"), actual value: "invalid" (type string)

The same can be seen for orb configs:

# orb.yml

version: 2.1

description: A greeting command orb

orbs:
  jira: circleci/jira@1.3.1

commands:
    greet:
        description: Greet someone with a "hello".
        parameters:
            to:
                type: string
                default: World
        steps:
          - when:
              condition: false
              steps:
                - jira/notify:
                    environment_type: invalid

When running validation checks:

$ circleci orb validate orb.yml
Error: Error calling command: 'greet'
Error calling command: 'jira/notify'
Type error for argument environment_type: expected type: enum ("production" "staging" "testing" "development" "unmapped"), actual value: "invalid" (type string)

Expected behavior:

I think this is expected behaviour; I believe the validation will check ALL steps, even if the condition may evaluate to false. I am trying to confirm if this is the case, on behalf of a customer :)

When did this begin / Was this previously working?:

Additional Information:

JulesFaucherre commented 1 year ago

Hey @kelvintaywl , I just got confirmation that steps are checked for any condition value. I close the issue but don't hesitate if you have any other question