Merge pull request #193 from rowingdude/rowingdude-patch-1 #10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI/CD Pipeline | |
| on: | |
| push: | |
| branches: [ main, master, develop ] | |
| pull_request: | |
| branches: [ main, master, develop ] | |
| jobs: | |
| test: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install pytest pytest-cov pytest-asyncio | |
| pip install -e . | |
| - name: Lint with flake8 | |
| run: | | |
| pip install flake8 | |
| # stop the build if there are Python syntax errors or undefined names | |
| flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | |
| # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | |
| flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | |
| - name: Type check with mypy | |
| run: | | |
| pip install mypy types-setuptools | |
| mypy src/analyzeMFT --ignore-missing-imports || true | |
| - name: Test syntax compilation | |
| run: | | |
| echo "Testing syntax compilation of all Python files..." | |
| python -c " | |
| import os | |
| import py_compile | |
| import sys | |
| failed = [] | |
| for root, dirs, files in os.walk('.'): | |
| for file in files: | |
| if file.endswith('.py') and not file.startswith('.'): | |
| filepath = os.path.join(root, file) | |
| try: | |
| py_compile.compile(filepath, doraise=True) | |
| print(f'✓ {filepath}') | |
| except Exception as e: | |
| print(f'✗ {filepath}: {e}') | |
| failed.append(filepath) | |
| if failed: | |
| print(f'\\nSyntax check failed for {len(failed)} files') | |
| sys.exit(1) | |
| else: | |
| print(f'\\nAll Python files passed syntax check') | |
| " | |
| - name: Run unit tests with pytest | |
| run: | | |
| pytest tests/ -v --tb=short --cov=src/analyzeMFT --cov-report=xml --cov-report=term-missing | |
| - name: Upload coverage reports to Codecov | |
| uses: codecov/codecov-action@v3 | |
| with: | |
| file: ./coverage.xml | |
| flags: unittests | |
| name: codecov-umbrella | |
| fail_ci_if_error: false | |
| security: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| - name: Install security tools | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install bandit safety | |
| - name: Run bandit security linter | |
| run: | | |
| bandit -r src/ -f json -o bandit-report.json || true | |
| bandit -r src/ | |
| - name: Check for known security vulnerabilities | |
| run: | | |
| pip install -r requirements.txt | |
| safety check --json --output safety-report.json || true | |
| safety check | |
| integration: | |
| needs: test | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install -e . | |
| - name: Run integration tests | |
| run: | | |
| echo "Running integration test suite..." | |
| pytest tests/test_integration.py -v --tb=short | |
| - name: Test CLI functionality | |
| run: | | |
| echo "Testing CLI functionality..." | |
| python -m src.analyzeMFT.test_generator --help | |
| # Generate test MFT file | |
| python -m src.analyzeMFT.test_generator test_sample.mft --num-records 100 | |
| # Test analysis | |
| python analyzeMFT.py -f test_sample.mft -o test_output.csv --csv | |
| # Verify output exists and has content | |
| if [ ! -f test_output.csv ]; then | |
| echo "Error: Output file not created" | |
| exit 1 | |
| fi | |
| lines=$(wc -l < test_output.csv) | |
| if [ $lines -lt 2 ]; then | |
| echo "Error: Output file appears empty (only $lines lines)" | |
| exit 1 | |
| fi | |
| echo "✓ CLI test passed - generated $lines lines of output" | |
| quality: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| - name: Install quality tools | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install black isort pylint | |
| - name: Check code formatting with black | |
| run: | | |
| black --check --diff src/ tests/ | |
| - name: Check import sorting with isort | |
| run: | | |
| isort --check-only --diff src/ tests/ | |
| - name: Lint with pylint | |
| run: | | |
| pip install -r requirements.txt | |
| pip install -e . | |
| pylint src/analyzeMFT --exit-zero --score=yes --reports=yes |