[CI] Gitea Actions: линт YAML, поиск секретов, обязательные файлы
lint / hygiene (push) Failing after 11s
lint / hygiene (push) Failing after 11s
This commit is contained in:
1 parent
4fbb2c20ee
commit
971cc9f5d8
1 file changed
+44
@@ -0,0 +1,44 @@
|
||||
name: lint
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
hygiene:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: YAML и compose
|
||||
run: |
|
||||
python3 - <<'PY'
|
||||
import glob, sys, yaml
|
||||
bad=[]
|
||||
for p in glob.glob('**/*.yml', recursive=True)+glob.glob('**/*.yaml', recursive=True):
|
||||
try:
|
||||
yaml.safe_load(open(p, encoding='utf-8'))
|
||||
except Exception as e:
|
||||
bad.append(f"{p}: {str(e)[:80]}")
|
||||
print("проверено файлов:", len(glob.glob('**/*.yml', recursive=True)))
|
||||
if bad:
|
||||
print("\n".join(bad)); sys.exit(1)
|
||||
PY
|
||||
- name: Секреты в коммите
|
||||
run: |
|
||||
python3 - <<'PY'
|
||||
import re, subprocess, sys
|
||||
files = subprocess.run(["git","ls-files"],capture_output=True,text=True).stdout.split()
|
||||
pat = re.compile(r"(?i)(password|passwd|api[_-]?key|secret|token)\s*[:=]\s*['\"]?[A-Za-z0-9_\-]{16,}")
|
||||
hits=[]
|
||||
for f in files:
|
||||
if f.endswith(('.md','.yml','.yaml','.py','.sh','.json','.ini','.conf','.env')):
|
||||
try: t=open(f,encoding='utf-8',errors='ignore').read()
|
||||
except Exception: continue
|
||||
for m in pat.finditer(t):
|
||||
if 'example' in m.group(0).lower() or 'placeholder' in m.group(0).lower(): continue
|
||||
hits.append(f"{f}: подозрение на секрет")
|
||||
print("файлов проверено:", len(files))
|
||||
if hits:
|
||||
print("\n".join(hits[:10])); sys.exit(1)
|
||||
PY
|
||||
- name: Обязательные файлы
|
||||
run: |
|
||||
for f in README.md docs/ARCHITECTURE.md ops; do
|
||||
test -e "$f" || { echo "нет $f"; exit 1; }
|
||||
done
|
||||
Reference in new issue
Block a user