Skip to content

Commit

Permalink
Merge pull request #48 from tj-actions/feature/add-test-and-update-su…
Browse files Browse the repository at this point in the history
…pported-platforms

Added test and updated supported platforms
  • Loading branch information
repo-ranger[bot] authored Mar 6, 2023
2 parents ae6c1e7 + 7d05806 commit 634a65b
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 15 deletions.
54 changes: 50 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,57 @@ on:

jobs:
test:
runs-on: ubuntu-latest
name: Test coverage-badge-py
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, windows-latest, macos-latest, macos-11, windows-2022]
steps:
- name: Checkout
uses: actions/checkout@v3
# - name: Run coverage-badge-py
# uses: ./
# TODO: Add test.
with:
persist-credentials: false
fetch-depth: 0

- uses: actions/setup-python@v4
with:
python-version: 3.9

- name: Install dependencies
run: |
pip install --upgrade pip setuptools
pip install coverage
- name: Run coverage
working-directory: test_package
run: |
coverage run -m unittest discover
coverage report -m
- name: Run coverage-badge-py
uses: ./
with:
working-directory: test_package

- name: Verify Changed files
uses: tj-actions/verify-changed-files@v13
id: verify-changed-files
with:
files: test_package/coverage.svg

- name: Commit README changes
if: steps.verify-changed-files.outputs.files_changed == 'true'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add ${{ steps.verify-changed-files.outputs.changed_files }}
git commit -m "chore: update coverage badge."
- name: Push changes
if: steps.verify-changed-files.outputs.files_changed == 'true'
uses: ad-m/github-push-action@master
continue-on-error: true
with:
github_token: ${{ secrets.PAT_TOKEN }}
branch: ${{ github.head_ref }}
26 changes: 18 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

[![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)
[![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)
[![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)

## coverage-badge-py

Expand Down Expand Up @@ -54,25 +55,37 @@ Support this project with a :star:
with:
fetch-depth: 0

- uses: actions/setup-python@v4
with:
python-version: 3.11

- name: Install dependencies
...

- name: Run coverage
run: |
coverage run ...
coverage report -m
- name: Coverage Badge
uses: tj-actions/coverage-badge-py@v1.8
uses: tj-actions/coverage-badge-py@v1

- name: Verify Changed files
uses: tj-actions/verify-changed-files@v12
id: changed_files
uses: tj-actions/verify-changed-files@v13
id: verify-changed-files
with:
files: coverage.svg

- name: Commit files
if: steps.changed_files.outputs.files_changed == 'true'
if: steps.verify-changed-files.outputs.files_changed == 'true'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add coverage.svg
git commit -m "Updated coverage.svg"
- name: Push changes
if: steps.changed_files.outputs.files_changed == 'true'
if: steps.verify-changed-files.outputs.files_changed == 'true'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.github_token }}
Expand All @@ -81,9 +94,6 @@ Support this project with a :star:
* Free software: [MIT license](LICENSE)
# TODO
* \[ ] 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)
## Credits
Expand Down
11 changes: 8 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,24 @@ author: tj-actions
inputs:
output:
description: 'Output path to write the coverage badge.'
required: true
required: false
default: 'coverage.svg'
overwrite:
description: 'Overwrite an existing coverage badge.'
required: true
required: false
default: 'true'
working-directory:
description: 'Current working directory'
required: false
default: '.'

runs:
using: 'composite'
steps:
- id: coverage-badge
working-directory: ${{ inputs.working-directory }}
run: |
pip install -U coverage coverage-badge
pip install -U coverage-badge
EXTRA_ARGS=""
if [[ '${{ inputs.overwrite }}' == 'true' ]]; then
Expand Down
21 changes: 21 additions & 0 deletions test_package/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions test_package/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def main():
return 2 + 2
11 changes: 11 additions & 0 deletions test_package/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from setuptools import setup, find_packages


setup(
name="test_package",
version="0.0.1",
author="Tonye Jack",
author_email="[email protected]",
install_requires=[],
packages=find_packages(),
)
6 changes: 6 additions & 0 deletions test_package/test_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import unittest
from main import main

class TestMain(unittest.TestCase):
def test_main(self):
self.assertEqual(main(), 4)

0 comments on commit 634a65b

Please sign in to comment.