Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
165 changes: 52 additions & 113 deletions .github/workflows/ci-common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,22 @@ name: FUEL_CI_Common

on:
workflow_call:
secrets:
GIST_ID:
required: true
GIST_TOKEN:
required: true
inputs:
RELEASE_VERSION:
required: false
type: string
DEV_DIR:
required: false
type: string
RELEASES_DIR:
required: false
type: string
default: ./public/releases

env:
ONTO_DIR: src
Expand All @@ -21,8 +30,9 @@ jobs:
build:
runs-on: ubuntu-latest
env:
DEV_DIR: ${{ inputs.DEV_DIR }}
RELEASE_VERSION: ${{ inputs.RELEASE_VERSION }}
DEV_DIR: ${{ inputs.DEV_DIR || 'dev' }}
RELEASE_VERSION: ${{ inputs.RELEASE_VERSION || '' }}
GIST_ID: ${{ secrets.GIST_ID || '' }}

steps:
- name: Checkout
Expand All @@ -46,126 +56,55 @@ jobs:
pip install rdflib dotenv pylode

- name: Validate ontology profile
id: profile
run: |
./robot validate-profile --input "${ONTO_DIR}/${ONTO_FILE}" --profile DL || \
./robot validate-profile --input "${ONTO_DIR}/${ONTO_FILE}" --profile DL -vvv || \
(echo "Profile check failed." && exit 1)

- name: Check badge secrets
if: always()
run: |
test -n "${{ secrets.GIST_ID }}" || (echo "Missing GIST_ID secret" && exit 1)
test -n "${{ secrets.GIST_TOKEN }}" || (echo "Missing GIST_TOKEN secret" && exit 1)


- name: Badge — Syntax
if: always()
uses: schneegans/dynamic-badges-action@v1.7.0
with:
forceUpdate: true
auth: ${{ secrets.GIST_TOKEN }}
gistID: ${{ secrets.GIST_ID }}
filename: fuel-ci-profile-${{ github.ref_name }}.json
label: OWL DL Profile (${{ github.ref_name }})
message: ${{ steps.profile.outcome || 'failed' }}
color: ${{ steps.profile.outcome == 'success' && 'brightgreen' || steps.profile.outcome == 'cancelled' && 'yellow' || 'red' }}

- name: Reasoning and consistency check
id: reasoning
run: |
if ./robot reason --reasoner HermiT --input "${ONTO_DIR}/${ONTO_FILE}" --output reasoned.owl; then
echo "REASON_RESULT=consistent" >> $GITHUB_ENV
echo "result=consistent" >> $GITHUB_OUTPUT
else
echo "REASON_RESULT=inconsistent" >> $GITHUB_ENV
echo "result=inconsistent" >> $GITHUB_OUTPUT
exit 1
fi

- name: Generate ontology syntaxes and documentation

- name: Badge — Reasoning
if: always()
uses: schneegans/dynamic-badges-action@v1.7.0
with:
forceUpdate: true
auth: ${{ secrets.GIST_TOKEN }}
gistID: ${{ secrets.GIST_ID }}
filename: fuel-ci-reasoning-${{ github.ref_name }}.json
label: Reasoning (${{ github.ref_name }})
message: ${{ steps.reasoning.outputs.result || 'failed'}}
color: ${{ steps.reasoning.outputs.result == 'consistent' && 'brightgreen' || 'red' }}

- name: Generate ontology syntaxes and documentation
run: |
python3 - << 'PY'
import os
from rdflib import Graph
from shutil import rmtree, copytree
import subprocess

ONTO_DIR = os.environ['ONTO_DIR']
ONTO_FILE = os.environ['ONTO_FILE']
ONTO_ABBREV = os.environ['ONTO_ABBREV']
DOCS_DIR = os.environ['DOCS_DIR']
RELEASES_DIR = os.environ['RELEASES_DIR']

RELEASE_VERSION = os.environ.get('RELEASE_VERSION')
DEV_DIR = os.environ.get('DEV_DIR')

g = Graph()
g.parse(os.path.join(ONTO_DIR, ONTO_FILE))
target_fmts = [("ttl","turtle"),("jsonld","json-ld"),("nt","nt"),("owl","xml")]

if RELEASE_VERSION:
# --- release build ---
release_dir = os.path.join(RELEASES_DIR, RELEASE_VERSION)
os.makedirs(release_dir, exist_ok=True)

# Generate syntaxes
for fmt in target_fmts:
g.serialize(destination=os.path.join(release_dir, f"{ONTO_ABBREV}.{fmt[0]}"), format=fmt[1], encoding="utf-8")

