bitrise-workflow-editor icon indicating copy to clipboard operation
bitrise-workflow-editor copied to clipboard

Don't reformat and reorder the entire bitrise.yml file

Open GrahamBorland opened this issue 4 years ago • 2 comments

When you save a file using the offline workflow editor, it reformats and reorders everything in the file. It gives completely different output from the online version of the editor at https://app.bitrise.io/.

This makes it impossible to do a meaningful code-review of the changes you make.

We have to use the offline editor to make changes to our bitrise.yml on a branch, to be reviewed and merged in a PR. The online editor only works on the repo's default branch which is why we can't use it.

For example, here's the result of taking a file which was originally generated by the online editor, and then making a tiny change in the offline editor.

It's reformatted and reordered EVERYTHING.

image

GrahamBorland avatar Mar 24 '21 09:03 GrahamBorland

The root cause for this seems to be that the GET /api/bitrise-yml.json endpoint of the local API server doesn't do a YAML to JSON conversion but parses the data into a models.BitriseDataModel structure which it then serializes to JSON.

https://github.com/bitrise-io/bitrise-workflow-editor/blob/f7a00bc429c5b6b8018b99d7aa99f236415e0bfd/apiserver/service/bitrise_config.go#L97-L102

The order of the fields inside the BitriseDataModel is not the same as the one that's used for the Bitrise production server.

https://github.com/bitrise-io/bitrise-workflow-editor/blob/f7a00bc429c5b6b8018b99d7aa99f236415e0bfd/vendor/github.com/bitrise-io/bitrise/models/models.go#L97-L112

Two ways out of this situation that come to mind:

  • Convert YAML directly to JSON, or
  • reorder the fields inside BitriseDataModel and its substructures to match whatever the prod server does.

tiwoc avatar Mar 24 '21 10:03 tiwoc

We recently ran into this issue as well. Some of our devs use the editor on bitrise.io and others run the editor locally. This usually causes large and messy diffs when committing the yml file back to our repo.

CraigSiemens avatar May 11 '23 18:05 CraigSiemens