Skip to content

Commit c3ec952

Browse files
authored
Refactor ontology build workflow in qc.yml
Updated the GitHub Actions workflow for ontology build and quality control, including changes to triggers, job steps, and environment variables.
1 parent ad5fd15 commit c3ec952

1 file changed

Lines changed: 25 additions & 284 deletions

File tree

.github/workflows/qc.yml

Lines changed: 25 additions & 284 deletions
Original file line numberDiff line numberDiff line change
@@ -1,302 +1,43 @@
1-
# ==============================================================================
2-
# WORKFLOW: Build Ontology (Quality Control)
3-
# ==============================================================================
4-
# Purpose: Builds ontology release assets and performs quality control checks
5-
#
6-
# This workflow:
7-
# 1. Refreshes imports to ensure consistency with upstream ontologies
8-
# 2. Generates release artifacts (OWL, JSON-LD, Turtle, etc.)
9-
# 3. Runs quality control checks (syntax, consistency, reasoning)
10-
# 4. Commits generated assets back to the repository
11-
# 5. Triggers the documentation workflow to continue the chain
12-
#
13-
# This is the core build workflow that transforms the edit file
14-
# (*-edit.owl) into production-ready ontology releases in multiple formats.
15-
#
16-
# Execution Chain Position:
17-
# setup-repo → [BUILD/QC] → docs
18-
# update-repo → [BUILD/QC] → docs
19-
# [BUILD/QC] → docs (on direct push to main)
20-
#
21-
# Read more about ODK builds:
22-
# https://github.com/INCATools/ontology-development-kit#building-the-ontology
23-
# ==============================================================================
1+
# Basic ODK workflow
242

25-
name: Build Ontology
3+
name: build
264

27-
# ==============================================================================
28-
# WORKFLOW TRIGGERS
29-
# ==============================================================================
30-
# This workflow can be triggered in four ways:
31-
# 1. Via repository_dispatch from setup-repo or update-repo workflow
32-
# 2. Automatically on pushes to main that modify ontology source files
33-
# 3. Automatically on pull requests that modify ontology source files
34-
# 4. Manually via workflow_dispatch for forced builds
35-
#
36-
# Path filters ensure the workflow only runs when ontology files change,
37-
# preventing unnecessary builds on unrelated commits (README, docs, etc.).
38-
#
39-
# IMPORTANT: The push trigger here only monitors ontology source/edit files.
40-
# The refresh-imports workflow independently monitors import-related files
41-
# and is used only for standalone import refreshes (workflow_dispatch /
42-
# repository_dispatch). This prevents double-triggering on import changes.
43-
#
44-
# IMPORTANT: Push triggers skip commits made by github-actions[bot] to prevent
45-
# duplicate runs when the workflow chain is triggered via repository_dispatch.
46-
# ==============================================================================
5+
# Controls when the action will run.
476
on:
48-
# ============================================================================
49-
# TRIGGER 1: Repository Dispatch (from setup-repo or update-repo workflow)
50-
# ============================================================================
51-
# Listens for 'trigger-qc' event dispatched by:
52-
# - setup-repo.yml (after full ontology scaffolding)
53-
# - update-repo.yml (after ODK config regeneration)
54-
# This ensures build runs immediately after those workflows complete.
55-
# ============================================================================
56-
repository_dispatch:
57-
types: [trigger-qc]
58-
59-
# ============================================================================
60-
# TRIGGER 2: Push Events (for regular development on main)
61-
# ============================================================================
62-
# Triggers when core ontology files are pushed to main branch.
63-
#
64-
# Why main branch only?
65-
# - Prevents unnecessary builds on feature/dev branches
66-
# - Production artifacts are built from main
67-
#
68-
# Path filter rationale:
69-
# - *-edit.owl : The primary ontology edit file being developed
70-
# - components/**: Component OWL modules (classes, properties, axioms)
71-
# - imports/** : Import module definitions and extracted term files
72-
# - Makefile : Core ODK build configuration
73-
# - *-Makefile : User-extended Makefile overrides
74-
#
75-
# NOTE: Bot commits from this workflow are NOT skipped here via 'if'
76-
# conditions on the job. Instead, we avoid the infinite loop by design:
77-
# the workflow commits to main, but that commit only touches release
78-
# artifacts (*.owl, *.json, *.ttl) — NOT the paths monitored below.
79-
# So there is no re-trigger from bot commits.
80-
# ============================================================================
7+
# Triggers the workflow on push or pull request events but only for the main branch
818
push:
82-
branches: ["main"]
83-
paths:
84-
- 'src/ontology/*-edit.owl' # Main edit file changes
85-
- 'src/ontology/components/**' # Component module changes
86-
- 'src/ontology/imports/**' # Import-related file changes
87-
- 'src/ontology/Makefile' # Core Makefile changes
88-
- 'src/ontology/*-Makefile' # User-generated Makefile changes
89-
90-
# ============================================================================
91-
# TRIGGER 3: Pull Request Events (for PR validation before merge)
92-
# ============================================================================
93-
# Triggers a dry-run build on pull requests targeting main.
94-
# Commits are skipped for PRs (see commit step condition below).
95-
# This catches build errors and QC failures before code lands on main.
96-
# ============================================================================
97-
pull_request:
98-
branches: ["main"]
99-
paths:
100-
- 'src/ontology/*-edit.owl'
101-
- 'src/ontology/components/**'
102-
- 'src/ontology/imports/**'
103-
- 'src/ontology/Makefile'
104-
- 'src/ontology/*-Makefile'
9+
branches: [main]
10+
# pull_request:
11+
# types: [closed]
10512

