-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make RandomExample/RandomItemGenerator deterministic (use seed)
We're now building govuk-developer-docs hourly, but our heavy use of GovukSchemas::RandomExample is causing ~50,000 line changes for every commit to gh-pages, despite the underlying schemas remaining unchanged. We want the example to be random and schema-validated, but not necessarily a new random on every build. Hence we would like to set the 'seed' so that we can predictably execute the same random generation every time. In theory, this means our gh-pages output will be identical between builds until an underlying schema changes. govuk_schemas did not support this out of the box because of its reliance on SecureRandom, which, as the name implies, does not allow outside interference/configuration by way of seed values (it gives a truly random result every time). We don't _need_ a 'secure' random output - just something we can be reasonably confident will give a different result every time if the seed is omitted. I've reproduced its 'uuid' and 'hex' methods using arrays of chars/numbers and the native 'rand' method, which _does_ respect the global seed value.
- Loading branch information
1 parent
0551260
commit e491224
Showing
3 changed files
with
41 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters