Skip to content

Commit ea80333

Browse files
authored
Lint and check schema for XML files (#2246)
1 parent 32c5f39 commit ea80333

21 files changed

+106
-161
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,44 @@ jobs:
4949

5050
- name: "Run PHPUnit"
5151
run: "bin/phpunit -c tests"
52+
53+
lint-xml-files:
54+
name: Lint XML files
55+
56+
runs-on: ubuntu-latest
57+
58+
steps:
59+
- name: Checkout
60+
uses: actions/checkout@v2
61+
62+
- name: Install required dependencies
63+
run: sudo apt-get update && sudo apt-get install libxml2-utils
64+
65+
- name: Lint xml files
66+
run: make lint-xml
67+
68+
lint-doctrine-xml-schema:
69+
name: Lint Doctrine XML schemas
70+
71+
runs-on: ubuntu-latest
72+
73+
steps:
74+
- name: Checkout
75+
uses: actions/checkout@v2
76+
77+
- name: "Install PHP"
78+
uses: "shivammathur/setup-php@v2"
79+
with:
80+
php-version: "8.0"
81+
extensions: mongodb
82+
83+
- name: "Install dependencies with Composer"
84+
uses: "ramsey/composer-install@v1"
85+
with:
86+
dependency-versions: "highest"
87+
88+
- name: Install required dependencies
89+
run: sudo apt-get update && sudo apt-get install libxml2-utils
90+
91+
- name: Lint xml files
92+
run: make lint-doctrine-xml-schema

Makefile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
lint-xml:
2+
find './tests/.' \( -name '*.xml' \) \
3+
| while read xmlFile; \
4+
do \
5+
XMLLINT_INDENT=' ' xmllint --encode UTF-8 --format "$$xmlFile"|diff - "$$xmlFile"; \
6+
if [ $$? -ne 0 ]; then echo "$$xmlFile" && exit 1; fi; \
7+
done
8+
9+
.PHONY: lint-xml
10+
11+
lint-doctrine-xml-schema:
12+
find './tests/Gedmo/Mapping/Driver/Xml/.' \( -name '*.xml' \) \
13+
| while read xmlFile; \
14+
do \
15+
xmllint --encode UTF-8 --format "$$xmlFile" --schema "./doctrine-mapping.xsd"; \
16+
if [ $$? -ne 0 ]; then echo "$$xmlFile" && exit 1; fi; \
17+
done
18+
19+
.PHONY: lint-doctrine-xml-schema
20+
21+
cs-fix-doctrine-xml:
22+
find './tests/Gedmo/Mapping/Driver/Xml/.' \( -name '*.xml' \) \
23+
| while read xmlFile; \
24+
do \
25+
XMLLINT_INDENT=' ' xmllint --encode UTF-8 --format "$$xmlFile" --output "$$xmlFile"; \
26+
done
27+
.PHONY: cs-fix-doctrine-xml

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"doctrine/dbal": "^2.13",
5151
"doctrine/doctrine-bundle": "^2.3",
5252
"doctrine/mongodb-odm": "^2.0",
53-
"doctrine/orm": "^2.6.3",
53+
"doctrine/orm": "^2.9.6",
5454
"friendsofphp/php-cs-fixer": "^3.0",
5555
"phpunit/phpunit": "^8.5",
5656
"symfony/cache": "^4.4 || ^5.0",

doctrine-mapping.xsd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<schema elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema">
3+
<import namespace="http://doctrine-project.org/schemas/orm/doctrine-mapping" schemaLocation="./vendor/doctrine/orm/doctrine-mapping.xsd"/>
4+
<import namespace="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping" schemaLocation="./schemas/orm/doctrine-extensions-mapping-2-2.xsd"/>
5+
</schema>
Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,18 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
3-
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
4-
xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping">
5-
2+
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping">
63
<entity name="Mapping\Fixture\Xml\ClosureTree" table="closure_trees">
7-
84
<id name="id" type="integer" column="id">
95
<generator strategy="AUTO"/>
106
</id>
11-
127
<field name="name" type="string" length="128"/>
13-
148
<field name="level" type="integer">
15-
<gedmo:tree-level />
9+
<gedmo:tree-level/>
1610
</field>
17-
1811
<many-to-one field="parent" target-entity="ClosureTree">
1912
<join-column name="parent_id" referenced-column-name="id" on-delete="CASCADE"/>
2013
<gedmo:tree-parent/>
2114
</many-to-one>
22-
2315
<gedmo:tree type="closure"/>
2416
<gedmo:tree-closure class="Mapping\Fixture\ClosureTreeClosure"/>
25-
2617
</entity>
27-
2818
</doctrine-mapping>
Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
3-
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
4-
xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping">
5-
2+
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping">
63
<embeddable name="Mapping\Fixture\Xml\Embedded">
7-
8-
<field name="subtitle" type="string" length="191" />
4+
<field name="subtitle" type="string" length="191"/>
95
</embeddable>
10-
116
</doctrine-mapping>
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
3-
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
4-
xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping">
5-
2+
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping">
63
<embeddable name="Mapping\Fixture\Xml\EmbeddedTranslatable">
7-
84
<field name="subtitle" type="string" length="191">
95
<gedmo:translatable/>
106
</field>
117
</embeddable>
12-
138
</doctrine-mapping>
Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,16 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
3-
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
4-
xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping">
5-
2+
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping">
63
<entity name="Mapping\Fixture\Xml\Loggable" table="loggables">
7-
84
<id name="id" type="integer" column="id">
95
<generator strategy="AUTO"/>
106
</id>
11-
127
<field name="title" type="string" length="128">
138
<gedmo:versioned/>
149
</field>
1510
<many-to-one field="status" target-entity="Status">
1611
<join-column name="status_id" referenced-column-name="id"/>
1712
<gedmo:versioned/>
1813
</many-to-one>
19-
2014
<gedmo:loggable log-entry-class="Gedmo\Loggable\Entity\LogEntry"/>
21-
2215
</entity>
23-
2416
</doctrine-mapping>
Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,19 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
3-
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
4-
xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping">
5-
2+
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping">
63
<entity name="Mapping\Fixture\Xml\LoggableWithEmbedded" table="loggables_with_embedded">
7-
84
<id name="id" type="integer" column="id">
95
<generator strategy="AUTO"/>
106
</id>
11-
127
<embedded name="embedded" class="Mapping\Fixture\Xml\Embedded">
13-
<gedmo:versioned />
8+
<gedmo:versioned/>
149
</embedded>
15-
1610
<field name="title" type="string" length="128">
1711
<gedmo:versioned/>
1812
</field>
1913
<many-to-one field="status" target-entity="Status">
2014
<join-column name="status_id" referenced-column-name="id"/>
2115
<gedmo:versioned/>
2216
</many-to-one>
23-
2417
<gedmo:loggable log-entry-class="Gedmo\Loggable\Entity\LogEntry"/>
25-
2618
</entity>
27-
2819
</doctrine-mapping>
Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,28 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
3-
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
4-
xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping">
5-
2+
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping">
63
<entity name="Mapping\Fixture\Xml\MaterializedPathTree" table="materialized_path_trees">
7-
84
<indexes>
95
<index name="title_idx" columns="title"/>
106
</indexes>
11-
127
<id name="id" type="integer" column="id">
138
<generator strategy="AUTO"/>
149
</id>
15-
1610
<field name="level" column="lvl" type="integer">
1711
<gedmo:tree-level/>
1812
</field>
19-
2013
<field name="title" type="string" length="64">
21-
<gedmo:tree-path-source />
14+
<gedmo:tree-path-source/>
2215
</field>
23-
2416
<field name="path" type="string" length="3000">
25-
<gedmo:tree-path separator="," />
17+
<gedmo:tree-path separator=","/>
2618
</field>
27-
2819
<field name="lockTime" type="datetime">
29-
<gedmo:tree-lock-time />
20+
<gedmo:tree-lock-time/>
3021
</field>
31-
3222
<many-to-one field="parent" target-entity="MaterializedPathTree">
3323
<join-column name="parent_id" referenced-column-name="id" on-delete="CASCADE"/>
3424
<gedmo:tree-parent/>
3525
</many-to-one>
36-
37-
<gedmo:tree type="materializedPath" activate-locking="true" locking-timeout="10" />
38-
26+
<gedmo:tree type="materializedPath" activate-locking="true" locking-timeout="10"/>
3927
</entity>
40-
4128
</doctrine-mapping>

0 commit comments

Comments
 (0)