Skip to content

Commit d9309ea

Browse files
committed
Log code inspection issues to console and GitHub step summary on lint failure
1 parent 8e392d3 commit d9309ea

2 files changed

Lines changed: 45 additions & 9 deletions

File tree

.github/workflows/code-style.yml

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,29 @@ jobs:
141141
- name: Run Backend Linting
142142
working-directory: developer-cli
143143
run: |
144-
set -o pipefail
145-
dotnet run lint --backend ${{ needs.detect-scope.outputs.backend_scope }} --no-build | tee lint-output.log
146-
147-
if ! grep -q "No backend issues found!" lint-output.log; then
148-
echo "Code linting issues found."
144+
set +e
145+
dotnet run lint --backend ${{ needs.detect-scope.outputs.backend_scope }} --no-build
146+
LINT_EXIT_CODE=$?
147+
set -e
148+
149+
if [ $LINT_EXIT_CODE -ne 0 ]; then
150+
echo ""
151+
echo "::error::Code linting issues found."
152+
echo ""
153+
154+
RESULT_FILE=$(find ${GITHUB_WORKSPACE}/application -maxdepth 2 -name result.json -type f 2>/dev/null | head -n 1)
155+
156+
if [ -n "$RESULT_FILE" ] && [ -f "$RESULT_FILE" ]; then
157+
cat "$RESULT_FILE"
158+
echo ""
159+
echo "### Code Inspection Issues" >> $GITHUB_STEP_SUMMARY
160+
echo '```json' >> $GITHUB_STEP_SUMMARY
161+
cat "$RESULT_FILE" >> $GITHUB_STEP_SUMMARY
162+
echo "" >> $GITHUB_STEP_SUMMARY
163+
echo '```' >> $GITHUB_STEP_SUMMARY
164+
else
165+
echo "Result file not found in application/"
166+
fi
149167
exit 1
150168
fi
151169

.github/workflows/developer-cli.yml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,29 @@ jobs:
5555
- name: Run Code Linting
5656
working-directory: developer-cli
5757
run: |
58-
set -o pipefail
59-
dotnet run --no-build -- lint --cli --no-build | tee lint-output.log
58+
set +e
59+
dotnet run --no-build -- lint --cli --no-build
60+
LINT_EXIT_CODE=$?
61+
set -e
6062
61-
if ! grep -q "No developer-cli issues found!" lint-output.log; then
62-
echo "Code linting issues found."
63+
if [ $LINT_EXIT_CODE -ne 0 ]; then
64+
echo ""
65+
echo "::error::Code linting issues found."
66+
echo ""
67+
68+
RESULT_FILE="result.json"
69+
70+
if [ -f "$RESULT_FILE" ]; then
71+
cat "$RESULT_FILE"
72+
echo ""
73+
echo "### Code Inspection Issues" >> $GITHUB_STEP_SUMMARY
74+
echo '```json' >> $GITHUB_STEP_SUMMARY
75+
cat "$RESULT_FILE" >> $GITHUB_STEP_SUMMARY
76+
echo "" >> $GITHUB_STEP_SUMMARY
77+
echo '```' >> $GITHUB_STEP_SUMMARY
78+
else
79+
echo "Result file not found in developer-cli/"
80+
fi
6381
exit 1
6482
fi
6583

0 commit comments

Comments
 (0)