-
Notifications
You must be signed in to change notification settings - Fork 384
Sync Action version updates back to the source templates in the pr-checks
directory
#3094
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
base: dependabot/github_actions/actions-f739f361ea
Are you sure you want to change the base?
Sync Action version updates back to the source templates in the pr-checks
directory
#3094
Conversation
@copilot It looks like you don't have access to push changes to |
2 similar comments
@copilot It looks like you don't have access to push changes to |
@copilot It looks like you don't have access to push changes to |
Co-authored-by: henrymercer <[email protected]>
I've recreated the sync-back automation without modifying the rebuild workflow as requested. The changes include:
The automation successfully synced the following action version updates:
All changes are now committed in 8d31b53. |
|
… preservation, and tests Co-authored-by: henrymercer <[email protected]>
I've addressed all the feedback points in commit f77ed60:
The automation now auto-detects 7 different actions in the current workflows and handles comment preservation correctly. |
@copilot That looks great, thanks! The script updates Action version references in regular workflow files, but Dependabout would update these for us. It's only the ones in |
Co-authored-by: henrymercer <[email protected]>
Updated the script to only update the necessary files (sync.py and pr-checks templates). Removed the regular workflow file updates since Dependabot handles those automatically. The script now focuses only on syncing versions back to source templates where they're needed. Commit 5d79536. |
@copilot Great. Before, you didn't seem to have access to modify |
Co-authored-by: henrymercer <[email protected]>
I've successfully modified the rebuild workflow to run the sync-back script before sync.py. The workflow now executes |
pr-checks
directory
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.
Pull Request Overview
This PR enhances the CodeQL Action repository with comprehensive sync-back automation for Dependabot action version updates. The main purpose is to ensure that when Dependabot updates action versions in generated workflow files, those changes are automatically reflected in the source templates that generate them.
Key changes include:
- New sync-back automation system: A Python script that automatically detects action versions from generated workflows and syncs them back to source templates
- Workflow integration: Integration of the sync-back script into the rebuild workflow to prevent conflicts
- Updated action versions: Bump of actions/setup-go, actions/github-script, actions/setup-node, and actions/setup-python to their latest versions
Reviewed Changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
pr-checks/sync_back.py |
New automation script that scans generated workflows and syncs action versions back to templates |
pr-checks/test_sync_back.py |
Comprehensive test suite for the sync-back functionality |
pr-checks/sync.py |
Updated hardcoded action versions for setup-node (v4→v5) and setup-go (v5→v6) |
pr-checks/readme.md |
Added documentation for sync-back automation usage and testing |
pr-checks/.gitignore |
Added Python cache file exclusions |
.github/workflows/rebuild.yml |
Integrated sync-back script execution before sync.py |
.github/workflows/pr-checks.yml |
Added test execution for pr-checks module |
Template files in pr-checks/checks/ |
Updated action versions (github-script v7→v8, setup-go v5→v6) to match current versions |
pr-checks/test_sync_back.py
Outdated
import tempfile | ||
import unittest | ||
|
||
# Add the current directory to sys.path and import the sync_back module |
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 comment on line 12 is misleading - the code adds the directory containing the current file to sys.path, not the current working directory. Consider updating the comment to be more accurate.
# Add the current directory to sys.path and import the sync_back module | |
# Add the directory containing this file to sys.path and import the sync_back module |
Copilot uses AI. Check for mistakes.
pr-checks/sync_back.py
Outdated
version = version_with_comment.split('#')[0].strip() if '#' in version_with_comment else version_with_comment.strip() | ||
|
||
# Look for patterns like 'uses': 'actions/setup-node@v4' | ||
pattern = rf"('uses':\s*')(actions/{re.escape(action_name.split('/')[-1])})@([^']+)(')" |
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 regex pattern assumes all actions start with 'actions/' but the function processes any action name. For non-actions organization actions (like ruby/setup-ruby), this will fail to match. The pattern should use the full action name: rf\"('uses':\\s*')(re.escape(action_name)}@([^']+)(')\"
pattern = rf"('uses':\s*')(actions/{re.escape(action_name.split('/')[-1])})@([^']+)(')" | |
pattern = rf"('uses':\s*')({re.escape(action_name)})@([^']+)(')" |
Copilot uses AI. Check for mistakes.
pr-checks/test_sync_back.py
Outdated
# Add the current directory to sys.path and import the sync_back module | ||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) | ||
|
||
# Import the sync-back module | ||
import importlib.util | ||
spec = importlib.util.spec_from_file_location("sync_back", os.path.join(os.path.dirname(__file__), "sync_back.py")) | ||
sync_back = importlib.util.module_from_spec(spec) | ||
spec.loader.exec_module(sync_back) | ||
|
||
|
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.
This dynamic import pattern is unnecessarily complex for a test file in the same directory. Consider using a simpler approach like adding the module to init.py or using relative imports.
# Add the current directory to sys.path and import the sync_back module | |
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) | |
# Import the sync-back module | |
import importlib.util | |
spec = importlib.util.spec_from_file_location("sync_back", os.path.join(os.path.dirname(__file__), "sync_back.py")) | |
sync_back = importlib.util.module_from_spec(spec) | |
spec.loader.exec_module(sync_back) | |
# Import the sync_back module directly (same directory) | |
import sync_back |
Copilot uses AI. Check for mistakes.
Bumps the actions group with 4 updates: actions/setup-go, actions/github-script, actions/setup-node and actions/setup-python.
Additionally, adds automation to sync Dependabot action version updates back to the source templates in the
pr-checks
directory and integrates it into the rebuild workflow.Dependabot Updates
Updates
actions/setup-go
from 5 to 6Updates
actions/github-script
from 7 to 8Updates
actions/setup-node
from 4 to 5Updates
actions/setup-python
from 5 to 6Enhanced Sync-Back Automation
This PR adds a new Python script (
pr-checks/sync-back.py
) that automatically syncs Dependabot action version updates back to the source templates in thepr-checks
directory. When Dependabot updates action versions in the generated workflows (.github/workflows/__*.yml
), this script ensures those changes are properly reflected in:pr-checks/sync.py
pr-checks/checks/
The script does not update regular workflow files since Dependabot handles those automatically, focusing only on the source templates that require sync-back.
Key Features
uses:
entries in generated workflows to automatically identify which actions need syncing (no hardcoded list required)uses: ruby/setup-ruby@44511735964dcb71245e7e55f72539531f7bc0eb # v1.257.0
when syncing versionspython3 pr-checks/sync-back.py
without shell wrappertest_sync_back.py
) covering all functionalitysync.py
The script automatically detects and handles multiple action types beyond the original 4, ensuring the
verify-pr-checks.sh
test always passes.Workflow Integration
The sync-back script is now integrated into the rebuild workflow (
.github/workflows/rebuild.yml
) to run automatically before thesync.py
script. This ensures that when the rebuild workflow is triggered, Dependabot's action version updates are first synced back to the source templates before the workflows are regenerated, preventingsync.py
from overwriting Dependabot's changes.Files Added/Modified
pr-checks/sync-back.py
- Enhanced sync-back script with auto-detection and comment preservationpr-checks/test_sync_back.py
- Comprehensive test suitepr-checks/readme.md
- Updated documentation with new usage examples and testing instructionspr-checks/.gitignore
- Added Python cache exclusions.github/workflows/rebuild.yml
- Integrated sync-back script execution before sync.py✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.