Skip to content
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

Respect SOURCE_DATE_EPOCH environment variable (if set) over Time.now #7187

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

lamby
Copy link

@lamby lamby commented Aug 18, 2018

Whilst working on the Reproducible Builds effort [0], we noticed
that jekyll builds sites that are not reproducible.

This is because site.time uses the current time of day and thus
anything then shipping a Jekyll site (eg. as documentation) will
therefore not be reproducible.

This commit prefers the value in the SOURCE_DATE_EPOCH environment
variable [1] if it is set and config.time is also not set.

[0] https://reproducible-builds.org/
[1] https://reproducible-builds.org/specs/source-date-epoch/

Whilst working on the Reproducible Builds effort [0], we noticed
that jekyll builds sites that are not reproducible.

This is because site.time uses the current time of day and thus
anything then shipping a Jekyll site (eg. as documentation) will
therefore not be reproducible.

This commit prefers the value in the SOURCE_DATE_EPOCH environment
variable [1] if it is set and config.time is also not set.

 [0] https://reproducible-builds.org/
 [1] https://reproducible-builds.org/specs/source-date-epoch/
@ghost
Copy link

ghost commented Aug 18, 2018

@lamby Can you fix the RuboCop offense as well as add a simple test? Thanks so much!

@ashmaroli
Copy link
Member

@DirtyF For a given Jekyll::Site instance site, calling site.now should not set site.time. Only site.reset should do that..
So can I request you to amend your commit to simply do the following:

def reset
  self.time = now
  self.layouts = {}
  self.pages = []
  [...]
end

# preferably a private method
def now
  # your implementation
end

@ashmaroli ashmaroli force-pushed the site-time-use-source-date-epoch branch from 32cda73 to 981dd27 Compare August 19, 2018 06:15
Krinkle added a commit to Krinkle/jekyll-feed that referenced this pull request Mar 27, 2022
Two main uses cases:

1. Reduce deployment churn in repositories that hold a docsite in
   addition to source code. These currently regenerate and find
   something new commit on every change, even when nothing in the
   site has been changed. The only file changing each time is
   feed.xml.
   For example: https://github.com/qunitjs/qunit/commits/gh-pages

2. Improve reproducibility of the build, as highlighted via
   jekyll/jekyll#7187, by offering a choice
   that simply eliminates use of current time entirely, not even
   having to mock it.
Krinkle added a commit to Krinkle/jekyll-feed that referenced this pull request Sep 19, 2022
Primary uses cases:

1. Reduce deployment churn in repositories that hold a docsite in
   addition to source code. These repositories currently regenerate
   and find "changed" files to deploy on every commit, even when
   nothing in the Jekyll site was changed. The only artefact changing
   each time is `feed.xml`.

   For example: https://github.com/qunitjs/qunit/commits/gh-pages

2. Improve reproducibility of the build, as highlighted via
   jekyll/jekyll#7187. By offering a choice
   that simply eliminates use of current time entirely, we do not
   even have to worry about mocking it.
Krinkle added a commit to Krinkle/jekyll-feed that referenced this pull request Sep 19, 2022
Primary uses cases:

1. Reduce deployment churn in repositories that hold a docsite in
   addition to source code. These repositories currently regenerate
   and find "changed" files to deploy on every commit, even when
   nothing in the Jekyll site was changed. The only artefact changing
   each time is `feed.xml`.

   For example: https://github.com/qunitjs/qunit/commits/gh-pages

2. Improve reproducibility of the build, as highlighted via
   jekyll/jekyll#7187. By offering a choice
   that simply eliminates use of current time entirely, we do not
   even have to worry about mocking it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants