Skip to content
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

[cli] implements vc deploy --logs and vc inspect --logs #11672

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

feugy
Copy link
Member

@feugy feugy commented May 30, 2024

🧐 What's in there?

This is the first part of distinguishing build logs from runtime logs.
The proposal is to provide:

  • vc deploy --logs: in addition to deploying the application, it should tail and display the build logs until the build finishes.
  • vc inspect --logs: instead of retuning a summary of the builds, it reads the build logs
  • vc inspect --logs --wait: when the build is in progress, tails the build logs until the configured timeout (3m by default), or display all available logs when the build is finished.
  • vc logs: read the runtime logs (not part of this PR, breaking change)

🧪 How to test?

Given a local application location in xyz folder, already linked to a vercel project:

  • pnpm -F vercel dev deploy --cwd xyz --logs to deploy and see build logs
  • pnpm -F vercel dev deploy --cwd xyz to deploy and see spinners instead
  • pnpm -F vercel dev inspect --cwd xyz dpl_ID/url --logs to see build logs of an existing deployment
  • pnpm -F vercel dev inspect --cwd xyz dpl_ID/url to see an existing deployment details
  • pnpm -F vercel dev inspect --cwd xyz dpl_ID/url --logs --wait to see build logs of an existing deployment (better if in progress)
  • pnpm -F vercel dev inspect --cwd xyz dpl_ID/url --logs --wait --timeout 5s to see build logs of an existing deployment (better if in progress) and bail after 5 seconds

Unit tests added:

  • inspect command: pnpm -F vercel exec vitest run /inspect.test
  • deploy command: pnpm -F vercel exec vitest run /deploy.test

❗ Notes to reviewers

It's better to omit whitespace changes when reviewing packages/cli/src/util/events.ts since most of the code was enclosed in a try-catch.

Copy link

changeset-bot bot commented May 30, 2024

🦋 Changeset detected

Latest commit: 3f3b503

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
vercel Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

const eventsRes = await client.fetch(eventsUrl, {
json: false,
signal: abortController?.signal,
});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

client.fetch() supports node-retry options, so this code may be refactored and not being wrapped in a retry call.

client,
deployment.id,
{
mode: 'logs',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use 'deploy' mode here (which triggers its own polling), because it's actually not working.
The API does not return the special "events" which are meant to controller polling.

I highly doubt it's working, and I would suggest we remove this mode parameter and the related code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we use the deploy anywhere?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not to my knowledge.

packages/cli/src/commands/inspect/index.ts Outdated Show resolved Hide resolved
packages/cli/src/commands/inspect/index.ts Outdated Show resolved Hide resolved
packages/cli/src/commands/inspect/index.ts Outdated Show resolved Hide resolved
packages/cli/src/commands/inspect/index.ts Outdated Show resolved Hide resolved
.changeset/curly-otters-guess.md Show resolved Hide resolved
client,
deployment.id,
{
mode: 'logs',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we use the deploy anywhere?

packages/cli/src/util/deploy/process-deployment.ts Outdated Show resolved Hide resolved
packages/cli/src/util/events.ts Outdated Show resolved Hide resolved
packages/cli/src/util/events.ts Show resolved Hide resolved
packages/cli/src/util/events.ts Show resolved Hide resolved
Comment on lines +238 to 243
function exitCode(state: Deployment['readyState']) {
if (state === 'ERROR' || state === 'CANCELED') {
return 1;
}
return 0;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be returning 0 all the time if you don't want to change how status code is returned?

return chalk.gray('UNKNOWN');
function exitCode(state: Deployment['readyState']) {
if (state === 'ERROR' || state === 'CANCELED') {
return 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a change, but I think it makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants