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

Automatically turn on debugging #264

Closed
TWiStErRob opened this issue Jun 4, 2022 · 16 comments · Fixed by #363
Closed

Automatically turn on debugging #264

TWiStErRob opened this issue Jun 4, 2022 · 16 comments · Fixed by #363
Labels
enhancement New feature or request

Comments

@TWiStErRob
Copy link

TWiStErRob commented Jun 4, 2022

I'm trying to debug a script: | block, and I have to modify the script with debug: true to be able to do so even though there's UI for it in shape of "[x] Enable debug logging".

Describe the solution you'd like
Make the default value of debug param

github-script/action.yml

Lines 15 to 17 in 7a5c598

debug:
description: Whether to tell the GitHub client to log details of its requests
default: false

equivalent to default: ${{ secrets.ACTIONS_STEP_DEBUG || false }}. Not sure if this would work verbatum, but what would work best if it tries to read the secret, and if that fails or not set, then falls back to the now-default false. I tried this as a parameter to the action, and it works well.

Describe alternatives you've considered
Trying to remember to put debug: ${{ secrets.ACTIONS_STEP_DEBUG || false }} for all of my .yml files.

Additional context
See TWiStErRob/github-actions-test#1 for the workaround.

Normal run without debugging: https://github.com/TWiStErRob/github-actions-test/runs/6740560658
Re-ran with Enable debug logging: https://github.com/TWiStErRob/github-actions-test/runs/6740567848

Note: ignore the fact that there's no output, reported that separately #265

TWiStErRob added a commit to TWiStErRob/github-actions-test that referenced this issue Jun 4, 2022
@joshmgross joshmgross added the enhancement New feature or request label Jun 16, 2022
@TWiStErRob
Copy link
Author

@DanRigby @mjpieters now that debug actually does something, what are your thoughts on this?

@mjpieters
Copy link
Contributor

I kind-of like this idea, it makes sense.

You can always use debug: false if you don't like the request logs from appearing when you enable debug logging, and debug: true if you want it enabled permanently.

@joshmgross
Copy link
Member

Something like this should work with the existing "Enable debug logging" option:

const debug = core.getBooleanInput('debug') || core.isDebug()

@TWiStErRob
Copy link
Author

You can always use debug: false if you don't like the request logs from appearing when you enable debug logging, and debug: true if you want it enabled permanently.

@mjpieters Is my reading correct that you meant that the default makes sense in line with the UI checkbox, and if someone wants a different 'static' behavior, they can use what you described. i.e. "You can" = "If someone wants".

@TWiStErRob
Copy link
Author

TWiStErRob commented Apr 4, 2023

@joshmgross that wouldn't allow explicit debug: false to always turn it off, regardless of debug flag, right?

@joshmgross
Copy link
Member

that wouldn't allow explicit debug: false to always turn it off, regardless of debug flag, right?

Good point, we'd need to check if it's set first:

  const debugSpecified = core.getInput('debug') !== ''
  const debug = debugSpecified ? core.getBooleanInput('debug') : core.isDebug()

@TWiStErRob
Copy link
Author

TWiStErRob commented Apr 4, 2023

... and that implies changing the default to '' (meaning "smart"), I guess, because GHA or core would automatically fill the value in?

This looks like a viable -2+3 PR already :)

@mjpieters
Copy link
Contributor

... and that implies changing the default to '' (meaning "smart"), I guess, because GHA or core would automatically fill the value in?

core.getInput() returns a string, always, and so '' is the value that you get when debug is not set (and there is no default value set in action.yml).

@TWiStErRob
Copy link
Author

TWiStErRob commented Apr 4, 2023

core.getInput() returns a string, always, and so '' is the value that you get when debug is not set

Yep, that's what I'm thinking too...

and there is no default value set in action.yml

... but there's a default right now:

github-script/action.yml

Lines 15 to 17 in 8d76c9a

debug:
description: Whether to tell the GitHub client to log details of its requests
default: false

and we need some default (e.g. '') because we want to keep it optional.

@mjpieters
Copy link
Contributor

mjpieters commented Apr 4, 2023

However, you can use Github Action expressions as the default in actions.yml, so default: ${{ env.RUNNER_DEBUG || 'false' }} should work just fine.

@mjpieters
Copy link
Contributor

Correction: RUNNER_DEBUG is either absent (empty) or set to '1', but getBooleanInput() looks for true or false (in various capitalisations), so the expression I gave is wrong. This should work better:

  default: ${{ (env.RUNNER_DEBUG == '1' && 'true') || 'false' }}

@mjpieters
Copy link
Contributor

I've confirmed locally (via https://github.com/nektos/act) that the above expression works as designed.

@TWiStErRob
Copy link
Author

Does runner_debug take the secrets into account?

@mjpieters
Copy link
Contributor

Does runner_debug take the secrets into account?

The ACTIONS_STEP_DEBUG secret triggers debug mode but when triggered the runner sets the RUNNER_DEBUG environment variable.

Testing for the environment variable is also what core.isDebug() does.

@TWiStErRob
Copy link
Author

Thanks for the PR @mjpieters, I was just about to create one :)

@TWiStErRob
Copy link
Author

Thanks for your efforts @mjpieters, it wasn't as trivial as it looked in the above conversation.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants