|
9 | 9 | jobs: |
10 | 10 | test: |
11 | 11 | runs-on: ubuntu-latest |
12 | | - |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + python-version: ['3.10', '3.11', '3.12'] |
| 15 | + |
13 | 16 | steps: |
14 | | - - uses: actions/checkout@v3 |
15 | | - |
16 | | - - name: Set up Python |
17 | | - uses: actions/setup-python@v4 |
| 17 | + - uses: actions/checkout@v4 |
| 18 | + |
| 19 | + - name: Set up Python ${{ matrix.python-version }} |
| 20 | + uses: actions/setup-python@v5 |
18 | 21 | with: |
19 | | - python-version: '3.11' |
20 | | - |
| 22 | + python-version: ${{ matrix.python-version }} |
| 23 | + |
21 | 24 | - name: Install dependencies |
22 | 25 | run: | |
23 | 26 | python -m pip install --upgrade pip |
24 | | - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi |
25 | | - |
| 27 | + pip install -r requirements.txt |
| 28 | + pip install pytest pytest-cov pytest-mock |
| 29 | +
|
26 | 30 | - name: Run tests |
27 | 31 | run: | |
28 | | - if [ -d tests ]; then |
29 | | - python -m pytest tests/ || echo "Tests not yet implemented" |
30 | | - else |
31 | | - echo "No tests directory found" |
32 | | - fi |
| 32 | + python -m pytest test/ -v --cov=cortex --cov-report=xml --cov-report=term-missing |
| 33 | +
|
| 34 | + - name: Upload coverage to Codecov |
| 35 | + uses: codecov/codecov-action@v4 |
| 36 | + if: matrix.python-version == '3.11' |
| 37 | + with: |
| 38 | + file: ./coverage.xml |
| 39 | + fail_ci_if_error: false |
| 40 | + |
| 41 | + lint: |
| 42 | + runs-on: ubuntu-latest |
| 43 | + |
| 44 | + steps: |
| 45 | + - uses: actions/checkout@v4 |
| 46 | + |
| 47 | + - name: Set up Python |
| 48 | + uses: actions/setup-python@v5 |
| 49 | + with: |
| 50 | + python-version: '3.11' |
| 51 | + |
| 52 | + - name: Install linting tools |
| 53 | + run: | |
| 54 | + python -m pip install --upgrade pip |
| 55 | + pip install black pylint mypy |
| 56 | +
|
| 57 | + - name: Check formatting with black |
| 58 | + run: | |
| 59 | + black --check cortex/ || echo "::warning::Code formatting issues found. Run 'black cortex/' to fix." |
| 60 | +
|
| 61 | + - name: Lint with pylint |
| 62 | + run: | |
| 63 | + pylint cortex/ --exit-zero --output-format=text | tee pylint-report.txt |
| 64 | + score=$(tail -n 2 pylint-report.txt | head -n 1 | grep -oP '\d+\.\d+') |
| 65 | + echo "Pylint score: $score" |
| 66 | +
|
| 67 | + security: |
| 68 | + runs-on: ubuntu-latest |
| 69 | + |
| 70 | + steps: |
| 71 | + - uses: actions/checkout@v4 |
| 72 | + |
| 73 | + - name: Set up Python |
| 74 | + uses: actions/setup-python@v5 |
| 75 | + with: |
| 76 | + python-version: '3.11' |
| 77 | + |
| 78 | + - name: Install security tools |
| 79 | + run: | |
| 80 | + python -m pip install --upgrade pip |
| 81 | + pip install bandit safety |
| 82 | +
|
| 83 | + - name: Run Bandit security linter |
| 84 | + run: | |
| 85 | + bandit -r cortex/ -ll -ii || echo "::warning::Security issues found. Please review." |
| 86 | +
|
| 87 | + - name: Check dependencies with safety |
| 88 | + run: | |
| 89 | + pip install -r requirements.txt |
| 90 | + safety check --full-report || echo "::warning::Vulnerable dependencies found." |
0 commit comments