Add GitHub workflow to auto-build artifacts on schema updates#73
Add GitHub workflow to auto-build artifacts on schema updates#73
Conversation
|
@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>
| - 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 |
There was a problem hiding this comment.
I want to point out that this will make an additional commit to the repository.
| jobs: | ||
| build-artifacts: | ||
| runs-on: ubuntu-latest | ||
| if: ${{ !contains(github.event.head_commit.message, '[skip artifacts]') }} |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
I don't know that there are any existing conventions in this repo for a branch named develop. I recommend removing this line.
| - 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 |
There was a problem hiding this comment.
- "Set up Python 3.12" is unnecessary. "Install dependencies" (via uv sync) will take care of installing Python.
- Regarding
astral-sh/setup-uv@v3:v6is available now
| - 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' |
There was a problem hiding this comment.
Add comment explaining how this "check for changes" + "check the results of that check" works.
There was a problem hiding this comment.
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.
|
Hi @shreddd, I finished reviewing this PR and left comments. I think I'll be OOO the rest of the day. |
There was a problem hiding this comment.
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.
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: 3.12 |
There was a problem hiding this comment.
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.
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: 3.12 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" |
There was a problem hiding this comment.
As commented here (#73 (comment)), this step as a whole can be removed.
|
|
||
| - name: Generate artifacts | ||
| run: | | ||
| make gen-artefacts |
There was a problem hiding this comment.
[nitpick] The target name 'gen-artefacts' uses British spelling. Consider using 'gen-artifacts' for consistency with American English conventions typically used in software development.
| make gen-artefacts | |
| make gen-artifacts |
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.yamlworkflow:src/schema/linkml/are modified via pushes tomain/developor pull requestsmake gen-artefactswhich creates:src/schema/jsonschema/bertron_schema.jsonsrc/schema/datamodel/bertron_schema_pydantic.pyKey features
uvdependency management as existing workflows for consistency[skip artifacts]tag in commit messages to prevent infinite loopsExample behavior
When a developer updates
src/schema/linkml/bertron_schema.yaml: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.shcurl -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.