# Versioned docs
release_docs_dir = os.path.join(release_dir, "docs")
os.makedirs(release_docs_dir, exist_ok=True)

# Pylode docs
pylode_outdir = os.path.join(release_docs_dir, "pylode")
os.makedirs(pylode_outdir, exist_ok=True)
subprocess.run([
"pylode",
"-o", os.path.join(pylode_outdir, "index"),
os.path.join(ONTO_DIR, ONTO_FILE)
], check=True)

# Widoco docs
widoco_dir = os.path.join(release_docs_dir, "widoco")
os.makedirs(widoco_dir, exist_ok=True)
subprocess.run([
"wget", "-O", os.path.join(widoco_dir,"widoco.jar"),
"https://github.com/dgarijo/Widoco/releases/download/v1.4.25/widoco-1.4.25-jar-with-dependencies_JDK-17.jar"
], check=True)
subprocess.run([
"java","-jar", os.path.join(widoco_dir,"widoco.jar"),
"-ontFile", os.path.join(ONTO_DIR, ONTO_FILE),
"-oops","-webVowl","-includeAnnotationProperties",
"-outFolder", widoco_dir,
"-rewriteAll","-includeImportedOntologies","-uniteSections","-excludeIntroduction"
], check=True)

# Update latest
latest_dir = os.path.join(RELEASES_DIR, "latest")
if os.path.exists(latest_dir):
rmtree(latest_dir)
copytree(release_dir, latest_dir)

# Generate releases index.html
releases_index = os.path.join(RELEASES_DIR, 'index.html')
release_folders = sorted([d for d in os.listdir(RELEASES_DIR) if os.path.isdir(os.path.join(RELEASES_DIR,d))])
with open(releases_index, 'w') as f:
f.write("<html><head><title>FUEL Releases</title></head><body>\n")
f.write("<h1>FUEL Ontology Releases</h1>\n<ul>\n")
for r in release_folders:
f.write(f'<li><a href="{r}/">{r}</a></li>\n')
f.write("</ul>\n</body></html>\n")

elif DEV_DIR:
# --- development build ---
os.makedirs(DEV_DIR, exist_ok=True)

# Generate syntaxes
for fmt in target_fmts:
g.serialize(destination=os.path.join(DEV_DIR, f"{ONTO_ABBREV}.{fmt[0]}"), format=fmt[1], encoding="utf-8")

# Development docs
dev_docs_dir = os.path.join(DEV_DIR, "docs")
os.makedirs(dev_docs_dir, exist_ok=True)

pylode_outdir = os.path.join(dev_docs_dir, "pylode")
os.makedirs(pylode_outdir, exist_ok=True)
subprocess.run([
"pylode",
"-o", os.path.join(pylode_outdir, "index"),
os.path.join(ONTO_DIR, ONTO_FILE)
], check=True)

widoco_dir = os.path.join(dev_docs_dir,"widoco")
os.makedirs(widoco_dir, exist_ok=True)
subprocess.run([
"wget", "-O", os.path.join(widoco_dir,"widoco.jar"),
"https://github.com/dgarijo/Widoco/releases/download/v1.4.25/widoco-1.4.25-jar-with-dependencies_JDK-17.jar"
], check=True)
subprocess.run([
"java","-jar", os.path.join(widoco_dir,"widoco.jar"),
"-ontFile", os.path.join(ONTO_DIR, ONTO_FILE),
"-oops","-webVowl","-includeAnnotationProperties",
"-outFolder", widoco_dir,
"-rewriteAll","-includeImportedOntologies","-uniteSections","-excludeIntroduction"
], check=True)
PY
python3 src/scripts/onto_syntax_doc.py

- name: Upload dev artifact
if: ${{ inputs.DEV_DIR != '' && inputs.DEV_DIR != null }}
Expand Down
53 changes: 9 additions & 44 deletions .github/workflows/ci-dev.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: FUEL_CI_Dev

concurrency:
group: fuel-gist-badges
cancel-in-progress: true

on:
push:
branches:
Expand All @@ -8,10 +12,11 @@ on:
jobs:
dev:
uses: ./.github/workflows/ci-common.yaml
secrets: inherit
with:
DEV_DIR: dev # build ontologies into "dev" folder
DEV_DIR: ./public/dev # build ontologies into "dev" folder

dev_index_and_deploy:
deploy:
needs: dev
runs-on: ubuntu-latest
permissions:
Expand All @@ -28,55 +33,15 @@ jobs:
uses: actions/download-artifact@v4
with:
name: dev
path: dev

