|
| 1 | +name: CI/CD Pipeline |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: '*.*.*' |
| 6 | + release: |
| 7 | + types: [ published ] |
| 8 | + |
| 9 | +jobs: |
| 10 | + test: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + python-version: |
| 15 | + - '3.8' |
| 16 | + - '3.9' |
| 17 | + - '3.10' |
| 18 | + - '3.11' |
| 19 | + - '3.12' |
| 20 | + - '3.13' |
| 21 | + - '3.14' |
| 22 | + |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v3 |
| 25 | + |
| 26 | + - name: Set up Python ${{ matrix.python-version }} |
| 27 | + uses: actions/setup-python@v4 |
| 28 | + with: |
| 29 | + python-version: ${{ matrix.python-version }} |
| 30 | + |
| 31 | + - name: Install dependencies |
| 32 | + run: | |
| 33 | + python -m pip install --upgrade pip |
| 34 | + python -m pip install pytest pytest-cov |
| 35 | + # pip install -e ".[test]" |
| 36 | +
|
| 37 | + - name: Run tests |
| 38 | + run: | |
| 39 | + # python -m pytest tests/ --cov=lib --cov-report=xml |
| 40 | + export PYTHONPATH="$(pwd -P)/lib:$PYTHONPATH" |
| 41 | + python -m pytest tests/unit/python.py --cov=lib --cov-report=term |
| 42 | +
|
| 43 | + # - name: Upload coverage to Codecov |
| 44 | + # uses: codecov/codecov-action@v3 |
| 45 | + # if: matrix.python-version == '3.10' |
| 46 | + # with: |
| 47 | + # file: ./coverage.xml |
| 48 | + # fail_ci_if_error: true |
| 49 | + |
| 50 | + security: |
| 51 | + runs-on: ubuntu-latest |
| 52 | + steps: |
| 53 | + - uses: actions/checkout@v3 |
| 54 | + |
| 55 | + - name: Set up Python |
| 56 | + uses: actions/setup-python@v4 |
| 57 | + with: |
| 58 | + python-version: '3.10' |
| 59 | + |
| 60 | + - name: Install safety |
| 61 | + run: pip install safety |
| 62 | + |
| 63 | + - name: Check dependencies for vulnerabilities |
| 64 | + run: safety check --full-report |
| 65 | + |
| 66 | + - name: Install bandit |
| 67 | + run: pip install bandit |
| 68 | + |
| 69 | + - name: Static security analysis |
| 70 | + run: bandit -r lib/ -f json -o bandit-report.json --skip B101 |
| 71 | + |
| 72 | + type-check: |
| 73 | + runs-on: ubuntu-latest |
| 74 | + steps: |
| 75 | + - uses: actions/checkout@v3 |
| 76 | + |
| 77 | + - name: Set up Python |
| 78 | + uses: actions/setup-python@v4 |
| 79 | + with: |
| 80 | + python-version: '3.10' |
| 81 | + |
| 82 | + - name: Install mypy |
| 83 | + run: pip install mypy |
| 84 | + |
| 85 | + - name: Type checking |
| 86 | + run: | |
| 87 | + export PYTHONPATH="$(pwd -P)/lib:$PYTHONPATH" |
| 88 | + mypy lib/ --disable-error-code import-untyped |
| 89 | +
|
| 90 | + build: |
| 91 | + needs: [test, security, type-check] |
| 92 | + runs-on: ubuntu-latest |
| 93 | + |
| 94 | + steps: |
| 95 | + - uses: actions/checkout@v3 |
| 96 | + |
| 97 | + - name: Set up Python |
| 98 | + uses: actions/setup-python@v4 |
| 99 | + with: |
| 100 | + python-version: '3.10' |
| 101 | + |
| 102 | + - name: Install build dependencies |
| 103 | + run: pip install build wheel |
| 104 | + |
| 105 | + - name: Build wheel package |
| 106 | + run: python -m build --wheel |
| 107 | + |
| 108 | + - name: List artifacts |
| 109 | + run: ls -la dist/ |
| 110 | + |
| 111 | + - name: Upload wheel to GitHub Releases |
| 112 | + uses: svenstaro/upload-release-action@v2 |
| 113 | + with: |
| 114 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 115 | + file: dist/*.whl |
| 116 | + tag: ${{ github.ref }} |
| 117 | + overwrite: true |
| 118 | + file_glob: true |
0 commit comments