Skip to content

Final improvements to make tests pass on GitHub CI #86

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

Merged
merged 11 commits into from
Sep 17, 2024

Conversation

cthoyt
Copy link
Contributor

@cthoyt cthoyt commented Sep 17, 2024

This is the last PR that finally makes the unit tests work. This PR also adds several other notes to help future contributors understand the workflow, and get it running locally.

Details on an issue we solved during this PR related to SOURCE_DATE_EPOCH

The expected-draft/paper.tex which outputs the current year. This gets there because of the following code:

  1. \fancyfoot[L]{\parbox[t]{0.98\headwidth}{\footnotesize{\sffamily $self-citation$}.}}
  2. self-citations is added in
    ['date-parts'] = {{meta.published_parts.year}}
  3. which gets set in
    meta.published_parts = os.date('*t')
  4. which comes from
    local epoch = os.getenv 'SOURCE_DATE_EPOCH'
  5. which in theory, is modulated by setting the SOURCE_DATE_EPOCH in

    inara/Makefile

    Lines 97 to 100 in c430b5b

    INARA_TEST_CMD = docker run --rm \
    --user $(shell id -u):$(shell id -g) \
    --env SOURCE_DATE_EPOCH=1234567890 \
    -v $${PWD}:/data $(IMAGE)

I think it's probably a fair compromise to remind ourselves once per year to update this rather than hacking more conditionals in there (at least on this pass)

@cthoyt cthoyt changed the title Improve tests, round 3 Final improvements to make tests pass on GitHub CI Sep 17, 2024
@tarleb
Copy link
Collaborator

tarleb commented Sep 17, 2024

Can we set SOURCE_DATE_EPOCH somewhere? That should make Inara use the given time instead of the current year.

@cthoyt
Copy link
Contributor Author

cthoyt commented Sep 17, 2024

Thanks for the idea. In theory, it's set here:

inara/Makefile

Lines 97 to 100 in c430b5b

INARA_TEST_CMD = docker run --rm \
--user $(shell id -u):$(shell id -g) \
--env SOURCE_DATE_EPOCH=1234567890 \
-v $${PWD}:/data $(IMAGE)

which should get propagated through, but I'm not sure it's working correctly

@cthoyt
Copy link
Contributor Author

cthoyt commented Sep 17, 2024

@tarleb is the solution to change draft.lua to also look up the source date epoch? it doesn't seem like it reaches anywhere to check that as is

function Meta (meta)
  if meta.draft and meta.draft ~= '' then
    local epoch = os.getenv 'SOURCE_DATE_EPOCH'
      and os.time { year = 1970, month = 1, day = 1, hour = 0, min = 0,
                  sec = tonumber(os.getenv 'SOURCE_DATE_EPOCH') }
      or os.time()
    meta.article.doi = '10.xxxxxx/draft'
    meta.article.issue = '¿ISSUE?'
    meta.article.volume = '¿VOL?'
    meta.published = 'unpublished'
    meta.published_parts = os.date('*t', epoch)
    return meta
  end
end

though when I do this, the published date becomes something from 2009, is that sounding correct?

@tarleb
Copy link
Collaborator

tarleb commented Sep 17, 2024

👍 that looks like the right thing to do.

@cthoyt
Copy link
Contributor Author

cthoyt commented Sep 17, 2024

@tarleb okay, all done

@tarleb
Copy link
Collaborator

tarleb commented Sep 17, 2024

Awesome, thanks!!

@tarleb tarleb merged commit e241d32 into openjournals:main Sep 17, 2024
1 check passed
@cthoyt cthoyt deleted the fix-tests-3 branch September 17, 2024 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants