Skip to content

Commit 393ec14

Browse files
committed
Fixed coverage action
1 parent 3326dcb commit 393ec14

1 file changed

Lines changed: 81 additions & 77 deletions

File tree

Lines changed: 81 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,81 @@
1-
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3-
4-
name: build
5-
6-
env:
7-
package: tinyscript
8-
9-
on:
10-
push:
11-
branches: [ "main" ]
12-
pull_request:
13-
branches: [ "main" ]
14-
15-
jobs:
16-
build:
17-
runs-on: ${{ matrix.os }}
18-
strategy:
19-
fail-fast: false
20-
matrix:
21-
os: [ubuntu-latest]
22-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
23-
steps:
24-
- uses: actions/checkout@v3
25-
- name: Set up Python ${{ matrix.python-version }}
26-
uses: actions/setup-python@v4
27-
with:
28-
python-version: ${{ matrix.python-version }}
29-
- name: Install pandoc
30-
run: sudo apt-get install -y pandoc
31-
- name: Install ${{ env.package }}
32-
run: |
33-
python -m pip install --upgrade pip
34-
python -m pip install pytest pytest-cov coverage
35-
pip install -r requirements.txt
36-
pip install .
37-
- name: Test ${{ env.package }} with pytest
38-
run: |
39-
pytest --cov=$package
40-
coverage:
41-
needs: build
42-
runs-on: ubuntu-latest
43-
env:
44-
cov_badge_path: docs/coverage.svg
45-
steps:
46-
- uses: actions/checkout@v3
47-
- name: Install pandoc
48-
run: sudo apt-get install -y pandoc
49-
- name: Install ${{ env.package }}
50-
run: |
51-
python -m pip install --upgrade pip
52-
python -m pip install pytest pytest-cov
53-
pip install -r requirements.txt
54-
pip install .
55-
- name: Make coverage badge for ${{ env.package }}
56-
run: |
57-
pip install genbadge[coverage]
58-
pytest --cov=$package --cov-report=xml
59-
genbadge coverage -i coverage.xml -o $cov_badge_path
60-
- name: Verify Changed files
61-
uses: tj-actions/verify-changed-files@v12
62-
id: changed_files
63-
with:
64-
files: ${{ env.cov_badge_path }}
65-
- name: Commit files
66-
if: steps.changed_files.outputs.files_changed == 'true'
67-
run: |
68-
git config --local user.email "github-actions[bot]@users.noreply.github.com"
69-
git config --local user.name "github-actions[bot]"
70-
git add $cov_badge_path
71-
git commit -m "Updated coverage.svg"
72-
- name: Push changes
73-
if: steps.changed_files.outputs.files_changed == 'true'
74-
uses: ad-m/github-push-action@master
75-
with:
76-
github_token: ${{ secrets.github_token }}
77-
branch: ${{ github.ref }}
1+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3+
4+
name: build
5+
6+
env:
7+
package: tinyscript
8+
9+
on:
10+
push:
11+
branches: [ "main" ]
12+
pull_request:
13+
branches: [ "main" ]
14+
15+
jobs:
16+
build:
17+
runs-on: ${{ matrix.os }}
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
os: [ubuntu-latest]
22+
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
23+
steps:
24+
- uses: actions/checkout@v3
25+
- name: Set up Python ${{ matrix.python-version }}
26+
uses: actions/setup-python@v4
27+
with:
28+
python-version: ${{ matrix.python-version }}
29+
- name: Install pandoc
30+
run: sudo apt-get install -y pandoc
31+
- name: Install ${{ env.package }}
32+
run: |
33+
python -m pip install --upgrade pip
34+
python -m pip install pytest pytest-cov coverage
35+
pip install -r requirements.txt
36+
pip install .
37+
- name: Test ${{ env.package }} with pytest
38+
run: |
39+
pytest --cov=$package
40+
coverage:
41+
needs: build
42+
runs-on: ubuntu-latest
43+
env:
44+
cov_badge_path: docs/coverage.svg
45+
steps:
46+
- uses: actions/checkout@v3
47+
- name: Set up Python ${{ matrix.python-version }}
48+
uses: actions/setup-python@v4
49+
with:
50+
python-version: 3.11
51+
- name: Install pandoc
52+
run: sudo apt-get install -y pandoc notification-daemon
53+
- name: Install ${{ env.package }}
54+
run: |
55+
python -m pip install --upgrade pip
56+
python -m pip install pytest pytest-cov
57+
pip install -r requirements.txt
58+
pip install .
59+
- name: Make coverage badge for ${{ env.package }}
60+
run: |
61+
pip install genbadge[coverage]
62+
pytest --cov=$package --cov-report=xml
63+
genbadge coverage -i coverage.xml -o $cov_badge_path
64+
- name: Verify Changed files
65+
uses: tj-actions/verify-changed-files@v12
66+
id: changed_files
67+
with:
68+
files: ${{ env.cov_badge_path }}
69+
- name: Commit files
70+
if: steps.changed_files.outputs.files_changed == 'true'
71+
run: |
72+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
73+
git config --local user.name "github-actions[bot]"
74+
git add $cov_badge_path
75+
git commit -m "Updated coverage.svg"
76+
- name: Push changes
77+
if: steps.changed_files.outputs.files_changed == 'true'
78+
uses: ad-m/github-push-action@master
79+
with:
80+
github_token: ${{ secrets.github_token }}
81+
branch: ${{ github.ref }}

0 commit comments

Comments
 (0)