bitrise-workflow-editor
bitrise-workflow-editor copied to clipboard
Don't reformat and reorder the entire bitrise.yml file
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.

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
BitriseDataModeland its substructures to match whatever the prod server does.
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.