Motivation
For my project, I want to check if all generated files are up to date by running dart run slang and get diff on GitHub Actions.
However, I found strings.g.dart is different between the one built on my Windows machine and the one built on GitHub Actions ubuntu-latest runner.
Motivation For my project, I want to check if all generated files are up to date by running
dart run slang
and get diff on GitHub Actions. However, I foundstrings.g.dart
is different between the one built on my Windows machine and the one built on GitHub Actions ubuntu-latest runner.Here is a simple example. https://github.com/poppingmoon/slang_sort_example
In this example, we have two input files,
lib/i18n/hello/hello.i18n.json
andlib/i18n/world/world.i18n.json
.I ran
dart run slang
locally and got the following outputs.Next, I pushed this code and triggered GitHub Actions workflow. https://github.com/poppingmoon/slang_sort_example/actions/runs/8540342484/job/23397146622#step:5:45 This time,
lib/i18n/world/world.i18n.json
came beforelib/i18n/hello/hello.i18n.json
, so the ordering instrings.g.dart
also differed.It seems
Directory.listSync
returns files in an arbitrary order and this is causing the issue.By sorting input files beforehand, files are always treated in the same order and output files should be reproducible.
This approach at least worked for my case. https://github.com/poppingmoon/slang/commit/0a7d041dab66e22b7349ef4a89e3156cbf203910 https://github.com/poppingmoon/slang_sort_example/actions/runs/8540394034/job/23397304286
Developer Experience How should devs use this new feature? Ex: There should be a new parameter called [...]