-
Notifications
You must be signed in to change notification settings - Fork 5
Add automated dependency update workflow with configurable environment variables #201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
83a9ecb
525349a
481ef16
8311821
17eae1b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,123 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name: Update Dependencies | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| schedule: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Run at 9:00 AM UTC every Monday | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - cron: 0 9 * * 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Allow manual runs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| workflow_dispatch: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| inputs: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| package: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: > | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Specific package to update (e.g., numpy, librosa). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Leave empty to check all packages. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| required: false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| version: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: > | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Target version for the package. Leave empty to use latest. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| required: false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PYTHON_VERSION: 3.11 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PIP_VERSION: 24.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| check-and-update: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if: github.repository_owner == 'JaclynCodes' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| contents: write # Needed to push changes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Checkout | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Use default token for now, can be updated to use PAT if needed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| token: ${{ secrets.GITHUB_TOKEN }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Set Git author | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| git config user.name "github-actions[bot]" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Setup Python | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uses: actions/setup-python@v5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| python-version: ${{ env.PYTHON_VERSION }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Upgrade pip | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| python -m pip install --upgrade pip==${{ env.PIP_VERSION }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Install dependencies | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pip install -r requirements.txt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Check for updates | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| id: check_updates | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Install pip-tools for dependency management | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pip install pip-tools | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Check for outdated packages | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Checking for outdated packages..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pip list --outdated > outdated.txt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cat outdated.txt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ -s outdated.txt ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "updates_available=true" >> $GITHUB_OUTPUT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "updates_available=false" >> $GITHUB_OUTPUT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+61
to
+69
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Check for outdated packages | |
| echo "Checking for outdated packages..." | |
| pip list --outdated > outdated.txt | |
| cat outdated.txt | |
| if [ -s outdated.txt ]; then | |
| echo "updates_available=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "updates_available=false" >> $GITHUB_OUTPUT | |
| # Check for outdated packages using machine-readable JSON output | |
| echo "Checking for outdated packages..." | |
| pip list --outdated --format=json > outdated.json | |
| cat outdated.json || true | |
| updates_count=$(python - << 'PY' | |
| import json | |
| import pathlib | |
| path = pathlib.Path("outdated.json") | |
| if not path.exists(): | |
| # Treat missing output as no updates | |
| print(0) | |
| else: | |
| try: | |
| data = json.loads(path.read_text()) | |
| except json.JSONDecodeError: | |
| # Treat malformed JSON as no updates | |
| print(0) | |
| else: | |
| # data should be a list of outdated packages | |
| print(len(data) if isinstance(data, list) else 0) | |
| PY | |
| ) | |
| if [ "$updates_count" -gt 0 ]; then | |
| echo "updates_available=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "updates_available=false" >> "$GITHUB_OUTPUT" |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inputs.package / inputs.version are interpolated directly into shell and sed commands. A crafted input containing quotes/metacharacters can break the command line and execute unintended shell code, especially since this job has contents: write. Validate inputs against an allowlist regex (e.g., [A-Za-z0-9_.-]+), and escape values before using them in sed (or update requirements via a small Python script instead of shell string interpolation).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: This sed replacement drops existing upper-bound constraints (e.g., librosa>=0.11.0,<0.12.0), so a “latest compatible” update can accidentally loosen requirements and allow incompatible versions. Preserve any trailing constraints instead of replacing the whole line.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .github/workflows/update_dependencies.yml, line 100:
<comment>This sed replacement drops existing upper-bound constraints (e.g., `librosa>=0.11.0,<0.12.0`), so a “latest compatible” update can accidentally loosen requirements and allow incompatible versions. Preserve any trailing constraints instead of replacing the whole line.</comment>
<file context>
@@ -0,0 +1,123 @@
+ exit 1
+ fi
+ # Use word boundaries to match exact package name
+ sed -i "s/^${{ inputs.package }}[>=<].*/${{ inputs.package }}>=\
+ $LATEST/" requirements.txt
+ fi
</file context>
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sed replacement overwrites the entire requirement line, which will drop additional constraints (e.g., librosa>=0.11.0,<0.12.0 would lose the <0.12.0 cap). This can unintentionally widen constraints and break compatibility. Consider preserving existing upper bounds/extras, or editing only the specific specifier being updated instead of replacing the whole line.
JaclynCodes marked this conversation as resolved.
Show resolved
Hide resolved
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the provided inputs.package doesn't exist in requirements.txt, sed will succeed but make no changes, and the workflow exits with "No changes to commit". That makes it hard to distinguish "already up to date" from "package not found". Add an explicit check that the package line exists/matched (e.g., grep before/after) and fail with a clear error when it isn't found.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| # GitHub Workflows | ||
|
|
||
| This document describes the GitHub Actions workflows used in the Symphonic-Joules project. | ||
|
|
||
| ## Available Workflows | ||
|
|
||
| ### Update Dependencies | ||
|
|
||
| **File:** `.github/workflows/update_dependencies.yml` | ||
|
|
||
| **Purpose:** Automates checking and updating Python package dependencies. | ||
|
|
||
| **Triggers:** | ||
| - **Schedule:** Runs automatically every Monday at 9:00 AM UTC | ||
| - **Manual:** Can be triggered manually via GitHub Actions UI | ||
|
|
||
| **Environment Variables:** | ||
| - `PYTHON_VERSION`: The Python version used for updates (default: 3.11) | ||
| - `PIP_VERSION`: The pip version used (default: 24.0) | ||
|
|
||
| **Manual Trigger Options:** | ||
| - `package`: Specify a particular package to update (e.g., `numpy`, `librosa`) | ||
| - `version`: Specify the target version for the package (leave empty for latest) | ||
|
|
||
| **What It Does:** | ||
| 1. Checks out the repository | ||
| 2. Sets up Python environment with configured version | ||
| 3. Installs current dependencies | ||
| 4. Checks for outdated packages | ||
| 5. (Optional) Updates specific package if provided | ||
| 6. Creates a new branch with updates | ||
| 7. Commits and pushes changes | ||
|
|
||
| **Usage Examples:** | ||
|
|
||
| **Check all packages for updates:** | ||
| - Go to Actions tab | ||
| - Select "Update Dependencies" workflow | ||
| - Click "Run workflow" | ||
| - Leave inputs empty | ||
| - Click "Run workflow" | ||
|
|
||
| **Update specific package:** | ||
| - Go to Actions tab | ||
| - Select "Update Dependencies" workflow | ||
| - Click "Run workflow" | ||
| - Enter package name (e.g., `numpy`) | ||
| - Optionally enter version (e.g., `1.24.0`) | ||
| - Click "Run workflow" | ||
|
|
||
| **Notes:** | ||
| - The workflow only runs if the repository owner is `JaclynCodes` | ||
| - Changes are pushed to a new branch with format `automated/update-dependencies-YYYYMMDD` | ||
| - Manual review is recommended before merging dependency updates | ||
| - The workflow uses GitHub Actions bot for commits | ||
|
|
||
| ## Other Workflows | ||
|
|
||
| ### CI (Continuous Integration) | ||
| **File:** `.github/workflows/blank.yml` | ||
| - Runs on push and pull requests to main branch | ||
| - Performs linting, testing, and builds | ||
|
|
||
| ### CodeQL Advanced | ||
| **File:** `.github/workflows/codeql.yml` | ||
| - Security scanning workflow | ||
| - Runs on schedule and PR events | ||
|
|
||
| ### License Check | ||
| **File:** `.github/workflows/license-check.yml` | ||
| - Validates license compliance | ||
|
|
||
| ### Static Content Deployment | ||
| **File:** `.github/workflows/static.yml` | ||
| - Deploys static content to GitHub Pages | ||
|
|
||
| ## Contributing | ||
|
|
||
| When adding or modifying workflows: | ||
| 1. Follow YAML best practices | ||
| 2. Use environment variables for configuration | ||
| 3. Add appropriate documentation | ||
| 4. Test workflows before merging | ||
| 5. Follow the repository's contribution guidelines |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The workflow installs
pip-toolsbut never uses it afterward. Either remove this install (to reduce runtime/network and simplify the workflow) or actually use pip-tools for compiling/updating requirements if that was the intent.