|
8 | 8 | jobs: |
9 | 9 | test: |
10 | 10 | runs-on: ubuntu-latest |
11 | | - |
12 | | - # Necessary for the workflow to push changes back to the repo |
13 | 11 | permissions: |
14 | 12 | contents: write |
15 | 13 |
|
16 | 14 | steps: |
17 | | - - name: Checkout repository |
18 | | - uses: actions/checkout@v4 |
| 15 | + - uses: actions/checkout@v4 |
19 | 16 | with: |
20 | | - # Fetches all history so the push doesn't fail on a shallow clone |
21 | 17 | fetch-depth: 0 |
22 | 18 |
|
23 | | - - name: Set up Python |
24 | | - uses: actions/setup-python@v5 |
| 19 | + - uses: actions/setup-python@v5 |
25 | 20 | with: |
26 | 21 | python-version: "3.11" |
27 | 22 |
|
28 | | - - name: Install package |
| 23 | + - name: Install dependencies |
29 | 24 | run: | |
30 | | - python -m pip install --upgrade pip setuptools wheel |
| 25 | + python -m pip install --upgrade pip |
31 | 26 | pip install -e .[dev] |
| 27 | + pip install coverage-badge # Simple tool to make the SVG |
32 | 28 |
|
33 | 29 | - name: Run tests with coverage |
34 | 30 | run: | |
35 | | - pytest --cov=pome \ |
36 | | - --cov-report=json:coverage.json |
| 31 | + pytest --cov=pome |
37 | 32 |
|
38 | | - - name: Generate coverage badge |
39 | | - # Only generate the badge on the default branch |
| 33 | + - name: Generate Badge File |
40 | 34 | if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) |
41 | | - uses: we-cli/coverage-badge-action@main |
| 35 | + run: | |
| 36 | + # This creates 'coverage.svg' in your root folder |
| 37 | + coverage-badge -o coverage.svg -f |
42 | 38 |
|
43 | 39 | - name: Commit and push coverage badge |
44 | | - # Only push the badge on the default branch |
45 | 40 | if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) |
46 | 41 | uses: stefanzweifel/git-auto-commit-action@v5 |
47 | 42 | with: |
48 | 43 | commit_message: "chore: update coverage badge [skip ci]" |
49 | 44 | file_pattern: 'coverage.svg' |
50 | | - # Prevents the action from failing if coverage hasn't changed |
51 | | - skip_dirty_check: false |
0 commit comments