Skip to content

Integrate GitHub actions debug mode detection #322

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
webknjaz opened this issue Jan 19, 2025 · 3 comments
Open

Integrate GitHub actions debug mode detection #322

webknjaz opened this issue Jan 19, 2025 · 3 comments

Comments

@webknjaz
Copy link
Member

webknjaz commented Jan 19, 2025

This should be possible by inspecting the following information sources:

There's additionally ${{ runner.debug }} to look at: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs#runner-context.

Ref: https://docs.github.com/en/actions/managing-workflow-runs-and-deployments/managing-workflow-runs/re-running-workflows-and-jobs#about-re-running-workflows-and-jobs

We may also want to take the rerun attempt into account.

Could provide a skip-existing-on: rerun | debug | second/third-attempt or something.

@Jomik
Copy link

Jomik commented Feb 21, 2025

Meanwhile, we can add

with:
  verbose: ${{ toJSON(runner.debug == '1') }}

@webknjaz
Copy link
Member Author

@Jomik nice find! Though, what I have in mind is a more integrated approach. This input only adds --verbose to twine upload. Meanwhile, we also have a few places where we print stuff that would be good to integrate.

@webknjaz
Copy link
Member Author

webknjaz commented Mar 25, 2025

Observations: when restarting jobs and using that checkbox to enable debug logging, GHA internally sets ${{ secrets.ACTIONS_STEP_DEBUG == 'true' }} and ${{ secrets.ACTIONS_RUNNER_DEBUG == 'true' }}.

And when ACTIONS_STEP_DEBUG is set, runner.debug is set, too.

This means, that whether the internal GHA machinery within the runners is requested to output detailed logs can be detected with ${{ secrets.ACTIONS_RUNNER_DEBUG == 'true' || (secrets.ACTIONS_RUNNER_DEBUG != '' && vars.ACTIONS_RUNNER_DEBUG == 'true') }} and is not directly inspectable from runtime. This would work in composite actions, but if they call some other scripts, the mode would have to be passed through. If this is set, the logs downloadable from GHA job run contain a runner-diagnostic-logs/ folder, which is not present otherwise. That folder contains a .zip file, which needs to be unpacked too, and it contains two text files — Runner_*.log and Worker_*.log.

Refs https://github.com/actions/toolkit/blob/main/docs/action-debugging.md#step-debug-logs.

And detecting the step debug (for user-provided actions or run-steps) has more ways:

  1. ${{ runner.debug == '1' }} in composite actions
  2. ${{ secrets.ACTIONS_STEP_DEBUG == 'true' || (secrets.ACTIONS_STEP_DEBUG != '' && vars.ACTIONS_STEP_DEBUG == 'true') }} in composite actions
  3. ${{ env.RUNNER_DEBUG == '1' }} in composite actions
  4. [[ "${RUNNER_DEBUG}" == '1' ]] in called bash scripts, run-steps and anything external (os.getenv('RUNNER_DEBUG') == '1' in Python, for example)

Additionally, printing out ::debug:: workflow commands in steps is evaluated by the runner and shows up depending on ACTIONS_STEP_DEBUG too.

The question is whether we need to care about the runner debug requests or not.

webknjaz added a commit to sphinx-contrib/sphinxcontrib-towncrier that referenced this issue Apr 8, 2025
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

No branches or pull requests

2 participants