Fix stop-after time preservation during workflow recompilation#3950
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Fix ExtractStopTimeFromLockFile to recognize comment pattern - Add --refresh-stop-time flag to force regeneration when needed - Update tests to cover new comment format and flag behavior - Default behavior now preserves existing stop times Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot merge main |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an issue where running make recompile was unnecessarily updating the stop times in lock files, causing unwanted version control changes. The root cause was that ExtractStopTimeFromLockFile was looking for an old pattern (STOP_TIME="...") instead of the current comment pattern (# Effective stop-time: ...), causing it to fail and generate new timestamps.
The implementation:
- Updates the extraction function to recognize the current comment-based stop-time format
- Maintains backward compatibility with the old format
- Adds a
--refresh-stop-timeflag to explicitly force regeneration when needed - Includes comprehensive test coverage for all scenarios
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/stop_after_test.go | Adds comprehensive test coverage for comment format extraction, backward compatibility, and refresh flag behavior |
| pkg/workflow/stop_after.go | Fixes stop-time extraction to recognize comment pattern, adds refresh logic with new flag |
| pkg/workflow/compiler.go | Adds refreshStopTime field and setter method to support the new flag |
| pkg/cli/compile_command.go | Adds RefreshStopTime configuration field and wires it to compiler |
| cmd/gh-aw/main.go | Adds --refresh-stop-time CLI flag definition and passes it through to compile config |
| pkg/cli/.github/aw/actions-lock.json | Creates new empty actions lock file |
| .github/workflows/daily-team-status.lock.yml | Updates stop time (unintended - demonstrates the issue being fixed) |
| .github/workflows/ci-doctor.lock.yml | Updates stop time (unintended - demonstrates the issue being fixed) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@copilot look for pattern below which is more stable: GH_AW_STOP_TIME: yyy-mm-dd hh:mm:ss |
Merged main branch in commit 79c1459. Resolved conflicts by accepting main's versions of the lock files. |
The GH_AW_STOP_TIME env variable pattern is more stable than comments as it's part of the YAML structure and used by the runtime check. Now checks for: 1. GH_AW_STOP_TIME: (most stable, in env section) 2. # Effective stop-time: (comment format) 3. STOP_TIME= (legacy format) All patterns are supported for maximum compatibility. Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Added support for the
Tests confirm the extraction works correctly with all patterns. |
|
@copilot only check for GH_AW_STOP_TIME remove other legacy formats |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Fix: Stop Time Preservation in Workflow Recompilation ✅
Problem Statement
When running
make recompile, the ci-doctor workflow's stop time in the lock file was being updated unnecessarily, causing unwanted changes in version control.Root Cause
The
ExtractStopTimeFromLockFilefunction was looking for an old patternSTOP_TIME="YYYY-MM-DD HH:MM:SS"(used in job-based stop time checks), but the actual lock files now use multiple patterns including a comment format and an environment variable format. When extraction failed, the system regenerated the timestamp withtime.Now().UTC()on every compilation.Solution Implemented
1. Fixed Stop Time Extraction
File:
pkg/workflow/stop_after.goGH_AW_STOP_TIME:pattern (most stable - in YAML env section)ExtractStopTimeFromLockFile()to use prefix-based extraction# Effective stop-time:STOP_TIME=patternprocessStopAfterConfiguration()to respect newrefreshStopTimeflagPattern Priority:
GH_AW_STOP_TIME:- Most stable (part of YAML structure, used by runtime check)# Effective stop-time:- Comment format at top of fileSTOP_TIME=- Legacy format in job steps2. Added CLI Flag for Controlled Refresh
Files:
cmd/gh-aw/main.go,pkg/cli/compile_command.go,pkg/workflow/compiler.go--refresh-stop-timeflag to force regeneration when needed3. Comprehensive Testing
File:
pkg/workflow/stop_after_test.goGH_AW_STOP_TIME:format4. Merged Main Branch
Verification Results
Stop Time Extraction with Multiple Patterns
With Refresh Flag
Test Results
Usage
Default Behavior (Recommended)
# Preserves existing stop times during recompilation gh aw compile make recompileForce Refresh (When Needed)
# Forces regeneration of stop-after times gh aw compile --refresh-stop-time gh aw compile ci-doctor --refresh-stop-timeImpact
make recompileno longer updates stop timesGH_AW_STOP_TIMEpattern (YAML structure)Files Changed
cmd/gh-aw/main.go- Added CLI flagpkg/cli/compile_command.go- Added config fieldpkg/workflow/compiler.go- Added compiler field and setterpkg/workflow/stop_after.go- Added GH_AW_STOP_TIME support, fixed extraction with prefix-based approach, added refresh logicpkg/workflow/stop_after_test.go- Added comprehensive tests for all patternsOriginal prompt
💡 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.