Validate Nextcloud’s info.xml on CI
The Nextcloud app metadata
is declared in an XML document, located at appinfo/info.xml
. The structure of
this document is defined by a XML schema that can be downloaded
here.
Most code editors are capable of validating the info.xml
while you’re editing
it. To ensure that the document remains valid, it’s possible to add a check
on your continuous integration service.
xmllint
xmllint
is a small CLI tool that can be used to validate info.xml
. To do
that you first have to download the schema, e.g. with wget
or curl
.
Download, validation and cleanup are three simple steps:
wget https://apps.nextcloud.com/schema/apps/info.xsd
xmllint appinfo/info.xml --schema info.xsd --noout
rm info.xsd
Travis CI
To run this check on Travis CI, you have to make sure xmllint
is available.
It can be installed by adding the libxml2-utils
apt package.
A complete and working configuration can be found in the Mail app.
Note that the currently distributed schema on apps.nextcloud.com is slightly outdated and thus elements of Nextcloud’s current info.xml are wrongly reported as invalid. This was fixed recently and the next appstore deployment will update the schema as well.
Final Words
If you’d like to learn more about the info.xml
file, I recommend to take a
look at the Nextcloud Developer Manual
that explains this file in more detail.
As Joas pointed out, Nextcloud 14 will automatically validate the schema. See his pull request for more info. This approach here is still useful if you’re developing your app for Nextcloud 12 and 13.
Update 2018-03-06: Added info about Nextcloud 14’s XML validation.