ForNeVeR / ForNeVeR/Generaptor

Yaml Serializer Not Deterministic Across Systems

Open
#134 4 comments 0 reactions 0 assignees View on GitHub
enhancement good first issue help wanted
Dominant language
F#
Stars
50
Forks
2
PR merge metrics
No merged PRs in 30d

Description

I got different outputs on Linux and Windows. There is a well-known bug in [YamlDotNet](https://github.com/aaubry/YamlDotNet) about how multi-line strings are handled (e.g., [Issue #520](https://github.com/aaubry/YamlDotNet/issues/520)).

Since Windows systems use '\r\n' as a line break marker, we have to normalize a string before passing it through the serializer.

Example:

```fsharp
[]
let ``Multiline string``(): unit =
let wf = workflow "wf" [
job "main" [
runsOn "ubuntu-latest"
step(
name = "Save Docker image",
run = """mkdir -p /tmp
docker save myimage:latest -o /tmp/myimage.tar
echo "Docker image saved successfully"
"""
)
]
]
let expected = """on: {}
jobs:
main:
runs-on: ubuntu-latest
steps:
- name: Save Docker image
run: |
mkdir -p /tmp
docker save myimage:latest -o /tmp/myimage.tar
echo "Docker image saved successfully"
"""
doTest expected wf
```

This test passes on Linux, but fails on Windows:
```sh
Assert.Equal() Failure: Strings differ
↓ (pos 101)
Expected: ···"r image\n run: |\n mkdir -p /tm"···
Actual: ···"r image\n run: |+\n mkdir -p /t"···

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.