name: Format validation on: push: branches: - '*' - '!rc/*' paths: - 'test/writer.jats_articleauthoring' - 'test/writer.jats_publishing' - 'test/writer.jats_archiving' - 'test/tables.jats_archiving' pull_request: branches: - '*' - '!rc/*' paths: - 'test/writer.jats_articleauthoring' - 'test/writer.jats_publishing' - 'test/writer.jats_archiving' - 'test/tables.jats_archiving' jobs: jats: name: JATS runs-on: ubuntu-latest env: VALIDATOR_URL: "https://jats-validator.hubmed.org/dtd/" strategy: fail-fast: false matrix: tagset: - articleauthoring - publishing - archiving steps: - name: Checkout uses: actions/checkout@v2 - name: Validate writer output run: | filename=test/writer.jats_${{ matrix.tagset }} printf "Validating file %s\n" "$filename" json="$(curl --form "xml=@${filename}" --silent "$VALIDATOR_URL")" err_count="$(printf '%s' "$json" | jq '.errors | length')" if [ "$err_count" -eq 0 ]; then printf "File was validated successfully.\n" exit 0 else 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