- name: Generate dev index.html
run: |
DEV_DIR=dev
DEV_SITE=dev_site
mkdir -p $DEV_SITE/dev

# Copy all ontology outputs into /dev
cp -r $DEV_DIR/* $DEV_SITE/dev/ || echo "No files to copy yet"

#### Root index.html (at /dev/index.html)
ROOT_INDEX=$DEV_SITE/dev/index.html
echo "<html><head><title>FUEL Dev Build</title></head><body>" > $ROOT_INDEX
echo "<h1>Development Build</h1>" >> $ROOT_INDEX

# List ontology files (inside /dev)
for f in $DEV_SITE/dev/*; do
fname=$(basename $f)
if [ "$fname" != "index.html" ] && [ "$fname" != "docs" ]; then
echo "<a href=\"$fname\">$fname</a><br>" >> $ROOT_INDEX
fi
done

# Add link to docs folder
if [ -d "$DEV_SITE/dev/docs" ]; then
echo "<br><a href=\"docs/\">Documentation</a><br>" >> $ROOT_INDEX
fi
echo "</body></html>" >> $ROOT_INDEX

#### Docs index.html (at /dev/docs/index.html)
if [ -d "$DEV_SITE/dev/docs" ]; then
DOCS_INDEX=$DEV_SITE/dev/docs/index.html
echo "<html><head><title>FUEL Dev Docs</title></head><body>" > $DOCS_INDEX
echo "<h1>Ontology Documentation</h1>" >> $DOCS_INDEX
for d in $DEV_SITE/dev/docs/*/; do
dname=$(basename $d)
echo "<a href=\"$dname/\">$dname</a><br>" >> $DOCS_INDEX
done
echo "</body></html>" >> $DOCS_INDEX
fi
path: ./public/dev

- name: Configure GitHub Pages
uses: actions/configure-pages@v5

- name: Upload dev site artifact
uses: actions/upload-pages-artifact@v4
with:
path: dev_site
path: ./public

- name: Deploy dev site
id: deployment
Expand Down
27 changes: 25 additions & 2 deletions .github/workflows/ci-release.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: FUEL_CI_Release

concurrency:
group: fuel-gist-badges
cancel-in-progress: true

on:
workflow_dispatch:
inputs:
Expand All @@ -14,8 +18,10 @@ on:
jobs:
release:
uses: ./.github/workflows/ci-common.yaml
secrets: inherit
with:
RELEASE_VERSION: ${{ github.event.inputs.release_version }}
RELEASES_DIR: ./public/releases

deploy:
needs: release
Expand All @@ -27,6 +33,23 @@ jobs:
pages: write
id-token: write
steps:
- name: Deploy to GitHub Pages
- name: Checkout
uses: actions/checkout@v4

- name: Download release artifact
uses: actions/download-artifact@v4
with:
name: release
path: ./public/releases # download into ./public/releases

- name: Configure GitHub Pages
uses: actions/configure-pages@v5

- name: Upload site artifact
uses: actions/upload-pages-artifact@v4
with:
path: ./public # publish the full public/ tree

- name: Deploy site
id: deployment
uses: actions/deploy-pages@v4.0.5
uses: actions/deploy-pages@v4
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# VSCode settings
.vscode/

# VSCode extensions
*.code-workspace

# VSCode logs
*.log

# VSCode backup files
*.tmp

# VSCode history
.history/

# VSCode crash reports
crash-reports/

# Mac system files
.DS_Store

# Python cache files
__pycache__/
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
### CI Status

**Dev:**
![OWL DL Profile (dev)](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/agbeltran/21194e497875f56c63a36e638e5e7f6b/raw/fuel-ci-profile-dev.json)
![Reasoning (dev)](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/agbeltran/21194e497875f56c63a36e638e5e7f6b/raw/fuel-ci-reasoning-dev.json)

**Main:**
![OWL DL Profile (main)](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/agbeltran/21194e497875f56c63a36e638e5e7f6b/raw/fuel-ci-profile-main.json)
![Reasoning (main)](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/agbeltran/21194e497875f56c63a36e638e5e7f6b/raw/fuel-ci-reasoning-main.json)


# FUsion Energy Lexicon (FUEL)

FUsion Energy Lexicon (FUEL) is an ontology for fusion energy data and processes.
FUEL is currently under development and will be available in this repository in the near future.

FUEL is currently under development.

### Development version

To check the development version, visit [FUEL Dev](https://ukaea.github.io/fuel/dev/)

Loading