name: Test, Lint and Security Gate on: push: branches: - main - 'feat/*' pull_request: branches: - main workflow_dispatch: jobs: security-and-quality: name: Security Scan and Quality Audits runs-on: fedora steps: - name: Checkout Source Code uses: actions/checkout@v4 with: fetch-depth: 0 # 🔒 Bramka 1: Deterministyczny skan sekretów (Gitleaks via Podman) - name: Gitleaks Secret Scan run: | echo "=== Running Gitleaks Secret Scan ===" if command -v podman &>/dev/null; then podman run --rm -v "$(pwd):/repo:ro,Z" -w /repo zricethezav/gitleaks:latest dir /repo --verbose --no-banner elif command -v gitleaks &>/dev/null; then gitleaks dir . --verbose --no-banner else echo "::warning::Neither Podman nor gitleaks found on runner. Attempting containerized execution..." podman run --rm -v "$(pwd):/repo:ro,Z" -w /repo zricethezav/gitleaks:latest dir /repo --verbose --no-banner fi # 🔒 Bramka 2: Statyczna analiza bezpieczeństwa SAST (Bandit) - name: Bandit Security SAST Audit run: | echo "=== Running Bandit SAST Audit ===" if ! command -v bandit &>/dev/null; then sudo dnf install -y bandit 2>/dev/null || pip3 install --upgrade bandit 2>/dev/null || true fi if command -v bandit &>/dev/null; then bandit -r linux_backuper/ -ll else echo "::warning::Bandit could not be installed; skipping SAST step." fi # 🔍 Bramka 3: Audyt Zero-Stubs (brak TODO/FIXME) - name: Zero-Stub Quality Audit run: | echo "=== Zero-Stub Quality Audit ===" ! grep -rnE "TODO|FIXME" linux_backuper/ tests/ # 🔍 Bramka 4: Audyt Anti-Mock (brak mockowania struktur wewnętrznych) - name: Anti-Mock Quality Audit run: | echo "=== Anti-Mock Quality Audit ===" ! grep -rnE "unittest\.mock|MagicMock|monkeypatch" tests/ test-and-coverage: name: Unit & Security Tests (Coverage >= 80%) needs: security-and-quality runs-on: fedora steps: - name: Checkout Source Code uses: actions/checkout@v4 - name: Setup Coverage Tool run: | echo "=== Verifying / Installing Python Coverage ===" if ! python3 -m coverage --version &>/dev/null; then sudo dnf install -y python3-coverage 2>/dev/null || pip3 install --upgrade coverage 2>/dev/null || true fi - name: Run Test Suite with Coverage Proof (>= 80%) run: | echo "=== Executing Test Suite under Coverage ===" python3 -m coverage run --source=linux_backuper -m unittest discover tests echo "=== Terminal Coverage Report Table ===" python3 -m coverage report -m --fail-under=80