Skip to content

Instantly share code, notes, and snippets.

oryks-code-coverage

This action shows code coverage using pycov.

Inputs

codedirectory

Required The directory containing the source code. Default ".".

update-pip:
@pip install --upgrade pip
install: update-pip requirements.txt
@pip install -r requirements.txt
install-dev: requirements-dev.txt
@pip install -r requirements-dev.txt
run-locally:
# -*- coding: utf-8 -*-
"""This module creates three functions to be tested."""
def add(x: int, y: int) -> int:
"""Add two numbers together.
Args:
x (int): first number to add
y (int): second number to add
# -*- coding: utf-8 -*-
"""This module tests the three functions in the src package."""
from src.math import add, multiply, subtract
def test_add():
"""Test that add() function correctly sums two integers.
GIVEN the add() function
WHEN inputs are 2 and 3
# -*- coding: utf-8 -*-
"""This module creates and executes the GitHub Action Code that shows code coverage."""
import json
import os
import subprocess
from os.path import exists
import xmltodict
# action.yml
name: "Pytest Coverage Example"
description: "Use Pytest to show test coverage."
author: "Lyle Okoth"
inputs:
codedirectory:
description: "The directory containing the source code."
default: "The project root i.e '.'"
testdirectory:
description: "The directory containing the tests."
# action.yml
name: "GitHub Action Template"
description: "A template for creating GitHub Actions."
author: "Lyle Okoth"
inputs:
myinput:
description: "The users name."
default: "world"
outputs:
myoutput:
on: [push]
jobs:
Build:
runs-on: ubuntu-latest
name: A job to test the oryks code coverage action
steps:
on: [push]
jobs:
Build:
runs-on: ubuntu-latest
name: A job to test the github action template
steps:
- name: oryks code coverage action
# action.yml
name: "GitHub Action Template"
description: "A template for creating GitHub Actions."
author: "Lyle Okoth"
inputs:
myinput:
description: "The users name."
default: "world"
outputs:
myoutput: