-
Notifications
You must be signed in to change notification settings - Fork 23
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
Fix missing "debug" and "environment" keys in runner context #79
base: main
Are you sure you want to change the base?
Conversation
* Add validation test * Update completions test * Fix them with adding default context
@@ -78,7 +78,9 @@ function getDefaultContext(name: string, workflowContext: WorkflowContext, mode: | |||
arch: "X64", | |||
name: "GitHub Actions 2", | |||
tool_cache: "/opt/hostedtoolcache", | |||
temp: "/home/runner/work/_temp" | |||
temp: "/home/runner/work/_temp", | |||
debug: "1", |
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.
(Sorry for the false-approval, I misclicked 🥴 )
Shouldn't this be "0"
by default? 🤔
My reasoning is that it will only be "1"
if a workflow is run with a secret/variable ACTIONS_RUNNER_DEBUG
set to true
in context1 (or when ticking the "Enable debug logging" checkbox when re-running jobs)...
Footnotes
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.
Thank you for reviewing. 🙏 I referred https://github.com/github/docs/blob/0208d54f08a79b92ba27a010722c87eb327e1c61/data/reusables/actions/runner-debug-description.md?plain=1#L1 for this value, and I understood the debug will be 1
or empty / undefined
instead of 0
.
I have checked the current ubuntu-24.04 runner behavior in https://github.com/kachick/example-actions-languageservices-78
In normal run
Run echo "$RUNNER_CONTEXT"
echo "$RUNNER_CONTEXT"
shell: /usr/bin/bash -e {0}
env:
RUNNER_CONTEXT: {
"os": "Linux",
"arch": "X64",
"name": "GitHub Actions 14",
"environment": "github-hosted",
"tool_cache": "/opt/hostedtoolcache",
"temp": "/home/runner/work/_temp",
"workspace": "/home/runner/work/example-actions-languageservices-78"
}
{
"os": "Linux",
"arch": "X64",
"name": "GitHub Actions 14",
"environment": "github-hosted",
"tool_cache": "/opt/hostedtoolcache",
"temp": "/home/runner/work/_temp",
"workspace": "/home/runner/work/example-actions-languageservices-78"
}
In debug mode
##[debug]Evaluating: toJson(runner)
##[debug]Evaluating toJson:
##[debug]..Evaluating runner:
##[debug]..=> Object
##[debug]=> '{
##[debug] "debug": "1",
##[debug] "os": "Linux",
##[debug] "arch": "X64",
##[debug] "name": "GitHub Actions 12",
##[debug] "environment": "github-hosted",
##[debug] "tool_cache": "/opt/hostedtoolcache",
##[debug] "temp": "/home/runner/work/_temp",
##[debug] "workspace": "/home/runner/work/example-actions-languageservices-78"
##[debug]}'
##[debug]Result: '{
##[debug] "debug": "1",
##[debug] "os": "Linux",
##[debug] "arch": "X64",
##[debug] "name": "GitHub Actions 12",
##[debug] "environment": "github-hosted",
##[debug] "tool_cache": "/opt/hostedtoolcache",
##[debug] "temp": "/home/runner/work/_temp",
##[debug] "workspace": "/home/runner/work/example-actions-languageservices-78"
##[debug]}'
##[debug]Evaluating condition for step: 'Dump runner context'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: Dump runner context
##[debug]Loading inputs
##[debug]Loading env
Run echo "$RUNNER_CONTEXT"
##[debug]/usr/bin/bash -e /home/runner/work/_temp/9a6f6001-cd7b-41dd-a27f-ebee9cffece7.sh
{
"debug": "1",
"os": "Linux",
"arch": "X64",
"name": "GitHub Actions 12",
"environment": "github-hosted",
"tool_cache": "/opt/hostedtoolcache",
"temp": "/home/runner/work/_temp",
"workspace": "/home/runner/work/example-actions-languageservices-78"
}
##[debug]Finishing: Dump runner context
So I still guessing debug
should never become 0
.
However in this test, ACTIONS_RUNNER_DEBUG
in repository secrets/variables setting does not change the injected ENV.
It looks only depend on the run is debug mode or not.
And I'm guessing actual source of truth is written in https://github.com/actions/runner/blob/6ef5803f24724b77a8d3599a478d06018da5d7c6/src/Runner.Worker/JobRunner.cs#L155-L158.
if (jobContext.Global.WriteDebug)
{
jobContext.SetRunnerContext("debug", "1");
}
Whichever the default value, In my understanding, these values are not actually used in this extension; only the keys are used.
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.
- 👍 If
on
section is not includingpull_request
, accessinggithub.event.pull_request.assignee
alertsContext access might be invalid: pull_request
. - 🤔 On the other hand, this
runner.debug
does not consider whether the runner is actually in debug mode or not.
I have no idea how to realize the polite behavior. 🙇♂️
@elbrenn thank you for updating this PR by merging the main branch. Should I take any further action regarding this PR? |
Fixes #78