-
Notifications
You must be signed in to change notification settings - Fork 5
69 lines (67 loc) · 2.2 KB
/
validate_pr.yml
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
name: Validate PR
on: pull_request
defaults:
run:
shell: bash
working-directory: project
jobs:
test:
runs-on: ubuntu-latest
steps:
# checkout code
- name: Checkout
uses: actions/checkout@v4
with:
path: project
fetch-depth: 2
# checkout schema as xmllint can't https
- name: Checkout schema repo
uses: actions/checkout@v4
with:
repository: BetaMasaheft/Schema
path: schema
- name: Install Test Dependencies
run: |
sudo apt-get update
sudo apt-get install -y libxml2-utils
# Compare locally changed files to PR's base
- name: Check for changed source files
id: changed
run: |
{
echo "FILES=$(git diff --name-only --diff-filter=ACMRT \
${{ github.event.pull_request.base.sha }} \
${{ github.sha }} \
-- ':./**/*.xml' ':!*/transkribus*.xml' ':!*/facsimile*.xml' \
':!./**/edition.xml' ':!./**/msDesc.xml' ':!./**/*text.xml' \
':!./**/taxonomy.xml' ':*.xml' ':!build.xml' ':!expath-pkg.xml' ':!repo.xml' | xargs)"
} >> "$GITHUB_OUTPUT"
# If no xml files were modified ...
- name: No source files changed
if: ${{ steps.changed.outputs.FILES == '' }}
run: |
echo "All good"
# ... otherwise
- name: List modified documents
env:
FILES: ${{ steps.changed.outputs.FILES }}
if: ${{ steps.changed.outputs.FILES != '' }}
run: |
echo "modified: $FILES"
# Validate changed files against latest schema
- name: Validate changed source files
env:
FILES: ${{ steps.changed.outputs.FILES }}
if: ${{ steps.changed.outputs.FILES != '' }}
run: |
xmllint \
--noout --xinclude --nowarning \
--relaxng ../schema/tei-betamesaheft.rng \
$FILES \
2>&1 | \
{ grep -vE 'RNG|validates' || :; }
# ensure branch contains only well-formed xml files
- name: Ensure all XML files are well formed
run: |
xmllint --noout \
$(find . -type f -name '*.xml')