Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 15, 2025

This PR adds a GitHub Actions workflow that automatically generates and commits LinkML artifacts whenever schema files are updated.

What this adds

The new .github/workflows/auto-build-artifacts.yaml workflow:

  • Triggers automatically when files in src/schema/linkml/ are modified via pushes to main/develop or pull requests
  • Generates artifacts by running make gen-artefacts which creates:
    • JSON Schema: src/schema/jsonschema/bertron_schema.json
    • Pydantic model: src/schema/datamodel/bertron_schema_pydantic.py
  • For pushes: Automatically commits generated artifacts back to the repository
  • For PRs: Adds a comment indicating artifacts will be auto-generated when merged

Key features

  • Uses the same uv dependency management as existing workflows for consistency
  • Only commits artifacts when they actually change (avoids unnecessary commits)
  • Includes [skip artifacts] tag in commit messages to prevent infinite loops
  • Provides clear feedback on pull requests about pending artifact generation

Example behavior

When a developer updates src/schema/linkml/bertron_schema.yaml:

  1. On a feature branch PR: The workflow adds a comment like "🤖 Artifacts will be auto-generated when this PR is merged"
  2. After merging to main: The workflow automatically generates fresh artifacts and commits them with message "Auto-generate artifacts from schema update [skip artifacts]"

This ensures the generated artifacts are always kept in sync with the schema definitions without requiring manual intervention.

Fixes #72.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • astral.sh
    • Triggering command: curl -LsSf REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copy link
Contributor Author

Copilot AI commented Sep 15, 2025

@shreddd 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

Co-authored-by: shreddd <143514+shreddd@users.noreply.github.com>
Copilot AI changed the title [WIP] Auto-build artifacts on schema update Add GitHub workflow to auto-build artifacts on schema updates Sep 15, 2025
Copilot AI requested a review from shreddd September 15, 2025 21:43
Comment on lines +52 to +58
- name: Commit and push changes
if: steps.check_changes.outputs.changes == 'true' && github.event_name == 'push'
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git commit -m "Auto-generate artifacts from schema update [skip artifacts]"
git push
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to point out that this will make an additional commit to the repository.

@shreddd shreddd marked this pull request as ready for review September 16, 2025 16:12
jobs:
build-artifacts:
runs-on: ubuntu-latest
if: ${{ !contains(github.event.head_commit.message, '[skip artifacts]') }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comment saying that [skip artifacts] is being included here to avoid infinite loops. That is explained in the PR description, but not here in the file.

push:
branches:
- main
- develop
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know that there are any existing conventions in this repo for a branch named develop. I recommend removing this line.

Comment on lines +26 to +36
- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: 3.12

- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Install dependencies
run: |
uv sync
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. "Set up Python 3.12" is unnecessary. "Install dependencies" (via uv sync) will take care of installing Python.
  2. Regarding astral-sh/setup-uv@v3: v6 is available now

Comment on lines +42 to +53
- name: Check for changes
id: check_changes
run: |
git add src/schema/jsonschema/ src/schema/datamodel/
if git diff --staged --quiet; then
echo "changes=false" >> $GITHUB_OUTPUT
else
echo "changes=true" >> $GITHUB_OUTPUT
fi

- name: Commit and push changes
if: steps.check_changes.outputs.changes == 'true' && github.event_name == 'push'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comment explaining how this "check for changes" + "check the results of that check" works.

Copy link
Contributor

@eecavanna eecavanna Sep 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend ensuring tests pass before regenerating the artifacts. That could be accomplished by invoking a different workflow, as long as that other workflow has:

  # Allow this workflow to be called by other workflows.
  # Reference: https://docs.github.com/en/actions/using-workflows/reusing-workflows
  workflow_call: { }

...or by running the tests directly in this workflow.

@eecavanna
Copy link
Contributor

Hi @shreddd, I finished reviewing this PR and left comments. I think I'll be OOO the rest of the day.

@eecavanna eecavanna requested a review from Copilot September 16, 2025 20:25
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces automated artifact generation for LinkML schema updates by adding a GitHub Actions workflow that monitors schema file changes and regenerates corresponding artifacts.

  • Adds workflow that triggers on schema file changes in src/schema/linkml/ for pushes and pull requests
  • Automatically generates JSON Schema and Pydantic model artifacts using make gen-artefacts
  • Implements different behaviors for pushes (auto-commit) versus pull requests (notification comment)

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +27 to +29
uses: actions/setup-python@v4
with:
python-version: 3.12
Copy link

Copilot AI Sep 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actions/setup-python action version should be updated to v5 for better compatibility and features. Also, the Python version should be quoted to avoid potential YAML parsing issues.

Suggested change
uses: actions/setup-python@v4
with:
python-version: 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As commented here (#73 (comment)), this step as a whole can be removed.


- name: Generate artifacts
run: |
make gen-artefacts
Copy link

Copilot AI Sep 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The target name 'gen-artefacts' uses British spelling. Consider using 'gen-artifacts' for consistency with American English conventions typically used in software development.

Suggested change
make gen-artefacts
make gen-artifacts

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto-build artifacts on schema update

3 participants