Skip to content

Commit

Permalink
Merge pull request #95 from Arquisoft/deployTest
Browse files Browse the repository at this point in the history
Corrección de fallos para poder desplegar
  • Loading branch information
uo283055 authored Mar 5, 2024
2 parents 2230f23 + e519308 commit 91eee3a
Show file tree
Hide file tree
Showing 15 changed files with 317 additions and 123 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,18 @@ jobs:
node-version: 20
- run: npm --prefix users/authservice ci
- run: npm --prefix users/userservice ci
- run: npm --prefix questions/answerservice ci
- run: npm --prefix questions/createservice ci
- run: npm --prefix questions/generatedquestservice ci
- run: npm --prefix questions/recordservice ci
- run: npm --prefix gatewayservice ci
- run: npm --prefix webapp ci
- run: npm --prefix users/authservice test -- --coverage
- run: npm --prefix users/userservice test -- --coverage
- run: npm --prefix questions/answerservice test -- --coverage
- run: npm --prefix questions/createservice test -- --coverage
- run: npm --prefix questions/generatedquestservice test -- --coverage
- run: npm --prefix questions/recordservice test -- --coverage
- run: npm --prefix gatewayservice test -- --coverage
- run: npm --prefix webapp test -- --coverage
- name: Analyze with SonarCloud
Expand Down
82 changes: 81 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,18 @@ jobs:
node-version: 20
- run: npm --prefix users/authservice ci
- run: npm --prefix users/userservice ci
- run: npm --prefix questions/answerservice ci
- run: npm --prefix questions/createservice ci
- run: npm --prefix questions/generatedquestservice ci
- run: npm --prefix questions/recordservice ci
- run: npm --prefix gatewayservice ci
- run: npm --prefix webapp ci
- run: npm --prefix users/authservice test -- --coverage
- run: npm --prefix users/userservice test -- --coverage
- run: npm --prefix questions/answerservice test -- --coverage
- run: npm --prefix questions/createservice test -- --coverage
- run: npm --prefix questions/generatedquestservice test -- --coverage
- run: npm --prefix questions/recordservice test -- --coverage
- run: npm --prefix gatewayservice test -- --coverage
- run: npm --prefix webapp test -- --coverage
- name: Analyze with SonarCloud
Expand All @@ -35,6 +43,10 @@ jobs:
node-version: 20
- run: npm --prefix users/authservice install
- run: npm --prefix users/userservice install
- run: npm --prefix questions/answerservice install
- run: npm --prefix questions/createservice install
- run: npm --prefix questions/generatedquestservice install
- run: npm --prefix questions/recordservice install
- run: npm --prefix gatewayservice install
- run: npm --prefix webapp install
- run: npm --prefix webapp run build
Expand Down Expand Up @@ -93,6 +105,74 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: users/userservice
docker-push-answerservice:
name: Push answer service Docker Image to GitHub Packages
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs: [e2e-tests]
steps:
- uses: actions/checkout@v4
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: arquisoft/wiq_es6b/answerservice
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: questions/answerservice
docker-push-createservice:
name: Push create service Docker Image to GitHub Packages
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs: [e2e-tests]
steps:
- uses: actions/checkout@v4
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: arquisoft/wiq_es6b/createservice
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: questions/createservice
docker-push-recordservice:
name: Push record service Docker Image to GitHub Packages
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs: [e2e-tests]
steps:
- uses: actions/checkout@v4
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: arquisoft/wiq_es6b/recordservice
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: questions/recordservice
docker-push-generatedquestservice:
name: Push generated quest service Docker Image to GitHub Packages
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs: [e2e-tests]
steps:
- uses: actions/checkout@v4
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: arquisoft/wiq_es6b/generatedquestservice
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: questions/generatedquestservice
docker-push-gatewayservice:
name: Push gateway service Docker Image to GitHub Packages
runs-on: ubuntu-latest
Expand All @@ -113,7 +193,7 @@ jobs:
deploy:
name: Deploy over SSH
runs-on: ubuntu-latest
needs: [docker-push-userservice,docker-push-authservice,docker-push-gatewayservice,docker-push-webapp]
needs: [docker-push-userservice,docker-push-authservice,docker-push-gatewayservice,docker-push-webapp,docker-push-createservice,docker-push-answerservice,docker-push-recordservice,docker-push-generatedquestservice]
steps:
- name: Deploy over SSH
uses: fifsky/ssh-action@master
Expand Down
56 changes: 29 additions & 27 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,33 @@ services:
networks:
- mynetwork

