English
Checking and building
bash
npx @geolonia/datamodels@0.4.3 check
npx @geolonia/datamodels@0.4.3 buildcheck validates every schema and example. On GitHub, the workflow runs the same check on every pull request.
For a node that is not online yet, check cannot compare the published files, so it notes that. This is not a problem, and the exit code is 0:
text
note: https://models.example.org/context/road/v0.1.0.jsonld: not reachable (ENOTFOUND), not compared
…
.: okbuild writes the site into _site/. Open _site/index.html in a browser to look at the front page. The links between the pages start with the base URL, though, so only the front page opens from your computer.
What check checks
- Every schema compiles, and every
examples/example.jsonis valid against its schema. A model has one example:example.json, andexample-normalized.jsonldin the normalized form. Any other file inexamples/is not read, published or checked;checknotes it. - In
schema.json, theconstoftypeis the model's folder name,$idis where the build publishes the schema,x-version(when there is one) is the subject's version, and eachx-ngsi.typeisProperty,Relationship,GeoProperty,JsonPropertyorVocabProperty. example.jsonis checked without the{"json": …}and{"vocab": …}wrappers that aJsonPropertyand aVocabPropertykeep in the key-values form: the schema describes the value inside. The example of an entity type is also checked with an@context(the alias URL, and the exact URL with the NGSI-LD core context): data may carry one, so the schema must accept it. In both examples, Polygon rings close (RFC 7946).example-normalized.jsonld, when there is one, follows the schema. Each attribute has the schema'sx-ngsi.type(Propertywithout one), and several instances only withx-ngsi.multi. A date or date-time value carries"@type": "Date"or"DateTime". Itsidandvocabvalues are those ofexample.json, and its key-values form is valid. Its@contextis a list with the alias URL of the subject's major version (for examplev1.jsonld).- A JSON-LD processor expands
example-normalized.jsonld: each attribute to its IRI, the type to the model's type IRI, and avocabvalue to a defined IRI. Nothing is lost when it is compacted again. The example of a value type is tried as the value of an attribute, and the vocabulary must expand too. The node's own @contexts come from the build, also offline, and the NGSI-LD core context v1.8 comes with the toolkit. Any other context is read online, and only noted when it cannot be read. - Every entity type and attribute is a term of the subject's
@context(or an NGSI-LD core term such aslocation), and expands to the IRI in the schema (x-iri). Otherwise JSON-LD drops the attribute, or gives it another meaning. A term from a context imported by URL is checked online; offline it is only noted. - Each mapping file (
mapping/*.yaml) has the form of a mapping file: astandardwith aname(and optionallyurl,license,note), and for each field a row withto(nullwhen the standard has no such item) and an optionalnote. Its texts are in the node's languages. A key that is not a language tag is a text that YAML cut at a comma: quote it. - The conversion rules of a mapping file are checked as
convertapplies them.vianames another mapping file of the node (<subject>/<Type>/<name>), and the files thatviaconnects do not form a circle. A row for a position in an array (coordinates[2]) only documents it. Unknown keys are reported, so a typo does not go unseen. - The release snapshot of the current version holds exactly what the sources produce. Every snapshot, the current version's included, is compared with the files online, and with a git ref by
--base: a version that is already online is served unchanged (How a published version is kept). - A model does not redefine a term of a model it
extends: the same name keeps the same IRI.
The exit code is 1 on a problem. Another node that cannot be reached, or does not answer within 20 seconds, is only noted: a node that is down never fails someone else's check. --offline skips the published files, the extended models and the schemas on other sites.
check reads other nodes' files only over https from public hosts. An address in your node's own files that cannot be read this way is a problem (exit code 1). When a redirect leads to such an address, or the host name points to a private address, it is only noted. So is an address that comes from another node's files.
GitHub Action
The workflow that init writes (.github/workflows/publish.yml) uses the toolkit's GitHub Action. The Action runs check and build and publishes the node on GitHub Pages. On a pull request it only checks and builds; every push to main publishes (Publish on GitHub Pages).
yaml
# .github/workflows/publish.yml
name: Publish
on:
pull_request:
push:
branches: [main]
workflow_dispatch:
permissions: {}
jobs:
check:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
steps:
- uses: actions/checkout@<SHA> # vX.Y.Z
with:
persist-credentials: false
- uses: geolonia/datamodels-toolkit@<SHA> # vX.Y.Z
with:
deploy: 'false'
publish:
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.node.outputs.page_url }}
concurrency:
group: pages
cancel-in-progress: false
steps:
- uses: actions/checkout@<SHA> # vX.Y.Z
with:
persist-credentials: false
- id: node
uses: geolonia/datamodels-toolkit@<SHA> # vX.Y.ZThe workflow pins each Action to the commit SHA of a release, with the tag as a comment (<SHA> # vX.Y.Z above). Move to a newer toolkit with upgrade; Dependabot also proposes new releases.
The Action has three inputs:
directory: the folder withnode.yamlandmodels/(default.).deploy:'false'to only check and build (default'true').offline:'true'to check without the network (default'false').
The Action's outputs are page_url, the address of the published site, and site, the folder with the built files, for a step that publishes them on another host (since v0.3.7).