Skip to content

Commit d659632

Browse files
50 - If re-running a job with debug on, set log level to debug (#51)
- Added check of workflow debug regime.
1 parent b2bddf1 commit d659632

File tree

4 files changed

+35
-7
lines changed

4 files changed

+35
-7
lines changed

.github/workflows/build.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,18 @@ jobs:
6565
CHANGED_FILES=$(echo "$CHANGED_FILES" | awk '{printf "%s,", $0} END {print ""}' | sed 's/,$//')
6666
6767
# Generate coverage report for changed files
68-
CHANGED_FILES_REPORT=$(coverage report --include="$CHANGED_FILES")
69-
echo "Changed Python files: $CHANGED_FILES_REPORT"
70-
68+
coverage report --include="$CHANGED_FILES" > coverage_report.txt
69+
echo -e "\nChanged Python files report:\n\n"
70+
cat coverage_report.txt
71+
7172
# Fail if the coverage for changed files is below threshold
72-
coverage report --include="$CHANGED_FILES" | grep TOTAL | awk '{if ($4 < 80.0) exit 1}'
73+
COVERAGE_TOTAL=$(awk '/TOTAL/ {print $4}' coverage_report.txt)
74+
echo "Total coverage for changed files: $COVERAGE_TOTAL"
75+
76+
if (( $(echo "$COVERAGE_TOTAL < 80.0" | bc -l) )); then
77+
echo "Coverage is below 80%"
78+
exit 1
79+
fi
7380
7481
- name: Upload coverage report
7582
uses: actions/upload-artifact@v3

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Generate Release Notes action is dedicated to enhance the quality and organizati
7272
- **Description**: Set to true to enable verbose logging for detailed output during the action's execution.
7373
- **Required**: No
7474
- **Default**: false
75-
75+
- **Note**: If workflow run in debug regime, 'verbose' logging is activated.
7676

7777
## Outputs
7878
The output of the action is a markdown string containing the release notes for the specified tag. This string can be used in subsequent steps to publish the release notes to a file, create a GitHub release, or send notifications.

release_notes_generator/action_inputs.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import json
1818
import logging
19+
import os
1920

2021
from release_notes_generator.utils.gh_action import get_action_input
2122

@@ -31,6 +32,7 @@ class ActionInputs:
3132
PRINT_EMPTY_CHAPTERS = 'print-empty-chapters'
3233
CHAPTERS_TO_PR_WITHOUT_ISSUE = 'chapters-to-pr-without-issue'
3334
VERBOSE = 'verbose'
35+
RUNNER_DEBUG = 'RUNNER_DEBUG'
3436

3537
@staticmethod
3638
def get_github_repository() -> str:
@@ -70,7 +72,7 @@ def get_chapters_to_pr_without_issue() -> bool:
7072

7173
@staticmethod
7274
def get_verbose() -> bool:
73-
return get_action_input(ActionInputs.VERBOSE).lower() == 'true'
75+
return os.getenv('RUNNER_DEBUG', 0) == 1 or get_action_input(ActionInputs.VERBOSE).lower() == 'true'
7476

7577
@staticmethod
7678
def validate_inputs():

tests/test_action_inputs.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,25 @@ def test_get_chapters_to_pr_without_issue(mocker):
125125
assert ActionInputs.get_chapters_to_pr_without_issue() is False
126126

127127

128-
def test_get_verbose(mocker):
128+
def test_get_verbose_verbose_by_action_input(mocker):
129129
mocker.patch('release_notes_generator.action_inputs.get_action_input', return_value='true')
130+
mocker.patch('os.getenv', return_value=0)
130131
assert ActionInputs.get_verbose() is True
132+
133+
134+
def test_get_verbose_verbose_by_workflow_debug(mocker):
135+
mocker.patch('release_notes_generator.action_inputs.get_action_input', return_value='false')
136+
mocker.patch('os.getenv', return_value=1)
137+
assert ActionInputs.get_verbose() is True
138+
139+
140+
def test_get_verbose_verbose_by_both(mocker):
141+
mocker.patch('release_notes_generator.action_inputs.get_action_input', return_value='true')
142+
mocker.patch('os.getenv', return_value=1)
143+
assert ActionInputs.get_verbose() is True
144+
145+
146+
def test_get_verbose_not_verbose(mocker):
147+
mocker.patch('release_notes_generator.action_inputs.get_action_input', return_value='false')
148+
mocker.patch('os.getenv', return_value=0)
149+
assert ActionInputs.get_verbose() is False

0 commit comments

Comments
 (0)