-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ft codeclimate test #17
Changes from all commits
a0ce4f8
f2e6163
4d60fc7
44f4d69
435933b
554ce18
d30650c
8650968
ccb038d
520090e
452c9ce
9caa477
b5b621c
be3bfdc
56577bc
cf720ab
2502c68
3cea4db
4a219b4
f0beace
4ecdbda
7ef9b72
e30e9da
8b79cf7
f1d6ac6
0494df2
1337c97
8b5f414
e96b100
7ad6c2a
8b9a6cb
b839748
d0b8060
bf954a6
2820e43
fa33e7c
ce4d595
c50360f
b13f330
3f9315b
ed40ff5
36d7acc
4327482
6d829ca
b56b114
0f3dca8
8f7a814
3507d36
9d76ea1
1c821e0
e074d98
39c1a12
bd87d2a
8838e66
6660a09
f26bfc6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
version: 2.1 | ||
|
||
|
||
orbs: | ||
node: circleci/[email protected] | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
version: "2" | ||
checks: | ||
argument_count: | ||
enabled: true | ||
file_lines: | ||
enabled: true | ||
method_count: | ||
enabled: true | ||
return_count: | ||
enabled: true | ||
|
||
exclude_paths: | ||
- "node_modules/**" | ||
- "coverage/**" | ||
|
||
engines: | ||
eslint: | ||
enabled: true | ||
config: | ||
extensions: | ||
- .js | ||
- .jsx | ||
|
||
ratings: | ||
paths: | ||
- "**.js" | ||
- "**.jsx" | ||
|
||
test_reporter: | ||
id: "cc-test-reporter" | ||
coverage_file: | ||
- "coverage/lcov.info" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
PORT= | ||
DEV_DATABASE_URL= | ||
TEST_DATABASE_UR= | ||
DATABASE_URL= | ||
JWT_SECRET= | ||
|
||
CODECLIMATE_REPO_TOKEN=b996f145a438f80141cfcc86bb35a2c212a2a24c394abee18da6add05eaaee7e |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
name: Test Coverage | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '16' | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: Run tests | ||
run: npm run test | ||
|
||
- name: Upload coverage to CodeClimate | ||
env: | ||
CODECLIMATE_REPO_TOKEN: ${{ secrets.CODECLIMATE_REPO_TOKEN }} | ||
run: | | ||
npm install -g codeclimate-test-reporter | ||
codeclimate-test-reporter < coverage/lcov.info |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
|
||
[![Test Coverage](https://api.codeclimate.com/v1/badges/b8b4783a32fb76cb4953/test_coverage)](https://codeclimate.com/github/atlp-rwanda/e-commerce-furebo-32-bn/test_coverage) | ||
[![HoundCI](https://img.shields.io/badge/style-yellow?style=flat&logo=houndci&label=HoundCI)](https://houndci.com) | ||
[![CircleCI](https://dl.circleci.com/status-badge/img/gh/atlp-rwanda/e-commerce-furebo-32-bn/tree/main.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/atlp-rwanda/e-commerce-furebo-32-bn/tree/main) | ||
|
||
[![Maintainability](https://api.codeclimate.com/v1/badges/b8b4783a32fb76cb4953/maintainability)](https://codeclimate.com/github/atlp-rwanda/e-commerce-furebo-32-bn/maintainability) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"development": { | ||
"username": "postgres", | ||
"password": "1234", | ||
"database": "data", | ||
"host": "127.0.0.1", | ||
"dialect": "postgres" | ||
}, | ||
"test": { | ||
"username": "root", | ||
"password": null, | ||
"database": "database_test", | ||
"host": "127.0.0.1", | ||
"dialect": "postgres" | ||
}, | ||
"production": { | ||
"username": "root", | ||
"password": null, | ||
"database": "database_production", | ||
"host": "127.0.0.1", | ||
"dialect": "postgres" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use strict'; | ||
|
||
/** @type {import('sequelize-cli').Migration} */ | ||
module.exports = { | ||
async up(queryInterface, Sequelize) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Parsing error: Unexpected token up |
||
await queryInterface.createTable('users', { | ||
id: { | ||
type: Sequelize.INTEGER, | ||
allowNull: false, | ||
autoIncrement: true, | ||
primaryKey: true | ||
}, | ||
username: { | ||
type: Sequelize.STRING, | ||
allowNull: false | ||
}, | ||
email: { | ||
type: Sequelize.STRING, | ||
allowNull: false, | ||
unique: true | ||
}, | ||
}); | ||
}, | ||
|
||
async down(queryInterface, Sequelize) { | ||
await queryInterface.dropTable('users'); | ||
} | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Sequelize, Dialect } from 'sequelize'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Parsing error: 'import' and 'export' may appear only with 'sourceType: module' |
||
import config from './config/config.json'; | ||
|
||
const { username, password, database, host, dialect } = config.development; | ||
|
||
const sequelize = new Sequelize(database, username, password, { | ||
host, | ||
dialect: dialect as Dialect, | ||
}); | ||
|
||
export default sequelize; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { DataTypes, Model } from 'sequelize'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Parsing error: 'import' and 'export' may appear only with 'sourceType: module' |
||
import sequelize from '../../sequelizeConfig'; | ||
|
||
interface UserAttributes { | ||
id: number; | ||
username: string; | ||
email: string; | ||
} | ||
|
||
class User extends Model<UserAttributes> implements UserAttributes { | ||
public id!: number; | ||
public username!: string; | ||
public email!: string; | ||
} | ||
|
||
User.init( | ||
{ | ||
id: { | ||
type: DataTypes.INTEGER, | ||
autoIncrement: true, | ||
primaryKey: true | ||
}, | ||
username: { | ||
type: DataTypes.STRING, | ||
allowNull: false | ||
}, | ||
email: { | ||
type: DataTypes.STRING, | ||
allowNull: false, | ||
unique: true | ||
} | ||
}, | ||
{ | ||
sequelize, | ||
modelName: 'User', | ||
tableName: 'users', | ||
} | ||
); | ||
|
||
export default User; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'require' is not defined no-undef |
||
const path = require('path'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'require' is not defined no-undef |
||
const Sequelize = require('sequelize'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'require' is not defined no-undef |
||
const process = require('process'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'require' is not defined no-undef |
||
const basename = path.basename(__filename); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. '__filename' is not defined no-undef |
||
const env = process.env.NODE_ENV || 'development'; | ||
const config = require(__dirname + '/../config/config.json')[env]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. '__dirname' is not defined no-undef |
||
const db = {}; | ||
|
||
let sequelize; | ||
if (config.use_env_variable) { | ||
sequelize = new Sequelize(process.env[config.use_env_variable], config); | ||
} else { | ||
sequelize = new Sequelize(config.database, config.username, config.password, config); | ||
} | ||
|
||
fs | ||
.readdirSync(__dirname) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. '__dirname' is not defined no-undef |
||
.filter(file => { | ||
return ( | ||
file.indexOf('.') !== 0 && | ||
file !== basename && | ||
file.slice(-3) === '.js' && | ||
file.indexOf('.test.js') === -1 | ||
); | ||
}) | ||
.forEach(file => { | ||
const model = require(path.join(__dirname, file))(sequelize, Sequelize.DataTypes); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. '__dirname' is not defined no-undef |
||
db[model.name] = model; | ||
}); | ||
|
||
Object.keys(db).forEach(modelName => { | ||
if (db[modelName].associate) { | ||
db[modelName].associate(db); | ||
} | ||
}); | ||
|
||
db.sequelize = sequelize; | ||
db.Sequelize = Sequelize; | ||
|
||
module.exports = db; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'module' is not defined no-undef |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsing error: Unexpected token up