Skip to content

Commit f2a2dde

Browse files
Adding summary and annotations
1 parent 6e32376 commit f2a2dde

1 file changed

Lines changed: 39 additions & 5 deletions

File tree

.github/workflows/copyright-check.yml

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ jobs:
127127
- name: Validate
128128
id: validate
129129
if: steps.changed-files.outputs.skip-validation != 'true'
130+
continue-on-error: true
130131
run: |
131132
set -o pipefail
132133
echo "Starting copyright validation..."
@@ -181,7 +182,7 @@ jobs:
181182
fi
182183
183184
- name: Job Summary (Markdown block extraction)
184-
if: steps.changed-files.outputs.skip-validation != 'true'
185+
if: always() && steps.changed-files.outputs.skip-validation != 'true'
185186
run: |
186187
summary_file="$GITHUB_STEP_SUMMARY"
187188
if [ ! -f validation_output.txt ]; then
@@ -190,14 +191,47 @@ jobs:
190191
fi
191192
awk '/^<<<COPYRIGHT-CHECK:MARKDOWN>>>/{flag=1;next}/^<<<END COPYRIGHT-CHECK:MARKDOWN>>>/{flag=0}flag' validation_output.txt >> "$summary_file"
192193
194+
- name: Annotate Summary
195+
if: always() && steps.changed-files.outputs.skip-validation != 'true'
196+
run: |
197+
python3 - <<'PY'
198+
import re, json, pathlib
199+
text = pathlib.Path('validation_output.txt').read_text()
200+
# Exact block extraction (no fallback parsing)
201+
m = re.search(r'<<<COPYRIGHT-CHECK:JSON>>>\s*(.*?)\s*<<<END COPYRIGHT-CHECK:JSON>>>', text, re.S)
202+
if not m:
203+
# No annotation if block missing (no fallback)
204+
raise SystemExit(0)
205+
js = json.loads(m.group(1))
206+
counts = js.get('counts', {})
207+
failed = counts.get('invalid', 0)
208+
summary_parts = [
209+
f"Total {counts.get('total',0)}",
210+
f"Passed {counts.get('valid',0)}",
211+
f"Failed {failed}"
212+
]
213+
skipped = counts.get('excluded',0)
214+
if skipped:
215+
summary_parts.append(f"Skipped {skipped}")
216+
summary_line = ' | '.join(summary_parts)
217+
if failed > 0:
218+
print(f"::error title=Copyright Summary::{summary_line}")
219+
failed_files = js.get('failed', [])
220+
if failed_files:
221+
# Truncate list to first 10
222+
display = failed_files[:10]
223+
listing = ', '.join(f['file'] for f in display)
224+
extra = '' if len(failed_files) <= 10 else f" (+{len(failed_files)-10} more)"
225+
print(f"::error title=Failed Files::{listing}{extra}")
226+
else:
227+
print(f"::notice title=Copyright Summary::{summary_line}")
228+
PY
229+
193230
- name: Fail if needed
194-
if: steps.changed-files.outputs.skip-validation != 'true'
231+
if: always() && steps.changed-files.outputs.skip-validation != 'true'
195232
run: |
196233
if [ "${{ steps.validate.outputs.status }}" != "success" ]; then
197-
echo "::error title=Copyright Check Failed::Some files invalid"
198234
exit 1
199-
else
200-
echo "::notice title=Copyright Check Passed::All files valid"
201235
fi
202236
203237
- name: No-op summary

0 commit comments

Comments
 (0)