harness / harness-migrate

Harness CI migration utility
https://www.harness.io/products/continuous-integration
Apache License 2.0
9 stars 4 forks source link

[circle] downgrade loses all but first workflow #122

Closed jimsheldon closed 1 year ago

jimsheldon commented 1 year ago

Here is a circle pipeline

version: 2.1
jobs:
  build:
    docker:
      - image: cimg/base:2023.03
    steps:
      - checkout
      - run:
          name: build
          command: echo "this is the build job"
  test:
    docker:
      - image: cimg/base:2023.03
    steps:
      - checkout
      - run:
          name: test
          command: echo "this is the test job"
workflows:
  build:
    jobs:
      - build
  test:
    jobs:
      - test

When converting to downgraded yaml, this is the result

pipeline:
  identifier: default
  name: default
  orgIdentifier: default
  projectIdentifier: default
  properties:
    ci:
      codebase:
        build: <+input>
  stages:
  - stage:
      identifier: build1
      name: build
      spec:
        cloneCodebase: true
        execution:
          steps:
          - step:
              identifier: build
              name: build
              spec:
                command: echo "this is the build job"
                image: cimg/base:2023.03
              timeout: ""
              type: Run
        platform:
          arch: Amd64
          os: Linux
        runtime:
          spec: {}
          type: Cloud
      type: CI

Only the first workflow comes through.

Without downgrading, this is the result

stages:
- name: test
  spec:
    platform:
      arch: amd64
      os: linux
    runtime:
      spec: {}
      type: cloud
    steps:
    - name: test
      spec:
        image: cimg/base:2023.03
        run: echo "this is the test job"
      type: script
  type: ci
version: 1

---
stages:
- name: build
  spec:
    platform:
      arch: amd64
      os: linux
    runtime:
      spec: {}
      type: cloud
    steps:
    - name: build
      spec:
        image: cimg/base:2023.03
        run: echo "this is the build job"
      type: script
  type: ci
version: 1

Each workflow is a separate pipeline delimited by ---. Downgrading should have the same behavior, multiple pipelines should be generated with a delimiter.

pipeline:
  identifier: default
  name: default
  orgIdentifier: default
  projectIdentifier: default
  properties:
    ci:
      codebase:
        build: <+input>
  stages:
  - stage:
      identifier: test1
      name: test
      spec:
        cloneCodebase: true
        execution:
          steps:
          - step:
              identifier: test
              name: test
              spec:
                command: echo "this is the test job"
                image: cimg/base:2023.03
              timeout: ""
              type: Run
        platform:
          arch: Amd64
          os: Linux
        runtime:
          spec: {}
          type: Cloud
      type: CI

---
pipeline:
  identifier: default
  name: default
  orgIdentifier: default
  projectIdentifier: default
  properties:
    ci:
      codebase:
        build: <+input>
  stages:
  - stage:
      identifier: build1
      name: build
      spec:
        cloneCodebase: true
        execution:
          steps:
          - step:
              identifier: build
              name: build
              spec:
                command: echo "this is the build job"
                image: cimg/base:2023.03
              timeout: ""
              type: Run
        platform:
          arch: Amd64
          os: Linux
        runtime:
          spec: {}
          type: Cloud
      type: CI
jimsheldon commented 1 year ago

Fix in https://github.com/drone/go-convert/pull/129