|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main, develop ] |
| 6 | + pull_request: |
| 7 | + branches: [ main, develop ] |
| 8 | + |
| 9 | +jobs: |
| 10 | + code-quality: |
| 11 | + name: Code Quality |
| 12 | + runs-on: ubuntu-latest |
| 13 | + strategy: |
| 14 | + matrix: |
| 15 | + python-version: ["3.11", "3.12"] |
| 16 | + |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v4 |
| 19 | + |
| 20 | + - name: Set up Python ${{ matrix.python-version }} |
| 21 | + uses: actions/setup-python@v5 |
| 22 | + with: |
| 23 | + python-version: ${{ matrix.python-version }} |
| 24 | + |
| 25 | + - name: Cache pip dependencies |
| 26 | + uses: actions/cache@v4 |
| 27 | + with: |
| 28 | + path: ~/.cache/pip |
| 29 | + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt', 'pyproject.toml') }} |
| 30 | + restore-keys: | |
| 31 | + ${{ runner.os }}-pip- |
| 32 | +
|
| 33 | + - name: Install dependencies |
| 34 | + run: | |
| 35 | + python -m pip install --upgrade pip |
| 36 | + pip install -e ".[dev]" |
| 37 | +
|
| 38 | + - name: Code formatting with Black |
| 39 | + run: | |
| 40 | + black --check --diff meshcore_mqtt/ tests/ |
| 41 | +
|
| 42 | + - name: Linting with Flake8 |
| 43 | + run: | |
| 44 | + flake8 meshcore_mqtt/ tests/ |
| 45 | +
|
| 46 | + - name: Type checking with MyPy |
| 47 | + run: | |
| 48 | + mypy meshcore_mqtt/ tests/ |
| 49 | +
|
| 50 | + - name: Import sorting with isort |
| 51 | + run: | |
| 52 | + isort --check-only --diff meshcore_mqtt/ tests/ |
| 53 | +
|
| 54 | + test: |
| 55 | + name: Tests |
| 56 | + runs-on: ubuntu-latest |
| 57 | + strategy: |
| 58 | + matrix: |
| 59 | + python-version: ["3.11", "3.12"] |
| 60 | + |
| 61 | + steps: |
| 62 | + - uses: actions/checkout@v4 |
| 63 | + |
| 64 | + - name: Set up Python ${{ matrix.python-version }} |
| 65 | + uses: actions/setup-python@v5 |
| 66 | + with: |
| 67 | + python-version: ${{ matrix.python-version }} |
| 68 | + |
| 69 | + - name: Cache pip dependencies |
| 70 | + uses: actions/cache@v4 |
| 71 | + with: |
| 72 | + path: ~/.cache/pip |
| 73 | + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt', 'pyproject.toml') }} |
| 74 | + restore-keys: | |
| 75 | + ${{ runner.os }}-pip- |
| 76 | +
|
| 77 | + - name: Install dependencies |
| 78 | + run: | |
| 79 | + python -m pip install --upgrade pip |
| 80 | + pip install -e ".[dev]" |
| 81 | +
|
| 82 | + - name: Run tests with pytest |
| 83 | + run: | |
| 84 | + pytest -v --cov=meshcore_mqtt --cov-report=xml --cov-report=term-missing |
| 85 | +
|
| 86 | + - name: Upload coverage to Codecov |
| 87 | + uses: codecov/codecov-action@v3 |
| 88 | + with: |
| 89 | + file: ./coverage.xml |
| 90 | + flags: unittests |
| 91 | + name: codecov-umbrella |
| 92 | + fail_ci_if_error: false |
| 93 | + |
| 94 | + security: |
| 95 | + name: Security Scan |
| 96 | + runs-on: ubuntu-latest |
| 97 | + |
| 98 | + steps: |
| 99 | + - uses: actions/checkout@v4 |
| 100 | + |
| 101 | + - name: Set up Python |
| 102 | + uses: actions/setup-python@v5 |
| 103 | + with: |
| 104 | + python-version: "3.12" |
| 105 | + |
| 106 | + - name: Install dependencies |
| 107 | + run: | |
| 108 | + python -m pip install --upgrade pip |
| 109 | + pip install -e ".[dev]" |
| 110 | +
|
| 111 | + - name: Run Bandit security scan |
| 112 | + run: | |
| 113 | + bandit -r meshcore_mqtt/ -f json -o bandit-report.json || true |
| 114 | + bandit -r meshcore_mqtt/ |
| 115 | +
|
| 116 | + # - name: Run Safety check |
| 117 | + # run: | |
| 118 | + # safety check --json --output safety-report.json || true |
| 119 | + # safety check |
| 120 | + |
| 121 | + build-test: |
| 122 | + name: Build Test |
| 123 | + runs-on: ubuntu-latest |
| 124 | + |
| 125 | + steps: |
| 126 | + - uses: actions/checkout@v4 |
| 127 | + |
| 128 | + - name: Set up Python |
| 129 | + uses: actions/setup-python@v5 |
| 130 | + with: |
| 131 | + python-version: "3.12" |
| 132 | + |
| 133 | + - name: Install build dependencies |
| 134 | + run: | |
| 135 | + python -m pip install --upgrade pip |
| 136 | + pip install build twine |
| 137 | +
|
| 138 | + - name: Build package |
| 139 | + run: | |
| 140 | + python -m build |
| 141 | +
|
| 142 | + - name: Check package |
| 143 | + run: | |
| 144 | + twine check dist/* |
| 145 | +
|
| 146 | + - name: Test installation |
| 147 | + run: | |
| 148 | + pip install dist/*.whl |
| 149 | + python -c "import meshcore_mqtt; print('Package installed successfully')" |
0 commit comments