Browse Source

validate-licenses: also verify LICENSE content is Apache 2.0 (#3633)

The existing check only verified that a LICENSE file exists in each
plugins/ directory. Extend it to also grep for 'Apache License' and
'Version 2.0' so that a placeholder or wrong-license file is caught
at PR time rather than silently passing.

Co-authored-by: Claude <noreply@anthropic.com>
Noah Zweben 2 tháng trước cách đây
mục cha
commit
8326199c6e

+ 12 - 1
.github/workflows/validate-licenses.yml

@@ -22,10 +22,14 @@ jobs:
         run: |
         run: |
           set -euo pipefail
           set -euo pipefail
           missing=()
           missing=()
+          wrong_content=()
           for plugin_dir in plugins/*/; do
           for plugin_dir in plugins/*/; do
             plugin="${plugin_dir%/}"
             plugin="${plugin_dir%/}"
             if [[ ! -f "$plugin/LICENSE" ]]; then
             if [[ ! -f "$plugin/LICENSE" ]]; then
               missing+=("$plugin")
               missing+=("$plugin")
+            elif ! grep -q "Apache License" "$plugin/LICENSE" || \
+                 ! grep -q "Version 2.0" "$plugin/LICENSE"; then
+              wrong_content+=("$plugin")
             fi
             fi
           done
           done
           if [[ "${#missing[@]}" -gt 0 ]]; then
           if [[ "${#missing[@]}" -gt 0 ]]; then
@@ -35,4 +39,11 @@ jobs:
             done
             done
             exit 1
             exit 1
           fi
           fi
-          echo "All $(ls -d plugins/*/ | wc -l) plugins have a LICENSE file."
+          if [[ "${#wrong_content[@]}" -gt 0 ]]; then
+            echo "::error::The following plugins have a LICENSE file that does not contain Apache 2.0 text:"
+            for p in "${wrong_content[@]}"; do
+              echo "  - $p"
+            done
+            exit 1
+          fi
+          echo "All $(ls -d plugins/*/ | wc -l) plugins have an Apache 2.0 LICENSE file."