diff --git a/.gitea/workflows/lint.yml b/.gitea/workflows/lint.yml new file mode 100644 index 0000000..e2c71b4 --- /dev/null +++ b/.gitea/workflows/lint.yml @@ -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