Skip to content
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

Closed
wants to merge 56 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
a0ce4f8
Integrating CircleCi With ReadMe
GabrielDushime May 20, 2024
f2e6163
Adding Badge
GabrielDushime May 20, 2024
4d60fc7
Resolving build issue
GabrielDushime May 20, 2024
44f4d69
Resolving build issues
GabrielDushime May 20, 2024
435933b
Integrating circleci
GabrielDushime May 20, 2024
554ce18
Adding Jest as tests
GabrielDushime May 20, 2024
d30650c
Adding Jest as tests
GabrielDushime May 20, 2024
8650968
Resolving conflicts
GabrielDushime May 20, 2024
ccb038d
Resolving conflict
GabrielDushime May 20, 2024
520090e
Adding Test Coverage
GabrielDushime May 21, 2024
452c9ce
Add CODECLIMATE_REPO_TOKEN to .env for CodeClimate integration
GabrielDushime May 21, 2024
9caa477
Remove CODECLIMATE_REPO_TOKEN to .env for CodeClimate integration
GabrielDushime May 21, 2024
b5b621c
Delete .env
GabrielDushime May 21, 2024
be3bfdc
Adding Test Coverage
GabrielDushime May 21, 2024
56577bc
Delete .github/workflows/test.yml
GabrielDushime May 21, 2024
cf720ab
Delete .codeclimate.yml
GabrielDushime May 21, 2024
2502c68
Delete test-setup.js
GabrielDushime May 21, 2024
3cea4db
updating Readme
GabrielDushime May 21, 2024
4a219b4
Merge branch 'ft-Codeclimate-test' of https://github.com/atlp-rwanda/…
GabrielDushime May 21, 2024
f0beace
Adding Test Coverage
GabrielDushime May 21, 2024
4ecdbda
Adding Test Coverages
GabrielDushime May 21, 2024
7ef9b72
Install axios and update CircleCI config
GabrielDushime May 21, 2024
e30e9da
Resolving Conflicts
GabrielDushime May 21, 2024
8b79cf7
Resolving conflicts
GabrielDushime May 21, 2024
f1d6ac6
configuring pg and sequelize
mutsinziisaac May 13, 2024
0494df2
moving model directory form root to src
mutsinziisaac May 13, 2024
1337c97
Configured Docker Compose to run two services: an Express server and …
mugishaj092 May 15, 2024
8b5f414
Pull request tempate
mugishaj092 May 16, 2024
e96b100
add test and coverage badge
jamesndekezi May 20, 2024
7ad6c2a
add test and coverage badge
jamesndekezi May 20, 2024
8b9a6cb
Adding Test Coverage
GabrielDushime May 21, 2024
b839748
Add CODECLIMATE_REPO_TOKEN to .env for CodeClimate integration
GabrielDushime May 21, 2024
d0b8060
Adding Test Coverage
GabrielDushime May 21, 2024
bf954a6
Delete .github/workflows/test.yml
GabrielDushime May 21, 2024
2820e43
Delete .codeclimate.yml
GabrielDushime May 21, 2024
fa33e7c
Delete test-setup.js
GabrielDushime May 21, 2024
ce4d595
Adding Test Coverage
GabrielDushime May 21, 2024
c50360f
Adding Test Coverages
GabrielDushime May 21, 2024
b13f330
Install axios and update CircleCI config
GabrielDushime May 21, 2024
3f9315b
swagger jsodc setup merge conflicts fixed
kennyg37 May 20, 2024
ed40ff5
Resolved merge conflicts in README.md and package-lock.json
GabrielDushime May 21, 2024
36d7acc
Resolved merge
GabrielDushime May 22, 2024
4327482
Resolved
GabrielDushime May 22, 2024
6d829ca
Resolveds
GabrielDushime May 22, 2024
b56b114
Resolve
GabrielDushime May 22, 2024
0f3dca8
Resolves
GabrielDushime May 22, 2024
8f7a814
Adding scripts npm run test:coverage
GabrielDushime May 22, 2024
3507d36
Adding scripts npm run test:coverages
GabrielDushime May 22, 2024
9d76ea1
Adding scripts npm run test:coverage
GabrielDushime May 22, 2024
1c821e0
Resolving NPM Install
GabrielDushime May 22, 2024
e074d98
Removing deploy from circleci
GabrielDushime May 22, 2024
39c1a12
Resolving Conflicts
GabrielDushime May 22, 2024
bd87d2a
Resolving Conflict
GabrielDushime May 22, 2024
8838e66
Resolving error
GabrielDushime May 22, 2024
6660a09
Resolving errors
GabrielDushime May 22, 2024
f26bfc6
Resolving conflicts
GabrielDushime May 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
version: 2.1


orbs:
node: circleci/[email protected]

Expand Down
33 changes: 33 additions & 0 deletions .codeclimate.yml
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"
7 changes: 7 additions & 0 deletions .env
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
30 changes: 30 additions & 0 deletions .github/workflows/test.yml
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
6 changes: 4 additions & 2 deletions README.md
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)

23 changes: 23 additions & 0 deletions config/config.json
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"
}
}
3 changes: 3 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ module.exports = {
restoreMocks: true,
clearMocks: true,
testTimeout:30000,
coverageReporters: ['html', 'text', 'lcov'],
coverageDirectory: 'coverage',
testPathIgnorePatterns: ['/node_modules/']
};
28 changes: 28 additions & 0 deletions migrations/20240512215421-create-users.js
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) {
Copy link

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

Copy link

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

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');
}
};
60 changes: 57 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"dev": "nodemon server.ts",
"start": "ts-node server.ts",
"test": "jest --detectOpenHandles --coverage",
"test:coverage": "jest --coverage",
"build": "tsc",
"migrate": "sequelize db:migrate"
},
Expand All @@ -48,5 +49,9 @@
"supertest": "^7.0.0",
"ts-jest": "^29.1.2",
"typescript": "^5.4.5"
},
"engines": {
"node": ">=12"
}
}

}
11 changes: 11 additions & 0 deletions sequelizeConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Sequelize, Dialect } from 'sequelize';
Copy link

Choose a reason for hiding this comment

The 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;
40 changes: 40 additions & 0 deletions src/models/User.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { DataTypes, Model } from 'sequelize';
Copy link

Choose a reason for hiding this comment

The 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;
43 changes: 43 additions & 0 deletions src/models/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
'use strict';

const fs = require('fs');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'require' is not defined no-undef

const path = require('path');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'require' is not defined no-undef

const Sequelize = require('sequelize');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'require' is not defined no-undef

const process = require('process');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'require' is not defined no-undef

const basename = path.basename(__filename);
Copy link

Choose a reason for hiding this comment

The 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];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'__dirname' is not defined no-undef
'require' 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)
Copy link

Choose a reason for hiding this comment

The 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);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'__dirname' is not defined no-undef
'require' 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;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'module' is not defined no-undef

Loading
Loading