Skip to content

Commit

Permalink
Final improvements to make tests pass on GitHub CI (#86)
Browse files Browse the repository at this point in the history
* Update more test artifacts

* Update .gitignore

* Update draft filter

* Update default-article-info.yaml

* Update draft.lua

* Add notes on running locally

* Update entrypoint.sh

* Update Makefile

* Use source date epoch for draft publication time

* Update CHANGELOG.md
  • Loading branch information
cthoyt authored Sep 17, 2024
1 parent c430b5b commit e241d32
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 12 deletions.
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,13 @@ example/paper.tex
/test/JATS-Publishing-1-2-MathML2-XSD.zip
/test/JATS-journalpublishing1-elements.xsd
/test/JATS-journalpublishing1.xsd
/test/standard-modules
/test/standard-modules

# If you copy the resources into the base directory to
# make the Makefile work, don't accidentally commit these
apa.csl
default-article-info.yaml
footer.csl
/joss
/jose
/resciencec
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

`Inara` uses [SemVer][] (semantic versioning).

## Inara v1.1.2
## UNRELEASED

- Fix bug in application of `prepare-affiliations.lua` filter (Charles Tapley Hoyt)
- Fix a bug in the injection of `SOURCE_DATE_EPOCH` (https://github.com/openjournals/inara/pull/86) in tests
- Fix test files (https://github.com/openjournals/inara/pull/86, https://github.com/openjournals/inara/pull/85)
- Switch testing to work on tex instead of pdf (https://github.com/openjournals/inara/pull/82)
- Refactor testing folders (https://github.com/openjournals/inara/pull/84)

## Inara v1.1.1

Expand Down
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ ARTICLE_INFO_FILE = $(OPENJOURNALS_PATH)/default-article-info.yaml

IMAGE = openjournals/inara:edge

MAKEFILE_DIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))

.PHONY: all
all: cff pdf tex html jats crossref native preprint

Expand Down Expand Up @@ -92,13 +94,23 @@ clean:

## Tests

# Note that SOURCE_DATE_EPOCH=1234567890 corresponds to 1234567890 seconds
# from the unix epoch (January 1, 1970), which is in 2009

# Command used to invoke Inara. Sets an environment variable that makes the
# program ignore the real date.
INARA_TEST_CMD = docker run --rm \
--user $(shell id -u):$(shell id -g) \
--env SOURCE_DATE_EPOCH=1234567890 \
-v $${PWD}:/data $(IMAGE)

# Uncomment this if you want to run tests locally instead of inside docker,
# though note that there might be non-trivial differences that are hard to explain.
# You also have to run `cp -r resources/* .` to copy all of the resource files
# into the root directory, since this makefile relies on this directory structure
# which the dockerfile creates
# INARA_TEST_CMD = SOURCE_DATE_EPOCH=1234567890 JOURNAL=joss OPENJOURNALS_PATH=$(MAKEFILE_DIR) sh scripts/entrypoint.sh

.PHONY: test test-golden-draft test-golden-pub
test: test-golden-draft test-golden-pub
test-golden-draft: \
Expand Down
13 changes: 10 additions & 3 deletions data/filters/draft.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
--- Removes and alters metadata for draft output

--- If you change this, please keep it in sync with
--- resources/default-article-info.yaml
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 = '0'
meta.article.volume = '0'
meta.article.issue = '¿ISSUE?'
meta.article.volume = '¿VOL?'
meta.published = 'unpublished'
meta.published_parts = os.date('*t')
meta.published_parts = os.date('*t', epoch)
return meta
end
end
5 changes: 4 additions & 1 deletion resources/default-article-info.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# If you change this, please keep it in sync with
# data/filters/draft.lua

metadata:
archive_doi: 'DOI unavailable'
editor_url: 'https://example.com'
Expand All @@ -7,7 +10,7 @@ metadata:
editor_name: 'Pending Editor'
issue: '¿ISSUE?'
page: '¿PAGE?'
published_at: '1970-01-01'
published_at: 'unpublished'
reviewers:
- 'Pending Reviewers'
submitted_at: '1970-01-01'
Expand Down
3 changes: 2 additions & 1 deletion scripts/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ for format in $(printf "%s" "$outformats" | sed -e 's/,/ /g'); do
# inara git repo that is created in Docker, in which the contents of
# the resources/ directory is copied into the root directory
# 3. assumes pandoc is in a certain location. Switch `/usr/local/bin/pandoc`
# to just `pandoc` locally
# to just `pandoc` locally, or symlink with
# sudo ln -s $which(pandoc) /usr/local/bin/pandoc
/usr/local/bin/pandoc \
--data-dir="$OPENJOURNALS_PATH"/data \
--defaults=shared \
Expand Down
13 changes: 8 additions & 5 deletions test/expected-draft/paper.tex
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
pdfpubtype={journal},
pdfvolumenum={},
pdfissuenum={},
pdfdoi={N/A},
pdfdoi={10.xxxxxx/draft},
pdfcopyright={Copyright (c) 1970, Albert Krewinkel, Juanjo Bazán,
Arfon M. Smith},
pdflicenseurl={http://creativecommons.org/licenses/by/4.0/},
Expand Down Expand Up @@ -136,9 +136,9 @@
\renewcommand{\footrulewidth}{0.25pt}

\fancyfoot[L]{\parbox[t]{0.98\headwidth}{\footnotesize{\sffamily Krewinkel
et al. (1970). Article Writing with Markdown and the Open Journals
et al. (2009). Article Writing with Markdown and the Open Journals
publishing pipeline. \emph{Journal of Open Source Software},
\emph{¿VOL?}(¿ISSUE?), ¿PAGE? \url{https://doi.org/N/A}}.}}
\emph{¿VOL?}(¿ISSUE?), ¿PAGE? \url{https://doi.org/10.xxxxxx/draft}}.}}


\fancyfoot[R]{\sffamily \thepage}
Expand Down Expand Up @@ -316,6 +316,9 @@
\newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{#1}}
\newcommand{\WarningTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{#1}}}}
\usepackage{longtable,booktabs,array}
\usepackage{lineno}
\linenumbers
\usepackage{draftwatermark}

\usepackage{graphicx,grffile}
\makeatletter
Expand Down Expand Up @@ -394,7 +397,7 @@
%\hrule
\sffamily\small

{\bfseries DOI:} \href{https://doi.org/N/A}{\color{linky}{N/A}}
{\bfseries DOI:} \href{https://doi.org/10.xxxxxx/draft}{\color{linky}{10.xxxxxx/draft}}

\vspace{2mm}
{\bfseries Software}
Expand Down Expand Up @@ -423,7 +426,7 @@
\vspace{2mm}

{\bfseries Submitted:} 01 January 1970\\
{\bfseries Published:} 01 January 1970
{\bfseries Published:} unpublished

\vspace{2mm}
{\bfseries License}\\
Expand Down

0 comments on commit e241d32

Please sign in to comment.