1- # Basic ODK workflow
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
8+ # 2. Generates release artifacts (OWL, JSON-LD, Turtle, etc.)
9+ # 3. Runs quality control checks (syntax, consistency, etc.)
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 → refresh-imports → [BUILD/QC] → docs
18+ #
19+ # Read more about ODK builds:
20+ # https://github.com/INCATools/ontology-development-kit#building-the-ontology
21+ # ==============================================================================
222
3- name : build
23+ name : Build Ontology
424
5- # Controls when the action will run.
25+ # ==============================================================================
26+ # WORKFLOW TRIGGERS
27+ # ==============================================================================
28+ # This workflow can be triggered in three ways:
29+ # 1. Via repository_dispatch from refresh-imports workflow (after imports refresh)
30+ # 2. Automatically on pushes that modify ontology source files
31+ # 3. Manually via workflow_dispatch for forced builds
32+ #
33+ # Path filters ensure the workflow only runs when ontology files change,
34+ # preventing unnecessary builds on unrelated commits (README, docs, etc.).
35+ #
36+ # IMPORTANT: Push triggers skip commits made by github-actions[bot] to prevent
37+ # duplicate runs when the workflow chain is triggered via repository_dispatch.
38+ # ==============================================================================
639on :
7- # Triggers the workflow on push or pull request events but only for the main branch
8- push :
9- branches : ["*"]
10- pull_request :
11- branches : ["*"]
40+ # ============================================================================
41+ # TRIGGER 1: Repository Dispatch (from refresh-imports workflow)
42+ # ============================================================================
43+ # Listens for 'trigger-qc' event dispatched by refresh-imports.yml
44+ # This ensures build runs immediately after imports are refreshed
45+ # ============================================================================
46+ repository_dispatch :
47+ types : [trigger-qc]
1248
13- # Allows you to run this workflow manually from the Actions tab
49+ # ============================================================================
50+ # TRIGGER 2: Push Events (for regular development)
51+ # ============================================================================
52+ # Triggers when any file in src/ontology/ is modified and pushed
53+ #
54+ # Why src/ontology/**?
55+ # - Catches changes to edit files, components, imports, metadata
56+ # - Ensures builds run after ontology content updates
57+ # - Excludes unrelated changes (documentation, root README, etc.)
58+ #
59+ # Examples of files that trigger:
60+ # - src/ontology/myonto-edit.owl (main edit file)
61+ # - src/ontology/components/*.owl (component modules)
62+ # - src/ontology/imports/*.owl (import modules)
63+ # - src/ontology/Makefile (build configuration)
64+ #
65+ # Note: This trigger is skipped for commits made by github-actions[bot]
66+ # to prevent duplicate runs when triggered via repository_dispatch
67+ # ============================================================================
68+ # push:
69+ # branches: ["*"] # Triggers on any branch
70+ # paths:
71+ # - 'src/ontology/**'
72+
73+ # ============================================================================
74+ # TRIGGER 3: Pull Request Events (for PR validation)
75+ # ============================================================================
76+ # Same as push trigger, but for pull requests
77+ # Runs QC checks on PR branches to validate changes before merge
78+ # Note: Commits are skipped for PRs (see commit step conditions)
79+ # ============================================================================
80+ # pull_request:
81+ # branches: ["*"]
82+ # paths:
83+ # - 'src/ontology/**'
84+
85+ # ============================================================================
86+ # TRIGGER 4: Manual Trigger (for forced builds)
87+ # ============================================================================
88+ # Allows manual execution via GitHub UI
89+ # Useful for:
90+ # - Testing build process without code changes
91+ # - Forcing rebuild after external changes
92+ # - Troubleshooting build issues
93+ # ============================================================================
1494 workflow_dispatch :
1595
16- # A workflow run is made up of one or more jobs that can run sequentially or in parallel
96+ # ==============================================================================
97+ # ENVIRONMENT VARIABLES
98+ # ==============================================================================
99+ # Global variables available to all jobs in this workflow
100+ # ==============================================================================
101+ env :
102+ # Default branch for git operations (used in some ODK make targets)
103+ DEFAULT_BRANCH : main
104+
105+ # ==============================================================================
106+ # JOBS
107+ # ==============================================================================
17108jobs :
18- # This workflow contains a single job called "ontology_qc"
109+ # ============================================================================
110+ # JOB: ontology_qc
111+ # ============================================================================
112+ # Main job that performs the complete build and QC process
113+ #
114+ # Process Flow:
115+ # 1. Checkout repository with full history
116+ # 2. Refresh imports (ensures consistency)
117+ # 3. Build all release assets (OWL, JSON-LD, Turtle, etc.)
118+ # 4. Commit generated files back to repository
119+ # 5. Trigger documentation workflow
120+ #
121+ # Container: ODK full image with all build tools
122+ #
123+ # CRITICAL: Skips workflow for commits made by github-actions[bot] on push
124+ # to prevent duplicate runs when triggered via repository_dispatch
125+ # ============================================================================
19126 ontology_qc :
20- # The type of runner that the job will run on
127+ # Use latest Ubuntu runner for stability
21128 runs-on : ubuntu-latest
129+
130+ # CRITICAL: Skip this workflow if triggered by push from github-actions[bot]
131+ # This prevents duplicate runs in the workflow chain
132+ # The chain uses repository_dispatch, so push triggers from bot commits are redundant
133+ # if: |
134+ # github.event_name != 'push' ||
135+ # github.event.head_commit.author.name != 'github-actions[bot]'
136+
137+ # Grant write permissions for committing generated assets
138+ permissions :
139+ contents : write
140+
141+ # Use ODK container for consistent build environment
142+ # Version v1.6 pinned for reproducibility
143+ # Includes: ROBOT, OWLTools, make, Java, Python, reasoning tools
22144 container : obolibrary/odkfull:v1.6
23145
24- # Steps represent a sequence of tasks that will be executed as part of the job
25146 steps :
26- # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
27- - uses : actions/checkout@v4
147+ # ========================================================================
148+ # STEP 1: Checkout Repository
149+ # ========================================================================
150+ # Fetch complete repository with full git history
151+ #
152+ # Why fetch-depth: 0?
153+ # - Full history may be needed for ODK make targets
154+ # - Allows git operations that reference commits/branches
155+ # - Required for accurate versioning in releases
156+ # ========================================================================
157+ - name : Checkout repository
158+ uses : actions/checkout@v4
159+ with :
160+ fetch-depth : 0 # Full history
28161
162+ # ========================================================================
163+ # STEP 2: Build Ontology
164+ # ========================================================================
165+ # Runs ODK make targets to build complete ontology release
166+ #
167+ # Make Targets:
168+ # 1. refresh-imports: Updates external ontology modules (ensures consistency)
169+ # 2. all_assets: Generates all release artifacts
170+ #
171+ # What all_assets generates:
172+ # - {id}-full.owl : Complete ontology with all imports merged
173+ # - {id}-base.owl : Core ontology without imports
174+ # - {id}.owl : Main release file (typically same as -full)
175+ # - {id}.json : JSON-LD serialization
176+ # - {id}.ttl : Turtle serialization
177+ # - {id}-simple.owl : Simplified version (if configured)
178+ # - {id}-non-classified.owl : Pre-reasoning version (if configured)
179+ # - Component files : Individual module builds
180+ # - Report files : QC reports and statistics
181+ #
182+ # Environment Variables:
183+ # - ROBOT_ENV: Sets Java heap size for ROBOT tool
184+ # - ROBOT_JAVA_ARGS=-Xmx6G: Allocates 6GB RAM for reasoning/validation
185+ #
186+ # Why 6GB?
187+ # - Large ontologies require significant memory for reasoning
188+ # - Prevents OutOfMemory errors during classification
189+ # - Adjust if builds fail with OOM errors (increase) or if builds
190+ # are fast and memory-constrained (decrease)
191+ # ========================================================================
29192 - name : Build ontology
30193 env :
31- DEFAULT_BRANCH : main
32- run : cd src/ontology && make refresh-imports all_assets ROBOT_ENV='ROBOT_JAVA_ARGS=-Xmx6G'
33- - name : Commit files # commit the src folder
194+ # Configure ROBOT tool memory allocation
195+ # Increase if builds fail with OutOfMemory errors
196+ ROBOT_ENV : ' ROBOT_JAVA_ARGS=-Xmx6G'
197+ run : |
198+ # Navigate to ontology source directory
199+ cd src/ontology
200+
201+ # Run ODK build targets
202+ # - refresh-imports: Update external imports first
203+ # - all_assets: Generate all release files
204+ make refresh-imports all_assets
205+
206+ # ========================================================================
207+ # STEP 3: Commit Ontology Assets
208+ # ========================================================================
209+ # Commits generated release files back to the repository
210+ #
211+ # Conditions:
212+ # - Only runs for push/dispatch events (not pull requests)
213+ # - Only commits if changes detected (action skips empty commits)
214+ #
215+ # What gets committed:
216+ # - src/ontology/*.owl : All OWL release files
217+ # - src/ontology/*.json : JSON-LD serializations
218+ # - src/ontology/*.ttl : Turtle serializations
219+ # - src/ontology/imports/*.owl : Updated import modules
220+ #
221+ # Why --force flag?
222+ # - Generated files are often in .gitignore
223+ # - --force overrides gitignore rules for these specific files
224+ # - Ensures release assets are tracked in version control
225+ #
226+ # Git History Note:
227+ # - Author: github-actions[bot] (distinguishes from human commits)
228+ # - Message: Clearly indicates automated build
229+ # - Allows easy filtering of bot commits in git log
230+ # ========================================================================
231+ - name : Commit ontology assets
232+ # Skip commits for pull requests (review changes manually in PR)
233+ if : github.event_name != 'pull_request'
34234 uses : EndBug/add-and-commit@v9
35235 with :
36- message : " updated ontology"
37- add : " *.* --force"
38- cwd : " ./src/"
236+ # Descriptive commit message for git history
237+ message : " Building the ontology from the edits"
238+
239+ # Working directory (repository root)
240+ cwd : " ."
241+
242+ # Add generated files, forcing inclusion despite .gitignore
243+ # Pattern breakdown:
244+ # - src/ontology/*.owl : All OWL files (base, full, simple, etc.)
245+ # - src/ontology/*.json : JSON-LD serializations
246+ # - src/ontology/*.ttl : Turtle serializations
247+ # - src/ontology/imports/*.owl : Import modules
248+ add : " src/ontology/*.owl src/ontology/*.json src/ontology/*.ttl src/ontology/imports/*.owl --force"
249+
250+ # Use GitHub Actions bot as commit author
39251 default_author : github_actions
252+
253+ # Push to current branch
254+ push : true
255+
256+ # ========================================================================
257+ # STEP 4: Trigger Documentation Workflow
258+ # ========================================================================
259+ # Dispatches repository event to start the documentation generation workflow
260+ #
261+ # Workflow Chain:
262+ # setup-repo → refresh-imports → qc → [DOCS]
263+ #
264+ # Why trigger docs after QC?
265+ # - Documentation is generated from release assets (*-full.owl)
266+ # - Ensures docs reflect the latest built ontology
267+ # - Keeps documentation synchronized with ontology content
268+ #
269+ # Why repository_dispatch?
270+ # - Allows explicit workflow chaining
271+ # - Maintains clear separation between workflow stages
272+ # - Prevents race conditions with concurrent triggers
273+ #
274+ # Condition: Only trigger for non-PR events
275+ # - PRs get preview docs via push trigger after merge
276+ # - Prevents duplicate doc builds during PR review
277+ #
278+ # Event type: trigger-docs
279+ # Listened for by: docs.yml
280+ # ========================================================================
281+ - name : Trigger Documentation Workflow
282+ # Skip for pull requests (docs will build via push trigger after PR merge)
283+ if : github.event_name != 'pull_request'
284+ uses : peter-evans/repository-dispatch@v3
285+ with :
286+ # Use default GitHub token (automatically available)
287+ token : ${{ secrets.GITHUB_TOKEN }}
288+
289+ # Event name that docs.yml listens for
290+ event-type : trigger-docs
0 commit comments