Skip to content

feat: Print action outputs to console#2265

Merged
helderco merged 1 commit intodagger:mainfrom
helderco:outputs
May 2, 2022
Merged

feat: Print action outputs to console#2265
helderco merged 1 commit intodagger:mainfrom
helderco:outputs

Conversation

@helderco
Copy link
Copy Markdown
Contributor

@helderco helderco commented Apr 21, 2022

Resolves #1351

👀 Doc preview

Signed-off-by: Helder Correia

@helderco helderco changed the title feat: Print action outputs to console Print action outputs to console Apr 21, 2022
@helderco helderco force-pushed the outputs branch 3 times, most recently from 165abf7 to a055cf7 Compare April 22, 2022 16:59
@helderco helderco force-pushed the outputs branch 2 times, most recently from d536ee1 to c0306eb Compare April 22, 2022 17:16
@helderco
Copy link
Copy Markdown
Contributor Author

Getting errors on sops.

@helderco
Copy link
Copy Markdown
Contributor Author

Update: I'm blocked by the same issue as:

I need to go back to a fix for it in order to move forward:

@helderco helderco force-pushed the outputs branch 3 times, most recently from 1d8404d to e68aed9 Compare April 27, 2022 16:20
@helderco helderco force-pushed the outputs branch 3 times, most recently from 7d20991 to d83552f Compare April 27, 2022 20:50
@helderco helderco marked this pull request as ready for review April 27, 2022 20:53
@helderco helderco requested review from a team, aluzzardi, samalba and shykes as code owners April 27, 2022 20:53
@helderco
Copy link
Copy Markdown
Contributor Author

helderco commented Apr 27, 2022

Update: asked for feedback upstream on the blocker: cue-lang/cue#1671. Solution in #2024 allows to unblock.

👀 Updated doc preview

I tried filling from tasks to a r.final but got data races. So approach was to recover computed values and only fill at the end. This will be simplified in CUE v0.4.3 with cue-lang/cue@04ac666.

Ready for review.

Copy link
Copy Markdown
Contributor

@marcosnils marcosnils left a comment

Choose a reason for hiding this comment

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

Just minor nit comment. Only reviewed the .md instructions and they LGTM!

@helderco helderco force-pushed the outputs branch 4 times, most recently from 348967f to 7ee6bb6 Compare April 28, 2022 00:17
@aluzzardi
Copy link
Copy Markdown
Contributor

Haven't looked in depth yet but looks good!

Q: Aren't the outputs polluted by random fields, or is there some logic to clean that up? (I looked at the logic of isOutput but couldn't find anything related to that).

For instance, for a netlify.#Deploy, shouldn't we see a bunch of noise in deploy.container (generated by bash.#Run)?

@helderco
Copy link
Copy Markdown
Contributor Author

helderco commented Apr 28, 2022

Q: Aren't the outputs polluted by random fields, or is there some logic to clean that up? (I looked at the logic of isOutput but couldn't find anything related to that).

For instance, for a netlify.#Deploy, shouldn't we see a bunch of noise in deploy.container (generated by bash.#Run)?

No because we're using only top-level fields of an action, not going deep. The netlify.#Deploy action is a good example as it correctly exports to the top-level what outputs are of interest:

	// URL of the deployed site
	url: container.export.files."/netlify/url"

	// URL of the latest deployment
	deployUrl: container.export.files."/netlify/deployUrl"

	// URL for logs of the latest deployment
	logsUrl: container.export.files."/netlify/logsUrl"

Which produces the output you can see here:

APP_NAME=dagger-todo dagger do deploy
[✔] actions.deps
[✔] actions.test.script
[✔] client.env
[✔] actions.build.run.script
[✔] actions.deploy.container.script
[✔] client.filesystem."./".read
[✔] actions.deploy
[✔] actions.test
[✔] actions.build.run
[✔] actions.build.contents
[✔] actions.deploy.container
[✔] client.filesystem."./_build".write
[✔] actions.deploy.container.export
Field      Value
url        "https://dagger-todo.netlify.app"
deployUrl  "https://62698983ffe8661d60613431--dagger-todo.netlify.app"
logsUrl    "https://app.netlify.com/sites/dagger-todo/deploys/62698983ffe8661d60613431"

So you can create a wrapper action to control which outputs (and CLI inputs) you want, as you can see in this example: https://deploy-preview-2265--devel-docs-dagger-io.netlify.app/1226/handling-outputs/#controlling-the-output

@aluzzardi
Copy link
Copy Markdown
Contributor

aluzzardi commented Apr 28, 2022

The netlify.#Deploy action is a good example as it correctly exports to the top-level what outputs are of interest

Yes, I noticed the output is perfect, that's what got me wondering on what's the wizardry behind that makes it look good :)

No because we're using only top-level fields of an action

How do we define top-level fields? For instance:

  • web contains build and deploy (build is yarn and deploy is netlify)
  • web.deploy is netlify
  • web.deploy.container is an internal field of netlify (bash.#Run)

web, deploy and container are actions in this case.

What would end up in outputs? Is it going to be the outputs of web only?

@helderco
Copy link
Copy Markdown
Contributor Author

What would end up in outputs? Is it going to be the outputs of web only?

Yes 🙂

@helderco helderco changed the title Print action outputs to console feat: Print action outputs to console Apr 29, 2022
I attempted to fill a final value from the tasks but got data races, so approach was to recover computed values and only fill at the end. This will become moot when CUE will return that final value in v0.4.3.

Signed-off-by: Helder Correia <[email protected]>
@aluzzardi
Copy link
Copy Markdown
Contributor

Ohh, clever! Makes sense -- this is the perfect counter part of --inputs, top-level only.

Copy link
Copy Markdown
Contributor

@aluzzardi aluzzardi left a comment

Choose a reason for hiding this comment

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

Design & Code LGTM

Copy link
Copy Markdown
Contributor

@shykes shykes left a comment

Choose a reason for hiding this comment

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

Can’t wait to play with this!

I’m sure we’ll find rough edges but we can deal with them as we go.

Thanks @helderco !

@helderco helderco merged commit c03b971 into dagger:main May 2, 2022
@helderco helderco deleted the outputs branch May 2, 2022 18:18
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.

Add outputs to screen

4 participants