Skip to content

Commit

Permalink
Working on coverage badges
Browse files Browse the repository at this point in the history
  • Loading branch information
micahjohnson150 committed Sep 8, 2023
1 parent bec9b6d commit ad7540e
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 21 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/badge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@

name: Study lyte Coverage Badge

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
workflow_dispatch:

jobs:
covergae:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10']
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
sudo apt-get update
python -m pip install --upgrade pip
python -m pip install pytest coverage genbadge[coverage]
python setup.py install
- name: Run coverage
run: |
coverage run --source study_lyte -m pytest
coverage xml
- name: Checkout gh-pages
uses: actions/checkout@v3
with:
ref: gh-pages

- name: Create Badges
shell: bash
run: |
mkdir -p badges
genbadge coverage -i coverage.xml -o badges/coverage.svg
- name: Deploy Badges
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "Update badges [skip ci]"
skip_fetch: true
skip_checkout: true

# Without this, will get Error:
# Can't find 'action.yml', 'action.yaml' or 'Dockerfile' under '/home/runner/work/coverage-badge-action/coverage-badge-action/action.yml'.
# Did you forget to run actions/checkout before running your local action?
- name: Checkout Back
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
25 changes: 4 additions & 21 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,12 @@ name: Study lyte testing

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

jobs:
build:

testing:
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -27,22 +23,9 @@ jobs:
run: |
sudo apt-get update
python -m pip install --upgrade pip
python -m pip install pytest coverage
python -m pip install pytest
python setup.py install
- name: Test with pytest
run: |
pytest -s ./tests/
- name: Run coverage
- name: test
run: |
coverage run --source study_lyte -m pytest
coverage json -o ./coverage/coverage-summary.json
# Add this
- name: Update Coverage Badge
# GitHub actions: default branch variable
# https://stackoverflow.com/questions/64781462/github-actions-default-branch-variable
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
uses: we-cli/coverage-badge-action@main
pytest tests

0 comments on commit ad7540e

Please sign in to comment.