Merge branch 'main' of github.com:materialdigital/microstructure-onto… #55
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Basic ODK workflow | |
| name: build | |
| # Controls when the action will run. | |
| on: | |
| # ============================================================================ | |
| # TRIGGER 1: Repository Dispatch (from setup-repo or update-repo workflow) | |
| # ============================================================================ | |
| # Listens for 'trigger-qc' event dispatched by: | |
| # - setup-repo.yml (after full ontology scaffolding) | |
| # - update-repo.yml (after ODK config regeneration) | |
| # This ensures build runs immediately after those workflows complete. | |
| # ============================================================================ | |
| repository_dispatch: | |
| types: [trigger-qc] | |
| # ============================================================================ | |
| # TRIGGER 2: Push Events (for regular development on main) | |
| # ============================================================================ | |
| # Triggers when core ontology files are pushed to main branch. | |
| # | |
| # Why main branch only? | |
| # - Prevents unnecessary builds on feature/dev branches | |
| # - Production artifacts are built from main | |
| # | |
| # Path filter rationale: | |
| # - *-edit.owl : The primary ontology edit file being developed | |
| # - components/**: Component OWL modules (classes, properties, axioms) | |
| # - imports/** : Import module definitions and extracted term files | |
| # - Makefile : Core ODK build configuration | |
| # - *-Makefile : User-extended Makefile overrides | |
| # | |
| # NOTE: Bot commits from this workflow are NOT skipped here via 'if' | |
| # conditions on the job. Instead, we avoid the infinite loop by design: | |
| # the workflow commits to main, but that commit only touches release | |
| # artifacts (*.owl, *.json, *.ttl) — NOT the paths monitored below. | |
| # So there is no re-trigger from bot commits. | |
| # ============================================================================ | |
| push: | |
| branches: ["main"] | |
| paths: | |
| - 'src/ontology/*-edit.owl' # Main edit file changes | |
| - 'src/ontology/components/**' # Component module changes | |
| - 'src/ontology/imports/**' # Import-related file changes | |
| - 'src/ontology/Makefile' # Core Makefile changes | |
| - 'src/ontology/*.Makefile' # User-generated Makefile changes | |
| # ============================================================================ | |
| # TRIGGER 3: Pull Request Events (for PR validation before merge) | |
| # ============================================================================ | |
| # Triggers a dry-run build on pull requests targeting main. | |
| # Commits are skipped for PRs (see commit step condition below). | |
| # This catches build errors and QC failures before code lands on main. | |
| # ============================================================================ | |
| pull_request: | |
| branches: ["main"] | |
| paths: | |
| - 'src/ontology/*-edit.owl' | |
| - 'src/ontology/components/**' | |
| - 'src/ontology/imports/**' | |
| - 'src/ontology/Makefile' | |
| - 'src/ontology/*.Makefile' | |
| # Allows you to run this workflow manually from the Actions tab | |
| workflow_dispatch: | |
| # A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
| jobs: | |
| # This workflow contains a single job called "ontology_qc" | |
| ontology_qc: | |
| # The type of runner that the job will run on | |
| runs-on: ubuntu-latest | |
| container: obolibrary/odkfull:v1.6 | |
| # Steps represent a sequence of tasks that will be executed as part of the job | |
| steps: | |
| # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
| - uses: actions/checkout@v4 | |
| - name: ODK update | |
| run: cd src/ontology && odk.py update | |
| - name: Build ontology | |
| env: | |
| # Configure ROBOT Java heap: 6GB is sufficient for most ontologies. | |
| # Increase to -Xmx8G or -Xmx12G if OOM errors occur during reasoning. | |
| ROBOT_ENV: 'ROBOT_JAVA_ARGS=-Xmx6G' | |
| run: | | |
| # Navigate to the ODK ontology source directory | |
| cd src/ontology | |
| echo "=== Starting ODK build ===" | |
| echo "Step 2: Refreshing ontology imports and generating all release assets..." | |
| # Run both ODK targets: | |
| # - refresh-imports : Mirrors external ontologies and extracts SLME modules | |
| # - all_assets : Generates all release serializations and runs QC | |
| make refresh-imports all_assets | |
| echo "=== Build complete ===" | |
| # ======================================================================== | |
| # STEP 3: Commit Ontology Release Assets | |
| # ======================================================================== | |
| # Commits the generated release files back to the repository so they are | |
| # versioned alongside the source and available for the docs workflow. | |
| # | |
| # Conditions: | |
| # - SKIPPED for pull requests: PR contributors should review changes manually | |
| # before merge; artifacts are not committed on PR runs. | |
| # - Only commits if there are actual changes (EndBug/add-and-commit@v9 | |
| # automatically skips empty commits). | |
| # | |
| # Files committed: | |
| # - src/ontology/*.owl : All OWL serializations (full, base, simple, etc.) | |
| # - src/ontology/*.json : JSON-LD serializations | |
| # - src/ontology/*.ttl : Turtle serializations | |
| # - src/ontology/imports/*.owl : Updated import modules | |
| # | |
| # Why --force? | |
| # - ODK generates these files but they may be listed in .gitignore | |
| # - --force overrides .gitignore so release artifacts are versioned | |
| # - This is intentional: release assets should be tracked for distribution | |
| # | |
| # Commit identity: | |
| # - Author set to github-actions[bot] to distinguish automated commits | |
| # from human developer commits in git log | |
| # ======================================================================== | |
| - name: Commit ontology release assets | |
| # Only commit for push and dispatch events — skip for pull requests | |
| if: github.event_name != 'pull_request' | |
| uses: EndBug/add-and-commit@v9 | |
| with: | |
| message: "updated ontology" | |
| cwd: "." # Crucial: Look at the whole repo | |
| add: "*.owl src/**/* --force" # Capture root owls and src folder | |
| default_author: github_actions |