diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml new file mode 100644 index 0000000..ee0f97e --- /dev/null +++ b/.github/workflows/validate.yaml @@ -0,0 +1,25 @@ +name: JATS validation + +on: + push: + paths: + - 'test/expected-paper.jats/paper.jats' + pull_request: + paths: + - 'test/expected-paper.jats/paper.jats' + +jobs: + build: + name: Verify expected JATS + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Install XML validator + run: | + sudo apt install libxml2-utils + + - name: Test image + run: | + make validate-jats diff --git a/.gitignore b/.gitignore index e0124dc..b34a412 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,9 @@ /example/paper.jats /example/paper.crossref /example/paper.preprint.tex + +# JATS schema files +/test/JATS-Publishing-1-2-MathML2-XSD.zip +/test/JATS-journalpublishing1-elements.xsd +/test/JATS-journalpublishing1.xsd +/test/standard-modules \ No newline at end of file diff --git a/Makefile b/Makefile index 3138103..e69371d 100644 --- a/Makefile +++ b/Makefile @@ -69,18 +69,23 @@ clean: rm -rf $(TARGET_FOLDER)/paper.pdf rm -rf $(TARGET_FOLDER)/paper.preprint rm -rf $(TARGET_FOLDER)/paper.preprint.tex + rm -rf test/JATS-Publishing-1-2-MathML2-XSD.zip + rm -rf test/JATS-journalpublishing1-elements.xsd + rm -rf test/JATS-journalpublishing1.xsd + rm -rf test/standard-modules + rm -rf /tmp/JATS-Publishing-1-2-MathML2-XSD ## Tests # Command used to invoke Inara. Sets an environment variable that makes the # program ignore the real date. -INARA_TEST_CMD = docker run --rm -it \ +INARA_TEST_CMD = docker run --rm \ --env SOURCE_DATE_EPOCH=1234567890 \ -v $${PWD}:/data openjournals/inara:latest -.PHONY: test golden-tests test-jats test-% -test: golden-tests +.PHONY: test test-golden test-jats test-% +test: test-golden test-golden: test-crossref test-jats test-pdf test-preprint @@ -91,3 +96,18 @@ test-%: $(INARA_TEST_CMD) -o $* example/paper.md diff example/$(GOLDEN_FILE) test/expected-$(GOLDEN_FILE) +NCBI_FTP = "ftp://ftp.ncbi.nih.gov/pub/jats/publishing/1.2/xsd/" +test/JATS-Publishing-1-2-MathML2-XSD.zip: + curl --output $@ \ + "$(NCBI_FTP)/JATS-Publishing-1-2-MathML2-XSD.zip" + +test/JATS-journalpublishing1.xsd: \ + test/JATS-Publishing-1-2-MathML2-XSD.zip + unzip -q -d /tmp $< + cp -a /tmp/JATS-Publishing-1-2-MathML2-XSD/* test + rm -rf /tmp/JATS-Publishing-1-2-MathML2-XSD + +.PHONY: validate-jats +validate-jats: test/expected-paper.jats/paper.jats \ + test/JATS-journalpublishing1.xsd + xmllint --schema test/JATS-journalpublishing1.xsd $< --noout