Ver código fonte

Add a tool to check "forbidden" content.

Also add a Makefile target and CI task for it.
Qi Xiao 2 anos atrás
pai
commit
9185e04b69
3 arquivos alterados com 30 adições e 1 exclusões
  1. 9 0
      .github/workflows/ci.yml
  2. 4 1
      Makefile
  3. 17 0
      tools/check-content.sh

+ 9 - 0
.github/workflows/ci.yml

@@ -170,6 +170,15 @@ jobs:
     - name: Run codespell
       run: codespell
 
+  check-content:
+    name: Check content
+    runs-on: ubuntu-latest
+    steps:
+    - name: Checkout code
+      uses: actions/checkout@v2
+    - name: Run check-content.sh
+      run: ./tools/check-content.sh
+
   check-rellinks:
     name: Check relative links
     runs-on: ubuntu-latest

+ 4 - 1
Makefile

@@ -58,5 +58,8 @@ lint:
 codespell:
 	codespell --skip .git
 
+check-content:
+	./tools/check-content.sh
+
 .SILENT: checkstyle-go checkstyle-md lint
-.PHONY: default get generate test style checkstyle checkstyle-go checkstyle-md lint cover
+.PHONY: default get generate test cover style checkstyle checkstyle-go checkstyle-md lint codespell check-content

+ 17 - 0
tools/check-content.sh

@@ -0,0 +1,17 @@
+#!/bin/sh -e
+
+# Check Go source files for disallowed content.
+
+echo 'Disallowed import of net/rpc:'
+if find . -name '*.go' | xargs grep '"net/rpc"'; then
+    exit 1
+else
+    echo '  None!'
+fi
+
+echo 'Disallowed call of unix.{Umask,Getrlimit,Setrlimit}'
+if find . -name '*.go' | egrep -v '\./pkg/(mods/unix|daemon|testutil)' | xargs egrep 'unix\.(Umask|Getrlimit|Setrlimit)'; then
+    exit 1
+else
+    echo '  None!'
+fi