-
Notifications
You must be signed in to change notification settings - Fork 63
templates check: Add --stabilise flag to make renders reproducible
#5214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
be3ceff to
4793f53
Compare
crates/spa/src/vite.rs
Outdated
| for name in &[ | ||
| "src/shared.css", | ||
| "src/templates.css", | ||
| "src/main.tsx", | ||
| "src/swagger.ts", | ||
| ] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't particularly like that this list is hard-coded like that, especially since you might have a fork of the templates & assets that include extra assets handled by the vite build pipeline?
Instead, if feasible I would have a 'fake' version of include_assets that doesn't use the manifest at all?
crates/cli/src/commands/templates.rs
Outdated
| // XXX: we should disallow SeedableRng::from_entropy | ||
| let mut rng = rand_chacha::ChaChaRng::from_entropy(); | ||
| let now = if stabilise { | ||
| DateTime::from_timestamp_secs(0).unwrap() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use a more believable timestamp so that the IDs look like they are not all zeros?
|
|
||
| impl<T: TemplateContext> TemplateContext for WithCaptcha<T> { | ||
| fn sample( | ||
| fn sample<R: Rng + Clone>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmmm a cloneable Rng is a bit suspicious at this stage? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's only samples :D
| /// | ||
| /// Returns an error if any template fails to render with any of the sample. | ||
| pub(crate) fn all(templates: &Templates, now: chrono::DateTime<chrono::Utc>, rng: &mut impl rand::Rng) -> anyhow::Result<::std::collections::BTreeMap<(&'static str, SampleIdentifier), String>> { | ||
| pub(crate) fn all<R: Rng + Clone>(templates: &Templates, now: chrono::DateTime<chrono::Utc>, rng: &R) -> anyhow::Result<::std::collections::BTreeMap<(&'static str, SampleIdentifier), String>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of requiring a cloneable RNG here, we could seed a ChaChaRng out of the rng passed as parameter and clone it within the function. That would be a lot less suspicious :p
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, either one is suspicious, but at least this one is a bit less prolific so sure.
No description provided.