|
8 | 8 | strategy: |
9 | 9 | matrix: |
10 | 10 | os: [ubuntu-latest, windows-latest] |
11 | | - python-version: ["3.9", "3.10", "3.11", "3.12"] |
| 11 | + python-version: ['3.9', '3.10', '3.11', '3.12'] |
12 | 12 |
|
13 | 13 | steps: |
14 | 14 | - uses: actions/checkout@v3 |
|
18 | 18 | with: |
19 | 19 | python-version: ${{ matrix.python-version }} |
20 | 20 | architecture: x64 |
21 | | - cache: "pip" |
| 21 | + cache: 'pip' |
22 | 22 |
|
23 | 23 | - name: Install Poetry manager |
24 | 24 | run: pip install --upgrade poetry |
|
28 | 28 |
|
29 | 29 | - name: Test with pytest |
30 | 30 | run: | |
31 | | - poetry run pytest --cov=transloadit tests |
| 31 | + poetry run pytest --cov=transloadit \ |
| 32 | + --cov-report=xml \ |
| 33 | + --cov-report=term-missing \ |
| 34 | + --cov-fail-under=65 \ |
| 35 | + tests |
| 36 | +
|
| 37 | + - name: Upload coverage reports |
| 38 | + if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12' |
| 39 | + uses: codecov/codecov-action@v4 |
| 40 | + with: |
| 41 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 42 | + files: ./coverage.xml |
| 43 | + flags: unittests |
| 44 | + name: python-sdk |
| 45 | + fail_ci_if_error: true |
| 46 | + |
| 47 | + coverage: |
| 48 | + needs: python |
| 49 | + runs-on: ubuntu-latest |
| 50 | + steps: |
| 51 | + - uses: actions/checkout@v3 |
| 52 | + |
| 53 | + - name: Set up Python |
| 54 | + uses: actions/setup-python@v4 |
| 55 | + with: |
| 56 | + python-version: '3.12' |
| 57 | + architecture: x64 |
| 58 | + cache: 'pip' |
| 59 | + |
| 60 | + - name: Install Poetry manager |
| 61 | + run: pip install --upgrade poetry |
| 62 | + |
| 63 | + - name: Install Dependencies |
| 64 | + run: poetry install |
| 65 | + |
| 66 | + - name: Generate coverage report |
| 67 | + run: | |
| 68 | + poetry run pytest --cov=transloadit \ |
| 69 | + --cov-report=json \ |
| 70 | + --cov-report=html \ |
| 71 | + tests |
| 72 | +
|
| 73 | + - name: Check coverage thresholds |
| 74 | + run: | |
| 75 | + COVERAGE=$(poetry run coverage report | grep TOTAL | awk '{print $4}' | sed 's/%//') |
| 76 | + THRESHOLD=65 |
| 77 | +
|
| 78 | + if (( $(echo "$COVERAGE < $THRESHOLD" | bc -l) )); then |
| 79 | + echo "Coverage ($COVERAGE%) is below threshold ($THRESHOLD%)" |
| 80 | + exit 1 |
| 81 | + else |
| 82 | + echo "Coverage ($COVERAGE%) meets threshold ($THRESHOLD%)" |
| 83 | + fi |
| 84 | +
|
| 85 | + - name: Upload coverage artifacts |
| 86 | + uses: actions/upload-artifact@v4 |
| 87 | + with: |
| 88 | + name: coverage-reports |
| 89 | + path: | |
| 90 | + coverage.json |
| 91 | + htmlcov/ |
0 commit comments