Skip to content

Commit 634a65b

Browse files
Merge pull request #48 from tj-actions/feature/add-test-and-update-supported-platforms
Added test and updated supported platforms
2 parents ae6c1e7 + 7d05806 commit 634a65b

File tree

7 files changed

+116
-15
lines changed

7 files changed

+116
-15
lines changed

.github/workflows/test.yml

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,57 @@ on:
1010

1111
jobs:
1212
test:
13-
runs-on: ubuntu-latest
1413
name: Test coverage-badge-py
14+
runs-on: ${{ matrix.platform }}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
platform: [ubuntu-latest, windows-latest, macos-latest, macos-11, windows-2022]
1519
steps:
1620
- name: Checkout
1721
uses: actions/checkout@v3
18-
# - name: Run coverage-badge-py
19-
# uses: ./
20-
# TODO: Add test.
22+
with:
23+
persist-credentials: false
24+
fetch-depth: 0
25+
26+
- uses: actions/setup-python@v4
27+
with:
28+
python-version: 3.9
29+
30+
- name: Install dependencies
31+
run: |
32+
pip install --upgrade pip setuptools
33+
pip install coverage
34+
35+
- name: Run coverage
36+
working-directory: test_package
37+
run: |
38+
coverage run -m unittest discover
39+
coverage report -m
40+
41+
- name: Run coverage-badge-py
42+
uses: ./
43+
with:
44+
working-directory: test_package
45+
46+
- name: Verify Changed files
47+
uses: tj-actions/verify-changed-files@v13
48+
id: verify-changed-files
49+
with:
50+
files: test_package/coverage.svg
51+
52+
- name: Commit README changes
53+
if: steps.verify-changed-files.outputs.files_changed == 'true'
54+
run: |
55+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
56+
git config --local user.name "github-actions[bot]"
57+
git add ${{ steps.verify-changed-files.outputs.changed_files }}
58+
git commit -m "chore: update coverage badge."
59+
60+
- name: Push changes
61+
if: steps.verify-changed-files.outputs.files_changed == 'true'
62+
uses: ad-m/github-push-action@master
63+
continue-on-error: true
64+
with:
65+
github_token: ${{ secrets.PAT_TOKEN }}
66+
branch: ${{ github.head_ref }}

README.md

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
[![Ubuntu](https://img.shields.io/badge/Ubuntu-E95420?logo=ubuntu\&logoColor=white)](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on)
77
[![Mac OS](https://img.shields.io/badge/mac%20os-000000?logo=macos\&logoColor=F0F0F0)](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on)
8+
[![Windows](https://img.shields.io/badge/Windows-0078D6?logo=windows\&logoColor=white)](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on)
89

910
## coverage-badge-py
1011

@@ -54,25 +55,37 @@ Support this project with a :star:
5455
with:
5556
fetch-depth: 0
5657

58+
- uses: actions/setup-python@v4
59+
with:
60+
python-version: 3.11
61+
62+
- name: Install dependencies
63+
...
64+
65+
- name: Run coverage
66+
run: |
67+
coverage run ...
68+
coverage report -m
69+
5770
- name: Coverage Badge
58-
uses: tj-actions/coverage-badge-py@v1.8
71+
uses: tj-actions/coverage-badge-py@v1
5972

6073
- name: Verify Changed files
61-
uses: tj-actions/verify-changed-files@v12
62-
id: changed_files
74+
uses: tj-actions/verify-changed-files@v13
75+
id: verify-changed-files
6376
with:
6477
files: coverage.svg
6578

6679
- name: Commit files
67-
if: steps.changed_files.outputs.files_changed == 'true'
80+
if: steps.verify-changed-files.outputs.files_changed == 'true'
6881
run: |
6982
git config --local user.email "github-actions[bot]@users.noreply.github.com"
7083
git config --local user.name "github-actions[bot]"
7184
git add coverage.svg
7285
git commit -m "Updated coverage.svg"
7386
7487
- name: Push changes
75-
if: steps.changed_files.outputs.files_changed == 'true'
88+
if: steps.verify-changed-files.outputs.files_changed == 'true'
7689
uses: ad-m/github-push-action@master
7790
with:
7891
github_token: ${{ secrets.github_token }}
@@ -81,9 +94,6 @@ Support this project with a :star:
8194
8295
* Free software: [MIT license](LICENSE)
8396
84-
# TODO
85-
86-
* \[ ] Add support for running action on [![Windows](https://img.shields.io/badge/Windows-0078D6?logo=windows\&logoColor=white)](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on)
8797
8898
## Credits
8999

action.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,24 @@ author: tj-actions
44
inputs:
55
output:
66
description: 'Output path to write the coverage badge.'
7-
required: true
7+
required: false
88
default: 'coverage.svg'
99
overwrite:
1010
description: 'Overwrite an existing coverage badge.'
11-
required: true
11+
required: false
1212
default: 'true'
13+
working-directory:
14+
description: 'Current working directory'
15+
required: false
16+
default: '.'
1317

1418
runs:
1519
using: 'composite'
1620
steps:
1721
- id: coverage-badge
22+
working-directory: ${{ inputs.working-directory }}
1823
run: |
19-
pip install -U coverage coverage-badge
24+
pip install -U coverage-badge
2025
EXTRA_ARGS=""
2126
2227
if [[ '${{ inputs.overwrite }}' == 'true' ]]; then

test_package/coverage.svg

Lines changed: 21 additions & 0 deletions
Loading

test_package/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def main():
2+
return 2 + 2

test_package/setup.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from setuptools import setup, find_packages
2+
3+
4+
setup(
5+
name="test_package",
6+
version="0.0.1",
7+
author="Tonye Jack",
8+
author_email="[email protected]",
9+
install_requires=[],
10+
packages=find_packages(),
11+
)

test_package/test_main.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import unittest
2+
from main import main
3+
4+
class TestMain(unittest.TestCase):
5+
def test_main(self):
6+
self.assertEqual(main(), 4)

0 commit comments

Comments
 (0)