Repository navigation
feat(compute): status prints the last deploy/build failure reason #361
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
Open
jwfing
wants to merge
1
commit into
main
Choose a base branch
from
junwenfeng/646-compute-status-last-failure
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| // `insta compute status` rendering: `live=none` must come with the reason the newest deploy | ||
| // attempt failed, and the build-logs command when it was a build (insta-platform #646). | ||
| import { describe, it, expect } from 'vitest' | ||
| import { statusLines } from '../src/commands/compute.js' | ||
|
|
||
| describe('statusLines', () => { | ||
| it('prints only desired vs live when the platform sends no failure', () => { | ||
| expect(statusLines('api', { desiredState: 'running', state: 'running' })).toEqual(['compute api: desired=running live=running']) | ||
| }) | ||
|
|
||
| it('prints the failure reason and the build-logs command for a repo build', () => { | ||
| expect(statusLines('api', { | ||
| desiredState: 'running', state: 'none', | ||
| lastFailure: { kind: 'deploy', at: '2026-10-08T09:34:03.123Z', reason: 'app on the vm not ready (listening on :8080) within 2m0s', buildId: '6a20f7bb-0000-4000-8000-000000000000', buildSource: 'github' }, | ||
| })).toEqual([ | ||
| 'compute api: desired=running live=none', | ||
| 'last deploy failed 2026-10-08 09:34 UTC: app on the vm not ready (listening on :8080) within 2m0s', | ||
| ' → insta build logs 6a20f7bb-0000-4000-8000-000000000000 --source github', | ||
| ]) | ||
| }) | ||
|
|
||
| it('names an archive build source and a build-phase failure', () => { | ||
| const lines = statusLines('api', { desiredState: 'running', state: 'none', lastFailure: { kind: 'build', at: '2026-10-08T09:34:03Z', reason: 'no Dockerfile', buildId: 'op-1', buildSource: 'archive' } }) | ||
| expect(lines[1]).toBe('last build failed 2026-10-08 09:34 UTC: no Dockerfile') | ||
| expect(lines[2]).toBe(' → insta build logs op-1 --source archive') | ||
| }) | ||
|
|
||
| it('an image deploy has no build to point at', () => { | ||
| expect(statusLines('api', { desiredState: 'running', state: 'stopped', lastFailure: { kind: 'deploy', at: '2026-10-08T09:34:03Z', reason: 'nothing on 8080' } })) | ||
| .toEqual(['compute api: desired=running live=stopped', 'last deploy failed 2026-10-08 09:34 UTC: nothing on 8080']) | ||
| }) | ||
| }) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
P3: The build-logs hint silently assumes --source github when the platform omits buildSource, but the build logs command itself defaults to --source archive (src/index.ts:545), and archive sources take deploy-operation IDs while github sources take GitHub build IDs. If the platform ever sends buildId without buildSource (the type here allows exactly that combination), a user debugging a failed archive/source-dir deploy would be handed 'insta build logs <op-id> --source github', which reads the wrong record. Since the companion platform work defines this contract, either guarantee buildSource whenever buildId is present and drop the github fallback, or only emit the hint when the source is known.
Prompt for AI agents