Skip to content

Commit

Permalink
Merge pull request #2 from philips-software/funcDefExtractorEnhanced
Browse files Browse the repository at this point in the history
Func def extractor enhanced
  • Loading branch information
SannihithReddy610 committed Aug 3, 2020
2 parents 15b22c6 + 4899241 commit 0f7478a
Show file tree
Hide file tree
Showing 60 changed files with 2,431 additions and 659 deletions.
97 changes: 58 additions & 39 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -1,60 +1,79 @@
# Koninklijke Philips N.V., 2019 - 2020. All rights reserved.
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python application

name: Build Python application and Publish Python 🐍 distributions 📦 to PyPI and TestPyPI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
create:
branches: [ master ]
env:
NODE_VERSION: '10.x' # set this to the node version to use
NODE_VERSION: '10.13.0' # set this to the node version to use
jobs:
build:
name: Conduct "Static analysis, Test & Coverage, Spell check, Mutation testing " for 🐍 code
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
node-version: ${{ env.NODE_VERSION }}
- name: Upgrade pip
run: |
python3 -m pip install --upgrade pip
- name: Install dependencies Conduct Static analysis Test Coverage Mutation
run: |
python3 build_scripts/dependencies_static_analysis_test_cov.py
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
- uses: actions/upload-artifact@v2
with:
name: my-artifact_static_analysis
path: |
htmlcov
CC.xml
jscpd-report.json
mutation.txt
runs-on: ubuntu-latest

publish:
name: Build , Smoke test , Performance test, and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
needs: build
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.7
- name: Fetch all history for all tags and branches
run: git fetch --prune --unshallow
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.7
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
python-version: 3.8
- name: Install the dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: npm install
python3 build_scripts/install_dependencies.py
- name: Build a binary wheel and a source tarball
run: |
sudo npm install
sudo npm install -g jscpd@3.2.1
- name: ctags install
python3 setup.py sdist bdist_wheel
- name: Install newly created wheel
run: |
sudo apt-get install ctags
export PATH="$PATH:/usr/bin/ctags"
ctags --version
- name: Static Analysis
python3 build_scripts/install_package.py
- name: Conduct the sanity test on new wheel created
run: |
pylint functiondefextractor/ test/
jscpd --min-tokens 20 --reporters "json" --mode "strict" --format "python" -o . .
python3 test_resource/jscpd_parser.py --j 10 #Allowed duplication is 10% with 20 token size
python3 build_scripts/sanity_test.py
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.test_pypi_password }}
repository_url: https://test.pypi.org/legacy/
- name: Publish distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.pypi_password }}

- name: Cyclomatic complexity
run: |
python3 -m lizard functiondefextractor -X> CC.xml
python3 test_resource/cyclo_gate.py --c 7 #Allowed cyclomatic complexity is less than 7
- name: Dead Code
run: |
python3 -m vulture functiondefextractor
- name: Tests & Coverage
run: |
pytest test --cov-config=.coveragerc --cov=functiondefextractor
coverage report --fail-under=90 #Coverage should be above 90%
codecov
- name: Mutation Tests
run: |
mutmut run > mutmut.log || true # Checking mutation on main file as the travis max execution time is overshooting
mutmut junitxml --suspicious-policy=ignore --untested-policy=ignore > mutmut.xml
python3 test_resource/mutmut_parse.py --m 20 #Mutation (failure+disables+error) allowed 20% of total mutants
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
build/
dist/
functiondefextractor.egg-info/
__pycache__
functiondefextractor/extractor.log
functiondefextractor\extractor.log
.eggs/"version.txt"
.eggs/
2 changes: 0 additions & 2 deletions .idea/.gitignore

This file was deleted.

19 changes: 0 additions & 19 deletions .idea/TestCaseExtractor.iml

This file was deleted.

9 changes: 0 additions & 9 deletions .idea/dictionaries/320074769.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/inspectionProfiles/profiles_settings.xml

This file was deleted.

4 changes: 0 additions & 4 deletions .idea/misc.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

