aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/format-validation.yml
blob: 1c0060cf8a720b8509d588b8bbeaf382b8209f25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: Format validation

on:
  push:
    branches:
      - '*'
      - '!rc/*'
    paths:
      - 'test/writer.jats_articleauthoring'
      - 'test/writer.jats_publishing'
      - 'test/writer.jats_archiving'
  pull_request:
    branches:
      - '*'
      - '!rc/*'
    paths:
      - 'test/writer.jats_articleauthoring'
      - 'test/writer.jats_publishing'
      - 'test/writer.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
        file:
          - writer
          # tables are not supported yet, the files contain only snippets.
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Validate
        run: |
          filename=test/${{ matrix.file }}.jats_${{ matrix.tagset }}
          printf "Validating file %s\n" "$filename"
          json="$(curl --form "xml=@${filename}" --silent "$VALIDATOR_URL")"
          err_count="$(echo "$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