From 56f607b50b1bdff6762f46160c99615535f20abd Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Wed, 18 Nov 2020 17:31:41 +0100 Subject: CI: validate JATS table output --- .github/workflows/format-validation.yml | 36 +++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/.github/workflows/format-validation.yml b/.github/workflows/format-validation.yml index 1c0060cf8..2104f9da1 100644 --- a/.github/workflows/format-validation.yml +++ b/.github/workflows/format-validation.yml @@ -9,6 +9,7 @@ on: - 'test/writer.jats_articleauthoring' - 'test/writer.jats_publishing' - 'test/writer.jats_archiving' + - 'test/tables.jats_archiving' pull_request: branches: - '*' @@ -17,6 +18,7 @@ on: - 'test/writer.jats_articleauthoring' - 'test/writer.jats_publishing' - 'test/writer.jats_archiving' + - 'test/tables.jats_archiving' jobs: jats: @@ -31,19 +33,16 @@ jobs: - articleauthoring - publishing - archiving - file: - - writer - # tables are not supported yet, the files contain only snippets. steps: - name: Checkout uses: actions/checkout@v2 - - name: Validate + - name: Validate writer output run: | - filename=test/${{ matrix.file }}.jats_${{ matrix.tagset }} + filename=test/writer.jats_${{ matrix.tagset }} printf "Validating file %s\n" "$filename" json="$(curl --form "xml=@${filename}" --silent "$VALIDATOR_URL")" - err_count="$(echo "$json" | jq '.errors | length')" + err_count="$(printf '%s' "$json" | jq '.errors | length')" if [ "$err_count" -eq 0 ]; then printf "File was validated successfully.\n" exit 0 @@ -51,3 +50,28 @@ jobs: printf "Validator report:\n%s" "$json" exit 1 fi + + - name: Validate tables + # Archiving has the simplest template, so we only check with that. + if: matrix.tagset == 'archiving' + run: | + tmpl="$(cat < + +
+ + %s
+ EOF + )" + jats_file="$(mktemp jats-tables.XXXXX)" + printf "$tmpl" "$(cat test/tables.jats_archiving)" > "$jats_file" + json="$(curl --form "xml=@${jats_file}" --silent "$VALIDATOR_URL")" + err_count="$(printf "%s" "$json" | jq '.errors | length')" + if [ "$err_count" -eq 0 ]; then + printf "Table output is valid when used as body content.\n" + exit 0 + else + printf "Validator report:\n%s" "$json" + exit 1 + fi -- cgit v1.2.3