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

{Type error for argument version: expected type: integer, actual value: "1" (type string)}] after updating 0.1.23845 -> 0.1.25569 #895

Closed emmeowzing closed 1 year ago

emmeowzing commented 1 year ago

Meta:

CircleCI CLI Version: 0.1.25569

Operating System: cimg/python:3.10.9

CircleCI CLI Diagnostic:

$ circleci diagnostic

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

Current behavior:

$ circleci config validate .circleci/premiscale.yml 
No org id or slug has been provided
Error: config compilation contains errors: [{Error calling workflow: 'premiscale'} {Error calling job: 'release-twine-setup-py'} {Type error for argument version: expected type: integer, actual value: "1" (type string)}]

Also here: https://app.circleci.com/pipelines/github/premiscale/premiscale/511/workflows/083fe6b8-0039-46bb-bb70-caeb8edcf371/jobs/2592?invite=true#step-107-5

Expected behavior:

Should be the same as the previous version, I think? So

$ circleci config validate .circleci/premiscale.yml 
You are running 0.1.23845
A new release is available (0.1.25569)
You can update with `circleci update install`

Validating config with following values
    git.base_revision:  960800bf119849aac88dcecb33ec6f9f2f3384ec    id: 00000000-0000-0000-0000-000000000001    number: 1   project.git_url:    https://github.com/premiscale/premiscale    project.type:   github  git.tag:        git.branch: ENG-148 git.revision:   960800bf119849aac88dcecb33ec6f9f2f3384ecConfig file at .circleci/premiscale.yml is valid.

When did this begin / Was this previously working?:

It worked on version 0.1.23845, now it's broken on version 0.1.25569 following running circleci update install.

Additional Information: N/A

emmeowzing commented 1 year ago

For context / reproducing, I've created a job in my CI config

  release-twine-setup-py:
    description: twine upload
    docker:
      - image: my-registry/python-3-10:v1.0.1
        auth:
          username: $DOCKER_USERNAME
          password: $DOCKER_PASSWORD
    resource_class: << parameters.resource-class >>
    environment:
      TWINE_NON_INTERACTIVE: true
    parameters:
      resource-class:
        type: enum
        enum:
          - small
          - medium
          - large
          - xlarge
          - 2xlarge
        default: small
        description: Resource class to run as.
      user:
        description: PyPi username.
        type: string
        default: $TWINE_USERNAME
      password:
        description: PyPi API token.
        type: string
        default: $TWINE_PASSWORD
      repository:
        description: Repository name to upload to. Must have a URL set in .pypirc.
        type: string
        default: python
      config:
        description: Location of the .pypirc-file to use.
        type: string
        default: .pypirc
      version:
        description: Override the version of the uploaded artifact in pyproject.toml. Mainly for development pipelines.
        type: integer
        default: -1
    steps:
      - checkout
      - install-poetry
      - unless:
          condition:
            equal: [<< parameters.version >>, -1]
          steps:
            - run:
                name: Update pyproject.toml version
                command: |
                  _VERSION="$(grep -oiP "(?<=version = \").*(?=\")" pyproject.toml)"

                  if [[ "$_VERSION" =~ ^[0-9]+.[0-9]+.[0-9]+$ ]]; then
                      sed "s@version = \"${_VERSION}\"@version = \"0.0.<< parameters.version >>\"@" pyproject.toml > pyproject.toml.tmp
                  elif [[ "$_VERSION" =~ ^[0-9]+.[0-9]+.[0-9]+a[0-9]+$ ]]; then
                      _VERSION_A="${_VERSION%%a*}"
                      sed "s@version = \"${_VERSION}\"@version = \"0.0.<< parameters.version >>\"@" pyproject.toml > pyproject.toml.tmp
                  fi

                  mv pyproject.toml.tmp pyproject.toml
            # - run:
            #     name: Update setup.py version
            #     command: |
            #       _VERSION="$(grep -oiP "(?<=version=\').*(?=\',)" setup.py)"

            #       if [[ "$_VERSION" =~ ^[0-9]+.[0-9]+.[0-9]+$ ]]; then
            #           sed "s@version=\'${_VERSION}\'@version=\'0.0.<< parameters.version >>\'@" setup.py > setup.py.tmp
            #       elif [[ "$_VERSION" =~ ^[0-9]+.[0-9]+.[0-9]+a[0-9]+$ ]]; then
            #           _VERSION_A="${_VERSION%%a*}"
            #           sed "s@version=\'${_VERSION}\'@version=\'0.0.<< parameters.version >>\'@" setup.py > setup.py.tmp
            #       fi

            #       mv setup.py.tmp setup.py
      - run:
          name: Build package
          command: |
            poetry build
      - run:
          name: Publish package to PyPI
          command: |
            pip install twine
            twine upload dist/* -u << parameters.user >> -p << parameters.password >> --repository << parameters.repository >> --non-interactive --config-file << parameters.config >>

and I call it in my workflow like

      - release-twine-setup-py:
          name: twine upload [python-develop]
          context: nexus
          repository: python-develop
          version: << pipeline.number >>
          requires:
            - pylint [python-develop]
          filters:
            branches:
              ignore:
                - master

and from what I see in the docs (https://circleci.com/docs/pipeline-variables/), << pipeline.number >> is of type integer. Plus, it worked on version 0.1.23845, but breaks in version 0.1.25569.