106-
# ============================================================================
107-
# TRIGGER 4: Manual Trigger (for forced builds or debugging)
108-
# ============================================================================
109-
# Allows manual execution via GitHub UI or API.
110-
# Useful for:
111-
# - Forcing rebuild after external changes (e.g. upstream ontology update)
112-
# - Troubleshooting build issues without touching source files
113-
# - Testing the complete pipeline end-to-end
114-
# ============================================================================
13+
# Allows you to run this workflow manually from the Actions tab
11514
workflow_dispatch:
11615

117-
# ==============================================================================
118-
# ENVIRONMENT VARIABLES
119-
# ==============================================================================
120-
# Global variables available to all jobs in this workflow
121-
# ==============================================================================
122-
env:
123-
# Default branch for git operations (used in some ODK make targets)
124-
DEFAULT_BRANCH: main
125-
126-
# ==============================================================================
127-
# JOBS
128-
# ==============================================================================
16+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
12917
jobs:
130-
# ============================================================================
131-
# JOB: ontology_qc
132-
# ============================================================================
133-
# Main job that performs the complete build and QC process.
134-
#
135-
# Process Flow:
136-
# 1. Checkout repository with full history
137-
# 2. Build ontology (runs make refresh-imports + all_assets inside ODK container)
138-
# 3. Commit generated release files back to the repository
139-
# 4. Trigger documentation generation workflow (docs.yml)
140-
#
141-
# Container: obolibrary/odkfull:v1.6
142-
# - Includes ROBOT, OWLTools, make, Java, Python, reasoning tools
143-
# - Version pinned for reproducibility
144-
#
145-
# Permissions: contents: write (required for committing release artifacts)
146-
# ============================================================================
18+
# This workflow contains a single job called "ontology_qc"
14719
ontology_qc:
20+
# The type of runner that the job will run on
14821
runs-on: ubuntu-latest
149-
150-
# Grant write permissions for committing generated release assets back to repo
151-
permissions:
152-
contents: write
153-
154-
# Use ODK container for a consistent, reproducible build environment.
155-
# odkfull includes: ROBOT (OWL reasoner + transformer), make, Java, Python,
156-
# yq (YAML processor), and all ODK tooling required for ontology builds.
15722
container: obolibrary/odkfull:v1.6
15823

24+
# Steps represent a sequence of tasks that will be executed as part of the job
15925
steps:
160-
# ========================================================================
161-
# STEP 1: Checkout Repository
162-
# ========================================================================
163-
# Fetch complete repository with full git history.
164-
#
165-
# Why fetch-depth: 0 (full history)?
166-
# - ODK make targets may inspect git history for versioning
167-
# - Ensures accurate version numbers in release artifacts
168-
# - Allows git operations (log, describe) within build scripts
169-
# ========================================================================
170-
- name: Checkout repository
171-
uses: actions/checkout@v4
172-
with:
173-
fetch-depth: 0 # Full git history required for ODK builds
26+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
27+
- uses: actions/checkout@v4
28+
29+
- name: ODK update
30+
run: cd src/ontology && odk.py update
17431

