name: CI/CD Pipeline on: push: branches: [ main ] pull_request: branches: [ main ] #schedule: # Run tests daily at 2 AM UTC # - cron: '0 2 * * *' permissions: contents: read actions: read pull-requests: write issues: write env: PYTHON_VERSION: "3.11" jobs: lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v4 with: python-version: ${{ env.PYTHON_VERSION }} - name: Install dependencies run: | python -m pip install --upgrade pip pip install ruff black - name: Run Ruff linter run: ruff check . - name: Run Black formatter check run: black --check . test-unit: runs-on: ubuntu-latest strategy: matrix: python-version: [3.11, 3.12, 3.13] steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Cache pip dependencies uses: actions/cache@v4 with: path: ~/.cache/pip key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt', '**/pyproject.toml') }} restore-keys: | ${{ runner.os }}-pip- - name: Install Python dependencies run: | python -m pip install --upgrade pip pip install -r requirements_lightweight.txt pip install pytest pytest-cov pytest-html pytest-xdist - name: Verify example data files run: | echo "Checking if example data directory exists:" ls -la example_data/ || echo "example_data directory not found" echo "Checking for specific CSV files:" ls -la example_data/*.csv || echo "No CSV files found" - name: Run CLI and GUI tests run: | cd test python run_tests.py - name: Run tests with pytest run: | pytest test/test.py test/test_gui_only.py -v --tb=short --junitxml=test-results.xml - name: Run tests with coverage run: | pytest test/test.py test/test_gui_only.py --cov=. --cov-report=xml --cov-report=html --cov-report=term - name: Upload test results uses: actions/upload-artifact@v4 if: always() with: name: test-results-python-${{ matrix.python-version }} path: | test-results.xml htmlcov/ coverage.xml test-integration: runs-on: ubuntu-latest needs: [lint, test-unit] steps: - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v4 with: python-version: ${{ env.PYTHON_VERSION }} - name: Install dependencies run: | python -m pip install --upgrade pip pip install -r requirements_lightweight.txt pip install pytest pytest-cov - name: Verify example data files run: | echo "Checking if example data directory exists:" ls -la example_data/ echo "Checking for specific CSV files:" ls -la example_data/*.csv || echo "No CSV files found" - name: Run integration tests (CLI and GUI) run: | cd test python run_tests.py - name: Test CLI help run: | python cli_topics.py --help - name: Test CLI version run: | python -c "import sys; print(f'Python {sys.version}')" security: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v4 with: python-version: ${{ env.PYTHON_VERSION }} - name: Install dependencies run: | python -m pip install --upgrade pip pip install bandit - name: Run bandit security check run: | bandit -r . -f json -o bandit-report.json || true - name: Upload security report uses: actions/upload-artifact@v4 if: always() with: name: security-report path: bandit-report.json build: runs-on: ubuntu-latest needs: [lint, test-unit] if: github.event_name == 'push' && github.ref == 'refs/heads/main' steps: - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v4 with: python-version: ${{ env.PYTHON_VERSION }} - name: Install build dependencies run: | python -m pip install --upgrade pip pip install build twine - name: Build package run: | python -m build - name: Check package run: | twine check dist/* - name: Upload build artifacts uses: actions/upload-artifact@v4 with: name: dist path: dist/