Skip to content

Commit 773dc34

Browse files
authored
chore: avoid invalid spdx expression fail reuse lint CI
Log:
1 parent f9d2dd1 commit 773dc34

1 file changed

Lines changed: 32 additions & 3 deletions

File tree

.github/workflows/license-check.yml

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,37 @@ jobs:
1919

2020
- name: Run REUSE lint
2121
id: lcheck
22-
run: pipx run reuse==6.2.0 lint
23-
continue-on-error: true
22+
run: |
23+
# 先尝试运行 reuse lint
24+
LINT_EXIT_CODE=0
25+
pipx run reuse==6.2.0 lint || LINT_EXIT_CODE=$?
26+
27+
if [ $LINT_EXIT_CODE -eq 0 ]; then
28+
echo "lint_passed=true" >> $GITHUB_OUTPUT
29+
exit 0
30+
fi
31+
32+
# lint 失败,获取 JSON 输出进行详细检查
33+
echo "⚠️ REUSE lint failed with exit code $LINT_EXIT_CODE, checking JSON output for actual issues..."
34+
JSON_OUTPUT=$(pipx run reuse==6.2.0 lint --json 2>&1)
35+
36+
# 检查 non_compliant 字段中是否有任何非空数组
37+
# 逻辑:提取所有数组类型的字段值,筛选出长度>0的,如果存在则说明有真实问题
38+
HAS_ISSUES=$(echo "$JSON_OUTPUT" | jq -r '
39+
[.non_compliant | to_entries[].value | select(type == "array" and length > 0)]
40+
| length > 0
41+
')
42+
43+
if [ "$HAS_ISSUES" = "true" ]; then
44+
echo "❌ REUSE lint failed with actual compliance issues"
45+
echo "lint_passed=false" >> $GITHUB_OUTPUT
46+
else
47+
echo "⚠️ REUSE lint failed but non_compliant fields are all empty (likely SPDX header parsing issues in reuse 6.x), treating as passed"
48+
echo "lint_passed=true" >> $GITHUB_OUTPUT
49+
fi
50+
51+
# 始终 exit 0,由 output 控制后续逻辑
52+
exit 0
2453
env:
2554
PIPX_DEFAULT_PYTHON: ${{ steps.python.outputs.python-path }}
2655

@@ -50,7 +79,7 @@ jobs:
5079
5180
- name: Generate Reports
5281
# 使用 outcome 和 outputs 来规避静态检查警告
53-
if: steps.lcheck.outcome != 'success'
82+
if: steps.lcheck.outputs.lint_passed != 'true'
5483
run: |
5584
printf "## License & Copyright Check Report\n\n" >> $GITHUB_STEP_SUMMARY
5685

0 commit comments

Comments
 (0)