recordservice:
container_name: recordservice-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_es6b/recordservice:latest
authservice:
container_name: authservice-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_es6b/authservice:latest
profiles: ["dev", "prod"]
build: ./questions/recordservice
build: ./users/authservice
depends_on:
- mongodb
ports:
- "8006:8006"
- "8002:8002"
networks:
- mynetwork
environment:
MONGODB_URI: mongodb://mongodb:27017/recorddb
MONGODB_URI: mongodb://mongodb:27017/userdb

createservice:
container_name: createservice-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_es6b/createservice:latest
userservice:
container_name: userservice-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_es6b/userservice:latest
profiles: ["dev", "prod"]
build: ./questions/createservice
build: ./users/userservice
depends_on:
- mongodb
ports:
- "8005:8005"
- "8001:8001"
networks:
- mynetwork
environment:
MONGODB_URI: mongodb://mongodb:27017/questiondb

MONGODB_URI: mongodb://mongodb:27017/userdb

answerservice:
container_name: answerservice-${teamname:-defaultASW}
Expand All @@ -54,34 +53,33 @@ services:
environment:
MONGODB_URI: mongodb://mongodb:27017/questiondb


authservice:
container_name: authservice-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_es6b/authservice:latest
createservice:
container_name: createservice-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_es6b/createservice:latest
profiles: ["dev", "prod"]
build: ./users/authservice
build: ./questions/createservice
depends_on:
- mongodb
ports:
- "8002:8002"
- "8005:8005"
networks:
- mynetwork
environment:
MONGODB_URI: mongodb://mongodb:27017/userdb
MONGODB_URI: mongodb://mongodb:27017/questiondb

userservice:
container_name: userservice-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_es6b/userservice:latest
recordservice:
container_name: recordservice-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_es6b/recordservice:latest
profiles: ["dev", "prod"]
build: ./users/userservice
build: ./questions/recordservice
depends_on:
- mongodb
ports:
- "8001:8001"
- "8006:8006"
networks:
- mynetwork
environment:
MONGODB_URI: mongodb://mongodb:27017/userdb
MONGODB_URI: mongodb://mongodb:27017/recorddb

generatedquestservice:
container_name: generatedquestservice-${teamname:-defaultASW}
Expand All @@ -106,15 +104,19 @@ services:
- mongodb
- userservice
- authservice
- answerservice
- createservice
- recordservice
- generatedquestservice
ports:
- "8000:8000"
networks:
- mynetwork
environment:
AUTH_SERVICE_URL: http://authservice:8002
USER_SERVICE_URL: http://userservice:8001
QUES_SERVICE_URL: http://createservice:8005
ANSW_SERVICE_URL: http://answerservice:8004
QUES_SERVICE_URL: http://createservice:8005
REC_SERVICE_URL: http://recordservice:8006
GEN_SERVICE_URL: http://generatedquestservice:8007

Expand Down
3 changes: 3 additions & 0 deletions docs/package-lock.json

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

