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

Default debug to current runner debug state #363

Merged
merged 1 commit into from Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
59 changes: 39 additions & 20 deletions .github/workflows/integration.yml
Expand Up @@ -187,7 +187,11 @@ jobs:
echo $'\u2705 Test passed' | tee -a $GITHUB_STEP_SUMMARY

test-debug:
name: 'Integration test: debug option'
strategy:
matrix:
environment: ['', 'debug-integration-test']
environment: ${{ matrix.environment }}
name: "Integration test: debug option (runner.debug mode ${{ matrix.environment && 'enabled' || 'disabled' }})"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -204,6 +208,7 @@ jobs:
script: |
const log = github.log
return {
runnerDebugMode: core.isDebug(),
debug: log.debug === console.debug,
info: log.info === console.info
}
Expand All @@ -215,6 +220,7 @@ jobs:
script: |
const log = github.log
return {
runnerDebugMode: core.isDebug(),
debug: log.debug === console.debug,
info: log.info === console.info
}
Expand All @@ -226,26 +232,39 @@ jobs:
script: |
const log = github.log
return {
runnerDebugMode: core.isDebug(),
debug: log.debug === console.debug,
info: log.info === console.info
}
- run: |
echo "- Validating debug default"
expected='{debug:false,info:false}'
if [[ "${{steps.debug-default.outputs.result}}" != "$expected" ]]; then
echo $'::error::\u274C' "Expected '$expected', got ${{steps.debug-default.outputs.result}}"
exit 1
fi
echo "- Validating debug set to true"
expected='{debug:true,info:true}'
if [[ "${{steps.debug-true.outputs.result}}" != "$expected" ]]; then
echo $'::error::\u274C' "Expected '$expected', got ${{steps.debug-true.outputs.result}}"
exit 1
fi
echo "- Validating debug set to false"
expected='{debug:false,info:false}'
if [[ "${{steps.debug-false.outputs.result}}" != "$expected" ]]; then
echo $'::error::\u274C' "Expected '$expected', got ${{steps.debug-false.outputs.result}}"
exit 1
fi
- id: evaluate-tests
name: Evaluate test outputs
env:
RDMODE: ${{ runner.debug == '1' }}
run: |
# tests table, pipe separated: label | output | expected
# leading and trailing spaces on any field are trimmed
tests=$(cat << 'TESTS'
Validating debug default |\
${{ steps.debug-default.outputs.result }} |\
{"runnerDebugMode":${{ env.RDMODE }},"debug":${{ env.RDMODE }},"info":${{ env.RDMODE }}}
Validating debug set to true |\
${{ steps.debug-true.outputs.result }} |\
{"runnerDebugMode":${{ env.RDMODE }},"debug":true,"info":true}
Validating debug set to false |\
${{ steps.debug-false.outputs.result }} |\
{"runnerDebugMode":${{ env.RDMODE }},"debug":false,"info":false}
TESTS
)

strim() { shopt -s extglob; lt="${1##+( )}"; echo "${lt%%+( )}"; }
while IFS='|' read label output expected; do
label="$(strim "$label")"; output="$(strim "$output")"; expected="$(strim "$expected")"
echo -n "- $label:"
if [[ "$output" != "$expected" ]]; then
echo $'\n::error::\u274C' "Expected '$expected', got '$output'"
exit 1
fi
echo $' \u2705'
done <<< "$tests"

echo $'\u2705 Test passed' | tee -a $GITHUB_STEP_SUMMARY
4 changes: 2 additions & 2 deletions action.yml
Expand Up @@ -13,8 +13,8 @@ inputs:
default: ${{ github.token }}
required: false
debug:
description: Whether to tell the GitHub client to log details of its requests
default: false
description: Whether to tell the GitHub client to log details of its requests. true or false. Default is to run in debug mode when the GitHub Actions step debug logging is turned on.
default: ${{ runner.debug == '1' }}
user-agent:
description: An optional user-agent string
default: actions/github-script
Expand Down