Skip to content

Commit

Permalink
Merge pull request #12 from xf2809/ci_cd_added
Browse files Browse the repository at this point in the history
Ci cd added
  • Loading branch information
manzil-infinity180 authored Aug 4, 2024
2 parents 6fe2e96 + 20f65dd commit a3f6b0d
Show file tree
Hide file tree
Showing 23 changed files with 1,213 additions and 407 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/.yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
extends: default

rules:
line-length: disable
truthy: disable
document-start: disable

ignore: |
site/node_modules/*
site/vendor/*
38 changes: 36 additions & 2 deletions .github/workflows/xf_ci.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
name: Jest Testing
on: push
on:
push:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
jest:
name: 'Jest testing'
Expand All @@ -10,16 +16,44 @@ jobs:
permissions: write-all
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.x'
- name: Install Dependencies
run: npm install
- name: 'start testing'
run: npm run test
- name: Run eslint
run: npm run eslint
env:
DOTENV_KEY: ${{ secrets.DOTENV_KEY }}
- name: Jest code coverage results
uses: actions/upload-artifact@v4
with:
name: code-coverage-report
path: coverage/Icon-report
path: ./coverage/Icon-report

js-lint:
runs-on: ubuntu-22.04
defaults:
run:
working-directory: ./backend
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.x'
- run: npm install
- name: Run Eslint
- run: npm run eslint

yaml-lint:
name: yaml-lint
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: install yamllint
run: sudo apt-get install -y yamllint
- name: Run yamllint
run: yamllint .

4 changes: 1 addition & 3 deletions backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,4 @@ yarn-error.log*
.env*
.flaskenv*
!.env.project
!.env.vault
./coverage
/coverage
!.env.vault
58 changes: 29 additions & 29 deletions backend/__tests__/post/post.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ describe('user testing', () => {
test('Update a Post', async () => {
const req = httpMocks.createRequest();
const res = httpMocks.createResponse();
const data = {
"type": "internship-remote",
}
// const data = {
// "type": "internship-remote",
// }
const mockValue = {
status: "Success",
statusCode: 200,
Expand All @@ -109,9 +109,9 @@ describe('user testing', () => {
expect(response.statusCode).toEqual(200);
expect(response.status).toBe("Success");
expect(res.statusCode).toEqual(200);
const changeStatus= {
"status":"selected"
}
// const changeStatus= {
// "status":"selected"
// }
const changeMockValue = {
status: "Success",
statusCode: 200,
Expand All @@ -129,29 +129,29 @@ describe('user testing', () => {
test('deletePost',async () => {
const req = httpMocks.createRequest();
const res = httpMocks.createResponse();
const data = {
"_id": '660e3a0cfde07df5ddbcba2f',
"pid": "660d6263bbd0df8300fbe4ed",
"type": "internship-onsite",
"companyId": "a9dec7c3-a10e-4963-976a-1bb39d8de7c2",
"salary": 4500,
"duration": 3,
"start": {
"$date": "2024-05-17T00:00:00.000Z"
},
"deadline": {
"$date": "2024-04-20T00:00:00.000Z"
},
"companyName": "xf",
"description": "Exp: 1 to 3 years \n\nSal: As per Industry Standard\n\nQualification: B.E/B.Tech/M.E/M.Tech/BCA/MCA/B.Sc/M.Sc",
"status": "selected",
"userId": {
"$oid": "660e37acfde07df5ddbcba19"
},
"logo": "https://internshala.com/static/images/company/logo.svg",
"__v": 0,
"name": "Java Developer"
}
// const data = {
// "_id": '660e3a0cfde07df5ddbcba2f',
// "pid": "660d6263bbd0df8300fbe4ed",
// "type": "internship-onsite",
// "companyId": "a9dec7c3-a10e-4963-976a-1bb39d8de7c2",
// "salary": 4500,
// "duration": 3,
// "start": {
// "$date": "2024-05-17T00:00:00.000Z"
// },
// "deadline": {
// "$date": "2024-04-20T00:00:00.000Z"
// },
// "companyName": "xf",
// "description": "Exp: 1 to 3 years \n\nSal: As per Industry Standard\n\nQualification: B.E/B.Tech/M.E/M.Tech/BCA/MCA/B.Sc/M.Sc",
// "status": "selected",
// "userId": {
// "$oid": "660e37acfde07df5ddbcba19"
// },
// "logo": "https://internshala.com/static/images/company/logo.svg",
// "__v": 0,
// "name": "Java Developer"
// }
const mockValue = {
status: "Success",
statusCode:200,
Expand Down
2 changes: 1 addition & 1 deletion backend/__tests__/users/user.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ describe('user testing', () => {
return Mockresponse;
});
mockController.mockReset();
const response = userController.verify(req,res);
// const response = userController.verify(req,res);
expect(mockController).toHaveBeenCalledTimes(1);
expect(res.statusCode).toEqual(200);
});
Expand Down
1 change: 0 additions & 1 deletion backend/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const jobDetailRouter = require("./router/jobDetailRouter");
const adminRouter = require("./router/adminRouter");
const adminPostRouter = require("./router/adminPostRouter");
const cookieParser = require('cookie-parser');
const session = require("express-session");
const cors = require('cors');
const cloudinary = require("cloudinary").v2;
app.use(cookieParser());
Expand Down
27 changes: 13 additions & 14 deletions backend/controller/adminController.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const Profile = require("../model/profileModel");
const jwt = require('jsonwebtoken');
const multer = require("multer");
const sendEmail = require("./../utils/mailing.js");
Expand All @@ -13,7 +12,7 @@ const User = require("../model/userModel.js");
let otp ;
let userData;

exports.register = async(req,res,next)=>{
exports.register = async(req,res)=>{
try{
const already = await Admin.findOne({email : req.body.email});
// user email & admin email should be different
Expand Down Expand Up @@ -58,7 +57,7 @@ exports.register = async(req,res,next)=>{
}
}

exports.login = async(req,res,next)=>{
exports.login = async(req,res)=>{
try{

const user = await Admin.findOne({email:req.body.email});
Expand Down Expand Up @@ -96,12 +95,12 @@ exports.login = async(req,res,next)=>{

}
}
exports.verify = async(req,res,next)=>{
exports.verify = async(req,res)=>{
try{
if(req.user){
res.clearCookie('jwt');
}
let OTP = Number(req.body.otp);
const OTP = Number(req.body.otp);
// console.log("doc");
// console.log(OTP);
// console.log(otp)
Expand Down Expand Up @@ -149,7 +148,7 @@ exports.verify = async(req,res,next)=>{
}
}

exports.getAdminDetail = async(req,res,next)=>{
exports.getAdminDetail = async(req,res)=>{
try{
// console.log("hello");
if(!req.admin){
Expand Down Expand Up @@ -179,10 +178,10 @@ exports.getAdminDetail = async(req,res,next)=>{

}
}
exports.logout = async(req,res,next)=>{
exports.logout = async(req,res)=>{
try{

if(!req.admin) throw new Error("You are already logout BRO!!!");
if(!req.admin) {throw new Error("You are already logout BRO!!!");}
res.clearCookie('admin');
res.status(200).json({
status:"Success",
Expand All @@ -197,9 +196,9 @@ exports.logout = async(req,res,next)=>{
}
}
exports.imageUpload = upload.single('image');
exports.updateDetails = async (req,res,next) =>{
exports.updateDetails = async (req,res) =>{
try{
const {email,image,coins,post,role} = req.body;
const {email,coins,post,role} = req.body;
const updateData = req.body;
const imageSize = 10 * 1024 * 1024;
if(imageSize < req.file.size){
Expand All @@ -209,8 +208,8 @@ exports.updateDetails = async (req,res,next) =>{
if (!updateData.image) {
// console.log(req.file);
const b64 = Buffer.from(req.file.buffer).toString("base64");
let dataURI = "data:" + req.file.mimetype + ";base64," + b64;
let result = await cloudinary.uploader.upload(dataURI,{
const dataURI = `data:${ req.file.mimetype };base64,${ b64}`;
const result = await cloudinary.uploader.upload(dataURI,{
folder:"xfintern"
});
updateData.image = result.url;
Expand All @@ -222,7 +221,7 @@ exports.updateDetails = async (req,res,next) =>{
)
}

const updatedUser = await Admin.findByIdAndUpdate(req.admin,updateData);
// const updatedUser = await Admin.findByIdAndUpdate(req.admin,updateData);

res.status(200).json({
status:"Success",
Expand All @@ -236,7 +235,7 @@ exports.updateDetails = async (req,res,next) =>{
});
}
}
exports.getAllAdminDetails = async(req,res,next)=>{
exports.getAllAdminDetails = async(req,res)=>{
try{
const adminId = req.params.adminId;
// console.log(adminId);
Expand Down
Loading

0 comments on commit a3f6b0d

Please sign in to comment.