2 changes: 1 addition & 1 deletion questions/answerservice/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": " Authentication service, in charge of authenticating users in the application",
"main": "service.js",
"scripts": {
"start": "node auth-service.js",
"start": "node answer-service.js",
"test": "jest"
},
"repository": {
Expand Down
49 changes: 49 additions & 0 deletions questions/createservice/create-service.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const request = require('supertest');
const { MongoMemoryServer } = require('mongodb-memory-server');
const bcrypt = require('bcrypt');
const Question = require('./create-model');

let mongoServer;
let app;

//test question
const questionTest = {
questionBody: '¿Cuál es la capital de ',
typeQuestion: 'pais',
typeAnswer: 'capital'
};

async function addQuestion(questionTest){
const newQuestion = new Question({
questionBody: questionTest.questionBody,
typeQuestion: questionTest.typeQuestion,
typeAnswer: questionTest.typeAnswer
});

await newQuestion.save();
}

beforeAll(async () => {
mongoServer = await MongoMemoryServer.create();
const mongoUri = mongoServer.getUri();
process.env.MONGODB_URI = mongoUri;
app = require('./create-service');
//Load database with initial conditions
await addQuestion(questionTest);
});

afterAll(async () => {
app.close();
await mongoServer.stop();
});

describe('Create Service', () => {
it('Should perform an addRecord operation /addQuestion', async () => {
const response = await request(app).post('/addQuestion').send(questionTest);
expect(response.status).toBe(200);
expect(response.body).toHaveProperty('questionBody', '¿Cuál es la capital de ');
expect(response.body).toHaveProperty('typeQuestion', 'pais');
expect(response.body).toHaveProperty('typeAnswer', 'capital');
});

});
2 changes: 1 addition & 1 deletion questions/createservice/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": " Creacion de preguntas automaticas",
"main": "service.js",
"scripts": {
"start": "node auth-service.js",
"start": "node create-service.js",
"test": "jest"
},
"repository": {
Expand Down
46 changes: 46 additions & 0 deletions questions/generatedquestservice/generatedquest-service.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const request = require('supertest');
const { MongoMemoryServer } = require('mongodb-memory-server');
const bcrypt = require('bcrypt');
const GeneratedQuestion = require('./generatedquest-model');

let mongoServer;
let app;

//test generated question
const generatedQuestionTest = {
generatedQuestionBody: '¿Cuál es la capital de España?',
correctAnswer: 'Madrid',
};

async function addGeneratedQuestion(generatedQuestionTest){
const newGeneratedQuestion = new GeneratedQuestion({
generatedQuestionBody: generatedQuestionTest.generatedQuestionBody,
correctAnswer: generatedQuestionTest.correctAnswer
});

await newGeneratedQuestion.save();
}

beforeAll(async () => {
mongoServer = await MongoMemoryServer.create();
const mongoUri = mongoServer.getUri();
process.env.MONGODB_URI = mongoUri;
app = require('./generatedquest-service');
//Load database with initial conditions
await addGeneratedQuestion(generatedQuestionTest);
});

afterAll(async () => {
app.close();
await mongoServer.stop();
});

describe('Generatedquest Service', () => {
it('Should perform an addRecord operation /addGeneratedQuestion', async () => {
const response = await request(app).post('/addGeneratedQuestion').send(generatedQuestionTest);
expect(response.status).toBe(200);
expect(response.body).toHaveProperty('generatedQuestionBody', '¿Cuál es la capital de España?');
expect(response.body).toHaveProperty('correctAnswer', 'Madrid');
});

});
2 changes: 1 addition & 1 deletion questions/generatedquestservice/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Almacenamiento de las preguntas automaticas generadas y su respuesta correcta correspondiente",
"main": "service.js",
"scripts": {
"start": "node auth-service.js",
"start": "node generatedquest-service.js",
"test": "jest"
},
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion questions/recordservice/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": " Creacion de preguntas automaticas",
"main": "service.js",
"scripts": {
"start": "node auth-service.js",
"start": "node record-service.js",
"test": "jest"
},
"repository": {
Expand Down
Loading

0 comments on commit 91eee3a

Please sign in to comment.