16 changes: 8 additions & 8 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,12 @@ disable=print-statement,
deprecated-sys-function,
exception-escape,
comprehension-escape,
W0106,
R1710,
R0903,
R1705,
R0123,
E0401
W0106, # Expression-not-assigned: As statement contains append function in single line for loop, it is not possible to assign to a variable
R1710, # Inconsistent-return-statements: Require to return from function if condition is satisfied.
E0401, # Import-error: Throws error even after successful import.
E0110, # Abstract-class-instantiated: states 'ExcelWriter' is a abstract class



# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down Expand Up @@ -367,7 +367,7 @@ ignore-docstrings=yes
ignore-imports=no

# Minimum lines number of a similarity.
min-similarity-lines=4
min-similarity-lines=6


[SPELLING]
Expand Down Expand Up @@ -532,7 +532,7 @@ max-returns=6
max-statements=50

# Minimum number of public methods for a class (see R0903).
min-public-methods=1
min-public-methods=0


[IMPORTS]
Expand Down
26 changes: 26 additions & 0 deletions .pyspelling.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
matrix:

- name: py
sources:
- "functiondefextractor/*.py"
- "test/*.py"
aspell:
lang: en
dictionary:
wordlists:
- spell_check/spell_ignore_py.txt
pipeline:
- pyspelling.filters.python:
comments: false

- name: markdown
pipeline:
- pyspelling.filters.text
sources:
- '**/*.md'
aspell:
lang: en
dictionary:
wordlists:
- spell_check/spell_ignore_md.txt
default_encoding: utf-8
35 changes: 0 additions & 35 deletions .travis.yml

This file was deleted.

73 changes: 31 additions & 42 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,65 +2,54 @@

Requirements are added in requirement.txt file

python & packages
----------------
Python 3.8

`Python 3.7.3 - 64 bit`
python: install python for the respective OS at
"https://www.python.org/downloads/" Make sure to update the
path variable to point to the python installation folder.

python:
install python for the respective OS at `https://www.python.org/downloads/` Make sure to update the path variable to point to the python installation folder.
pip: (only if pip is not present by default) get get-pip.py
from below link to your folder "https://bootstrap.pypa.io/get-pip.py"
Open a command prompt and navigate to the folder containing get-pip.py.

pip:
get `get-pip.py` from below link to your folder `https://bootstrap.pypa.io/get-pip.py` Open a command prompt and navigate to the folder containing `get-pip.py`. Run the following command:
Run the following command:

pandas:
`python -m pip install pandas`
functiondefextractor:

pylint:
`python -m pip install -U pylint`
pip install functiondefextractor

mutmut:
`python -m pip install mutmut`
## Other tools

pytest:
`python -m pip install pytest`
### Ctags: "https://en.wikipedia.org/wiki/Ctags"

unittest:
`python -m pip install unittest`
- Windows:

codecov:
`python -m pip install codecov`
1.Download Ctags from "http://ctags.sourceforge.net/"

pytest-cov:
`python -m pip install pytest-cov`
2.Select the right package(based on OS & architecture) and

Other tools
-----------
Ctags: `https://en.wikipedia.org/wiki/Ctags`
***********************
extract the zip file to a folder

Windows:
1. Download Ctags from `https://sourceforge.net/projects/ctags/files/ctags/5.8/ctags58.zip/download?use_mirror
=excellmedia`
3.Update the system 'path' environment variable with the path to ctags executable

or

`http://ctags.sourceforge.net/`
2. select the right package(based on the Operating system and architecture) and extract the zip file to a folder
3. Update the system 'path' environment variable with the path to ctags executable

Linux:
- Linux:

`apt-get install ctags`

OS X:
- OS X:

`brew install ctags`
grep
***********************
1. Download grep `"binaries and Dependencies"` from `http://gnuwin32.sourceforge.net/packages/grep.htm`
2. extract the content to a folder
3. Copy and paste contents from `\bin` folder of Dependencies to `\bin` folder of Binaries
4. Update the system `'path'` environment variable with the path to "grep" executable

### grep

1.Download grep `"binaries and Dependencies"`

from `http://gnuwin32.sourceforge.net/packages/grep.htm`

2.Extract the content to a folder

3.Copy and paste contents from `\bin` folder of Dependencies

to `\bin` folder of Binaries

4.Update the system `'path'` environment variable with the path to "grep" executable

0 comments on commit 0f7478a

Please sign in to comment.