Skip to content

Commit

Permalink
Merge pull request #4 from Project-Resilience/actions
Browse files Browse the repository at this point in the history
Add Github Actions
  • Loading branch information
danyoungday authored Jul 23, 2024
2 parents 6efe9ba + 4535733 commit d2f1930
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
max-line-length = 120
31 changes: 31 additions & 0 deletions .github/workflow/sdk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This runs the unit tests for the ELUC use case

name: SDK Workflow

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with PyLint
run: pylint ./src/prsdk
- name: Lint with Flake8
run: flake8 ./src/prsdk
- name: Run unit tests
run: python -m unittest

45 changes: 45 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Note:
# This is a minimal subset of the options available for Pylint.
# To generate an exhaustive configuration file based on current settings and defaults, run the following command
# in the project directory:
#
# pylint --generate-rcfile > ~/.pylintrc

[MASTER]

# Add files or directories to the blacklist. They should be base names, not
# paths.
ignore=

# Directories from top level that should be ignored.
ignore-paths=

# Add files or directories matching the regex patterns to the blacklist. The
# regex matches against base names, not paths.
ignore-patterns=

# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the
# number of processors available to use.
jobs=0

# Set reasonable line length
max-line-length=120

# When enabled, pylint would attempt to guess common misconfiguration and emit
# user-friendly hints instead of false-positive error messages.
suggestion-mode=yes

# Disable the message, report, category or checker with the given id(s). You
# can either give multiple identifiers separated by comma (,) or put this
# option multiple times (only on the command line, not in the configuration
# file where it should appear only once).You can also use "--disable=all" to
# disable everything first and then reenable specific checks. For example, if
# you want to run only the similarities checker, you can use "--disable=all
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"

disable=

# Default set of "always good" names
good-names=_
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
flake8==7.1.0
pylint==3.2.6
10 changes: 9 additions & 1 deletion src/prsdk/dummy.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
"""
A dummy module to test the package.
"""


def compute_percent_change(x: int) -> float:
return x / 100
"""
A function that divides an integer by 100 and returns a float.
"""
return x / 100
File renamed without changes.
20 changes: 20 additions & 0 deletions tests/test_dummy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""
Dummy test for the dummy module.
"""
import unittest

from src.prsdk.dummy import compute_percent_change


class TestDummy(unittest.TestCase):
"""
Tests for the dummy module.
"""
def test_pct_change(self):
"""
Tests the compute_percent_change function.
It should return the input divided by 100.
"""
self.assertEqual(compute_percent_change(100), 1.0)
self.assertEqual(compute_percent_change(50), 0.5)
self.assertEqual(compute_percent_change(0), 0.0)

0 comments on commit d2f1930

Please sign in to comment.