Skip to content

Commit

Permalink
group25 workflows (CSC510-Group-25#65)
Browse files Browse the repository at this point in the history
* Added simple log in form, added material ui

* Added Dashboard and stored user email in the session

* Added logic to restrict based feature tagging on log in

* added pylint workflow w/artifacts

run: pylint --fail-under=1 $(find . -name "*.py" | xargs)
note: set the failure threshold as indicated above

actions/starter-workflows#636 (comment)

* Added CodeQL & Pylint badges, edits

* Added CodeQL badge
* Added Pylint badge
* Minor edits: updated git clone steps

* Lowered pylint failure theshold

* Update and rename build.yml to coveralls.yml

* Added test files to pylint.yml

* Updated py files to improve pylint score

* Fixed error in coveralls.yml

* Removed individual tests in pylint.yml

* Added pylint labels

* Added test workflow

* Update and rename nodejsTest.yml to nodejs.yml

* Update nodejs.yml

* Update nodejs.yml

* Added workflow build badge to README

* Added yet another workflow

 All for the sake of a test badge.

* Added test badge

* Rearranged README badges

Co-authored-by: Emily Tracey <etracey@ncsu.edu>
  • Loading branch information
snapcat and Emily Tracey committed Oct 25, 2021
1 parent 6e4e234 commit 79228c9
Show file tree
Hide file tree
Showing 21 changed files with 356 additions and 45 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/build.yml → .github/workflows/coveralls.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: Coveralls
jobs:

build:
name: Build

runs-on: ubuntu-latest

strategy:
Expand All @@ -23,12 +23,15 @@ jobs:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2

- name: script
- name: install npm and coveralls
run: |
npm install
npm install coveralls
npm test -- --coverage
- name: test with coverage
run: npm test -- --coverage

- name: Coveralls
uses: coverallsapp/github-action@v1.1.2
with:
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Build
on: ["push", "pull_request"]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm install
- run: npm run build --if-present
- name: test
run: npm test
27 changes: 27 additions & 0 deletions .github/workflows/nodejs_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Tests
on: ["push", "pull_request"]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm install
- run: npm run build --if-present
- name: test
run: npm test
56 changes: 56 additions & 0 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Pylint

on: ["push", "pull_request"]

jobs:
build:

name: pylint

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint
if [ -f ./backend/requirements.txt ]; then pip install -r ./backend/requirements.txt; fi
- name: Analyze files with pylint
run: |
echo "::group::Skipped files"
echo "Skipping files" | tee -a pylint.txt
echo "backend/app/controllers/__init__.py" | tee -a pylint.txt
echo "backend/logger/__init__.py" | tee -a pylint.txt
echo "backend/linter.py" | tee -a pylint.txt
echo "See each individual file for pylint comments." | tee -a pylint.txt
echo "Be sure to update this workflow if any files are skipped/unskipped." | tee -a pylint.txt
echo "::endgroup::"
pylint --fail-under=10 `find -regextype egrep -regex '(.*.py)$'` |
tee -a pylint.txt
- name: Upload pylint report as artifact
uses: actions/upload-artifact@v2
with:
name: pylint report
path: pylint.txt

- name: pylint workflow status
run: |
echo "::group::Skipped files"
echo "backend/app/controllers/__init__.py"
echo "backend/logger/__init__.py"
echo "backend/linter.py"
echo "::endgroup::"
echo "See each individual file for pylint comments."
echo "Be sure to update this workflow if any files are skipped/unskipped."
pylint --fail-under=5 $(find . -name "*.py" | xargs)
# run: pylint $(find . -name "*.py" | xargs)
# note: set the failure threshold as indicated above
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
<img width="657" alt="Feature Hunt" src="https://user-images.githubusercontent.com/11090612/135201949-a1f1de9d-f80a-4adf-a7ac-886c77c4c226.png">
</p>

[![Build Status](https://app.travis-ci.com/CSC510-Group-25/feature-hunt.svg?branch=main)](https://app.travis-ci.com/CSC510-Group-25/feature-hunt)
[![DOI](https://zenodo.org/badge/413987683.svg)](https://zenodo.org/badge/latestdoi/413987683)
[![made-with-javascript](https://img.shields.io/badge/Made%20with-JavaScript-blue)](https://www.javascript.com)
[![GitHub license](https://img.shields.io/github/license/shahrk/feature-hunt)](https://github.com/shahrk/feature-hunt/blob/main/LICENSE)
[![GitHub issues](https://img.shields.io/github/issues/CSC510-Group-25/feature-hunt)](https://github.com/CSC510-Group-25/feature-hunt/issues)
[![made-with-javascript](https://img.shields.io/badge/Made%20with-JavaScript-blue)](https://www.javascript.com)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
[![Docker](https://img.shields.io/badge/Containerized-Docker-blue)](https://docs.docker.com/compose/)
[![GitHub issues](https://img.shields.io/github/issues/CSC510-Group-25/feature-hunt)](https://github.com/CSC510-Group-25/feature-hunt/issues)
[![Build Status](https://app.travis-ci.com/CSC510-Group-25/feature-hunt.svg?branch=main)](https://app.travis-ci.com/CSC510-Group-25/feature-hunt)
[![Build](https://github.com/CSC510-Group-25/feature-hunt/actions/workflows/nodejs.yml/badge.svg)](https://github.com/CSC510-Group-25/feature-hunt/actions/workflows/nodejs.yml)
[![Tests](https://github.com/CSC510-Group-25/feature-hunt/actions/workflows/nodejs_tests.yml/badge.svg)](https://github.com/CSC510-Group-25/feature-hunt/actions/workflows/nodejs_tests.yml)
[![Coverage Status](https://coveralls.io/repos/github/CSC510-Group-25/feature-hunt/badge.svg?branch=main)](https://coveralls.io/github/CSC510-Group-25/feature-hunt?branch=main)
[![CodeQL](https://github.com/CSC510-Group-25/feature-hunt/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/CSC510-Group-25/feature-hunt/actions/workflows/codeql-analysis.yml)
[![Pylint](https://github.com/CSC510-Group-25/feature-hunt/actions/workflows/pylint.yml/badge.svg)](https://github.com/CSC510-Group-25/feature-hunt/actions/workflows/pylint.yml)

## INTRODUCTION ⚡️

Expand Down Expand Up @@ -86,7 +90,7 @@ https://docs.docker.com/get-docker
```
#### 2. Git clone the Repository using
```
git clone https://github.com/shahrk/feature-hunt.git
git clone https://github.com/CSC510-Group-25/feature-hunt.git
```

#### 3. Run the following Commands
Expand All @@ -104,7 +108,7 @@ This will run two docker containers. The frontend will run on port 3000 and the

#### 1. Git clone the Repository using
```
git clone https://github.com/shahrk/feature-hunt.git
git clone https://github.com/CSC510-Group-25/feature-hunt.git
```
#### 2. Run the following Commands
```
Expand Down
9 changes: 5 additions & 4 deletions backend/app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
You should have received a copy of the XYZ license with
this file. If not, please write to: featurehuntteam@gmail.com
"""
# pylint: disable=wrong-import-position,pointless-string-statement

''' flask app with mongo '''
import os
Expand All @@ -13,14 +14,14 @@
from flask import Flask
from flask_pymongo import PyMongo
from flask_cors import CORS
from app.controllers import *

def create_app():
return Flask(__name__)

''' docstr todo '''
return Flask(__name__)

# create the flask object
app = create_app()
CORS(app)
app.config['MONGO_URI'] = os.environ.get('DB')
mongo = PyMongo(app)

from app.controllers import *
3 changes: 2 additions & 1 deletion backend/app/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pylint: skip-file
''' all controllers for various collections of database '''
import os
import glob
__all__ = [os.path.basename(f)[:-3]
for f in glob.glob(os.path.dirname(__file__) + "/*.py")]
for f in glob.glob(os.path.dirname(__file__) + "/*.py")]
30 changes: 17 additions & 13 deletions backend/app/controllers/products.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
You should have received a copy of the XYZ license with
this file. If not, please write to: featurehuntteam@gmail.com
"""

# pylint: disable=line-too-long

import os
from sys import stderr
from flask import request, jsonify
Expand All @@ -18,18 +21,17 @@
# print('ROOT_PATH', ROOT_PATH)
LOG = logger.get_root_logger(__name__, filename=os.path.join(ROOT_PATH, 'output.log'))

@app.route('/products', methods=['GET', 'POST', 'DELETE', 'PATCH'])

#################################################################################
## Function: products
## Description: Get/ Add/ Update/ Delete the products from the database
## Function: products
## Description: Get/ Add/ Update/ Delete the products from the database
## Inputs:
## - NA
## Outputs:
## - NA
#################################################################################

@app.route('/products', methods=['GET', 'POST', 'DELETE', 'PATCH'])
def products():
''' docstr todo '''
if request.method == 'GET':
query = request.args
#db = mongo.feature-hunt
Expand All @@ -46,12 +48,12 @@ def products():
mimetype='application/json')
result = mongo.db.products.insert_one(data).inserted_id
return jsonify({'ok': True, 'message': 'Product added successfully'}), 200

if request.method == 'DELETE':
if data is None or data == {}:
return Response(response=json.dumps({"Error": "Please provide all necessary input"}),
status=400,
mimetype='application/json')
mimetype='application/json')

db_response = mongo.db.products.delete_one({'id' : data[id]})
if db_response.deleted_count == 1:
Expand All @@ -70,31 +72,33 @@ def products():


#################################################################################
## Function: get_feature
## Function: get_feature
## Description: Get the list of all features for given product name
## Inputs:
## - productName: Name of the product
## Outputs:
## - results: List of features that are available in that product
#################################################################################
@app.route('/<productname>', methods=['GET', 'POST'])
@app.route('/<productname>', methods=['GET', 'POST'])
def get_feature(productname):
''' docstr todo '''
if request.method == 'GET':
data = mongo.db.products.find({"name":productname},{"features":1})
return dumps(data)



#################################################################################
## Function: features
## Function: features
## Description: You can add/get features of a product
## Inputs:
## - productName: Name of the product
## Outputs:
## - results: Add features to that product or return feature list
#################################################################################
@app.route('/<productname>/features', methods=['GET', 'POST'])
def features(productname):
@app.route('/<productname>/features', methods=['GET', 'POST'])
def features(productname):
''' docstr todo '''
if request.method == 'POST':
data = request.json
data['_id'] = ObjectId()
Expand All @@ -104,7 +108,7 @@ def features(productname):
status=400,
mimetype='application/json')
result = mongo.db.products.find_one_and_update({"name": productname}, {"$push": {"features": data}})

elif request.method == 'GET':
result = mongo.db.products.find({"name":productname},{"features":1})
return dumps(result)
4 changes: 1 addition & 3 deletions backend/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
import sys
from flask import jsonify, make_response, send_from_directory
import logger

from app import app

ROOT_PATH = os.path.dirname(os.path.realpath(__file__))
os.environ.update({'ROOT_PATH': ROOT_PATH})
sys.path.append(os.path.join(ROOT_PATH, 'modules'))

from app import app

# Create a logger object to log the info and debug
LOG = logger.get_root_logger(os.environ.get(
'ROOT_LOGGER', 'root'), filename=os.path.join(ROOT_PATH, 'output.log'))
Expand Down
4 changes: 3 additions & 1 deletion backend/linter.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pylint: skip-file
''' docstr todo '''
from pylint import epylint as lint
(pylint_stdout, pylint_stderr) = lint.py_run('index.py', return_std=True)
print(pylint_stdout.getvalue())
print(pylint_stdout.getvalue())
4 changes: 3 additions & 1 deletion backend/logger/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from .logger import *
#pylint: skip-file
''' docstr todo '''
from .logger import *
6 changes: 3 additions & 3 deletions backend/logger/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import os
import logging
#################################################################################
## Function: get_root_logger
## Description: Get the logger object
## Function: get_root_logger
## Description: Get the logger object
## Inputs:
## - logger_name: Name of the logger
## - file name : the file which is used for logging
Expand Down Expand Up @@ -31,6 +31,6 @@ def get_root_logger(logger_name, filename=None):

return logger


def get_child_logger(root_logger, name):
''' docstr todo '''
return logging.getLogger('.'.join([root_logger, name]))
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@emotion/react": "^11.5.0",
"@emotion/styled": "^11.3.0",
"@fortawesome/fontawesome-svg-core": "^1.2.36",
"@fortawesome/free-solid-svg-icons": "^5.15.4",
"@fortawesome/react-fontawesome": "^0.1.15",
"@mui/material": "^5.0.4",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"prettier": "^2.4.1",
"react": "^17.0.2",
"react-client-session": "^0.0.7",
"react-dom": "^17.0.2",
"react-router-dom": "^5.2.0",
"react-scripts": "^4.0.3",
Expand Down

0 comments on commit 79228c9

Please sign in to comment.