Skip to content

Commit

Permalink
Lint: add basic ontology linting for structure and spelling
Browse files Browse the repository at this point in the history
This commit starts to add additional linting for the OAP, in order to
validate the structure and content of the documents.  There are two
pieces to this commit:

 * Structural linting uses yamale to validate the OAP data against
   yaml schema for equipment, points, and tags files.  The schemas are
   based on the actual data present and so might not be exactly what
   the designers intended; but prevent indentation errors.
 * Spellchecking runs cspell on the text.  Identifiers and other words must be
   added to lint/ids.txt or the build will fail.
 * Two github workflows which run these linters on commit.

In the future, we should add additional check; eg to ensure each point
has a definition (see OntologyAlignmentProject#2); but until that issue is closed the test
would fail anyways.
  • Loading branch information
stevedh committed Apr 12, 2023
1 parent 3fc4c86 commit 308a6f6
Show file tree
Hide file tree
Showing 10 changed files with 1,146 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
on:
push:
branches:
- develop
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- develop
jobs:
lint:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest
name: Run the linter on the dataset
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.x
- name: Install prereqs
working-directory: lint
run: pip install -r requirements.txt
- name: Run linter
working-directory: lint
run: python lint.py

26 changes: 26 additions & 0 deletions .github/workflows/spellcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
on:
push:
branches:
- develop
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- develop
jobs:
lint:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest
name: Run cspell on the dataset using our saved dictionary of ignore words
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install cspell
working-directory: lint
run: npm install -g cspell
- name: Run spellcheck
working-directory: lint
run: cspell ../data/**/*.yaml

6 changes: 6 additions & 0 deletions lint/cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"dictionaries": ["en_us", "ids"],
"dictionaryDefinitions": [
{"name": "ids", "path": "./ids.txt"}
]
}
21 changes: 21 additions & 0 deletions lint/equip.schema.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
map(include("equip"))
---
equip:
name: str()
description: str(required=False)
short_name: str(required=False)
haystack: include("haystack")
extends: str(required=False)
is_base: bool(required=False)
contains: list(str(), required=False)
attributes: list(str(), required=False)
points: list(str(), required=False)
points_base: list(str(), required=False)
ifc_class: str(required=False)
ifc_type: str(required=False)
functions: list(str(), required=False)
functions_base: list(str(), required=False)
brick_ontology: str(required=False)
google_ontology: str(required=False)
deprecated: bool(required=False)
kpi: list(str(), required=False)
Loading

0 comments on commit 308a6f6

Please sign in to comment.