175-
# ========================================================================
176-
# STEP 2: Build Ontology (Refresh Imports + Generate All Artifacts)
177-
# ========================================================================
178-
# Runs two ODK make targets inside the odkfull container:
179-
#
180-
# Target 1: refresh-imports
181-
# - Downloads and extracts terms from upstream ontologies
182-
# - Updates all import module OWL files (imports/*_import.owl)
183-
# - Uses SLME (Syntactic Locality Module Extraction) for minimal imports
184-
# - Reads term lists from imports/*_terms.txt
185-
#
186-
# Target 2: all_assets
187-
# Generates all release artifacts:
188-
# - {id}-full.owl : Complete ontology (all imports merged)
189-
# - {id}-base.owl : Core ontology without transitive imports
190-
# - {id}.owl : Main release file
191-
# - {id}.json : JSON-LD serialization
192-
# - {id}.ttl : Turtle serialization
193-
# - {id}-simple.owl : Simplified version (if configured)
194-
# - {id}-non-classified.owl : Pre-reasoning version (if configured)
195-
# - Component OWL files, QC reports, statistics
196-
#
197-
# Memory configuration (ROBOT_ENV):
198-
# ROBOT_ENV is consumed by the ODK Makefile as a prefix to the ROBOT
199-
# command: `$(ROBOT_ENV) robot ...`. Setting ROBOT_JAVA_ARGS=-Xmx6G
200-
# allocates 6GB Java heap to ROBOT, which is required for reasoning
201-
# over large ontologies. Increase to -Xmx8G if you see OutOfMemory errors.
202-
# ========================================================================
203-
- name: Build ontology (refresh imports + generate all release assets)
32+
- name: Build ontology
20433
env:
205-
# Configure ROBOT Java heap: 6GB is sufficient for most ontologies.
206-
# Increase to -Xmx8G or -Xmx12G if OOM errors occur during reasoning.
207-
ROBOT_ENV: 'ROBOT_JAVA_ARGS=-Xmx6G'
208-
run: |
209-
# Navigate to the ODK ontology source directory
210-
cd src/ontology
211-
212-
echo "=== Starting ODK build ==="
213-
echo "Step 2a: Refreshing ontology imports..."
214-
echo "Step 2b: Generating all release assets..."
215-
216-
# Run both ODK targets:
217-
# - refresh-imports : Mirrors external ontologies and extracts SLME modules
218-
# - all_assets : Generates all release serializations and runs QC
219-
make refresh-imports all_assets
220-
221-
echo "=== Build complete ==="
222-
223-
# ========================================================================
224-
# STEP 3: Commit Ontology Release Assets
225-
# ========================================================================
226-
# Commits the generated release files back to the repository so they are
227-
# versioned alongside the source and available for the docs workflow.
228-
#
229-
# Conditions:
230-
# - SKIPPED for pull requests: PR contributors should review changes manually
231-
# before merge; artifacts are not committed on PR runs.
232-
# - Only commits if there are actual changes (EndBug/add-and-commit@v9
233-
# automatically skips empty commits).
234-
#
235-
# Files committed:
236-
# - src/ontology/*.owl : All OWL serializations (full, base, simple, etc.)
237-
# - src/ontology/*.json : JSON-LD serializations
238-
# - src/ontology/*.ttl : Turtle serializations
239-
# - src/ontology/imports/*.owl : Updated import modules
240-
#
241-
# Why --force?
242-
# - ODK generates these files but they may be listed in .gitignore
243-
# - --force overrides .gitignore so release artifacts are versioned
244-
# - This is intentional: release assets should be tracked for distribution
245-
#
246-
# Commit identity:
247-
# - Author set to github-actions[bot] to distinguish automated commits
248-
# from human developer commits in git log
249-
# ========================================================================
250-
- name: Commit ontology release assets
251-
# Only commit for push and dispatch events — skip for pull requests
252-
if: github.event_name != 'pull_request'
34+
CRYO_TOKEN: ${{ secrets.CRYO_TOKEN }}
35+
DEFAULT_BRANCH: main
36+
run: cd src/ontology && make refresh-imports all_assets ROBOT_ENV='ROBOT_JAVA_ARGS=-Xmx6G' -vvv
37+
- name: Commit files # commit the src folder
25338
uses: EndBug/add-and-commit@v9
25439
with:
255-
# Descriptive message — visible in git log, easy to filter
256-
message: "Building the ontology from the edits"
257-
258-
# Repository root as working directory
259-
cwd: "."
260-
261-
# Add all generated files; --force bypasses .gitignore for artifacts
262-
add: "src/ontology/*.owl src/ontology/*.json src/ontology/*.ttl src/ontology/imports/*.owl --force"
263-
264-
# Commit as the GitHub Actions bot (standard identity for CI commits)
40+
message: "updated ontology"
41+
cwd: "." # Crucial: Look at the whole repo
42+
add: "*.owl src/**/* --force" # Capture root owls and src folder
26543
default_author: github_actions
266-
267-
# Push directly to the current branch
268-
push: true
269-
270-
# ========================================================================
271-
# STEP 4: Trigger Documentation Workflow
272-
# ========================================================================
273-
# After the ontology is successfully built and committed, dispatch a
274-
# repository event to start the Widoco documentation generation workflow.
275-
#
276-
# Workflow chain:
277-
# setup-repo ─→ [this: BUILD/QC] ─→ docs
278-
# update-repo ─→ [this: BUILD/QC] ─→ docs
279-
# push to main ─→ [this: BUILD/QC] ─→ docs
280-
#
281-
# Why repository_dispatch and not a direct workflow call?
282-
# - Maintains clean separation between workflow stages
283-
# - Avoids nested workflow complexity (GitHub has limits on chained calls)
284-
# - Ensures docs always build from the committed artifact, not mid-run state
285-
# - Prevents race conditions between build commit and docs generation
286-
#
287-
# The 'trigger-docs' event is listened for by docs.yml.
288-
#
289-
# Condition: Only dispatch for non-PR events.
290-
# - PRs do not deploy to Pages; docs are rebuilt after PR merge to main.
291-
# ========================================================================
292-
- name: Trigger Documentation Workflow
293-
# Skip for pull requests — docs will be regenerated after PR merge
294-
if: github.event_name != 'pull_request'
295-
uses: peter-evans/repository-dispatch@v3
296-
with:
297-
# GITHUB_TOKEN is automatically available with the 'contents: write'
298-
# permission set on this job. No PAT required.
299-
token: ${{ secrets.GITHUB_TOKEN }}
300-
301-
# Event type that docs.yml listens for via repository_dispatch trigger
302-
event-type: trigger-docs

0 commit comments

Comments
 (0)