Skip to content

Commit

Permalink
Merge pull request #125 from Arquisoft/develop
Browse files Browse the repository at this point in the history
Merging develop to master for the deployment
  • Loading branch information
sergiollende authored Mar 22, 2024
2 parents 3be0b18 + 31d9146 commit f12d157
Show file tree
Hide file tree
Showing 38 changed files with 460 additions and 168 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 20
- uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0'

- run: npm --prefix gatewayservice ci
- run: npm --prefix webapp ci
- run: npm --prefix authservice ci
- run: npm --prefix userservice ci
- run: dotnet build ./wikidata_service/WikidataService.csproj

- run: npm --prefix gatewayservice test -- --coverage
- run: npm --prefix webapp test -- --coverage
Expand Down
79 changes: 11 additions & 68 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,12 @@ on:
types: [published]

jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm --prefix users/authservice ci
- run: npm --prefix users/userservice 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 gatewayservice test -- --coverage
- run: npm --prefix webapp test -- --coverage
- name: Analyze with SonarCloud
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
e2e-tests:
needs: [unit-tests]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm --prefix users/authservice install
- run: npm --prefix users/userservice install
- run: npm --prefix gatewayservice install
- run: npm --prefix webapp install
- run: npm --prefix webapp run build
- run: npm --prefix webapp run test:e2e
docker-push-webapp:
name: Push webapp 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
Expand All @@ -58,48 +23,24 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: webapp
buildargs: API_URI
docker-push-authservice:
name: Push auth service Docker Image to GitHub Packages
buildargs: |
API_URI
docker-push-api:
name: Push api 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_en3a/authservice
name: arquisoft/wiq_en3a/api
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: users/authservice
docker-push-userservice:
name: Push user 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_en3a/userservice
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: users/userservice
workdir: api
docker-push-gatewayservice:
name: Push gateway 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
Expand All @@ -113,16 +54,18 @@ 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-gatewayservice,docker-push-webapp, docker-push-api]
steps:
- name: Deploy over SSH
uses: fifsky/ssh-action@master
env:
API_URI: ${{ secrets.DEPLOY_HOST }}
with:
host: ${{ secrets.DEPLOY_HOST }}
user: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.DEPLOY_KEY }}
command: |
wget https://raw.githubusercontent.com/arquisoft/wiq_en3a/master/docker-compose.yml -O docker-compose.yml
wget https://raw.githubusercontent.com/arquisoft/wiq_en3a/master/.env
docker compose down
docker compose --profile prod up -d
docker compose --profile prod down
docker compose --profile prod up -d --pull always
File renamed without changes.
5 changes: 3 additions & 2 deletions users/Dockerfile → api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
FROM node:20

# Set the working directory in the container
WORKDIR /usr/src/users
WORKDIR /usr/src/api

# Copy package.json and package-lock.json to the working directory
COPY package*.json ./

# Install app dependencies
RUN npm install
RUN npm install --no-cache

# Copy the app source code to the working directory
COPY . .
Expand All @@ -18,3 +18,4 @@ EXPOSE 8002

# Define the command to run your app
CMD ["node", "index.js"]

17 changes: 17 additions & 0 deletions api/authservice/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Use an official Node.js runtime as a parent image
FROM node:20

# Set the working directory in the container
WORKDIR /usr/src/authservice

# Copy package.json and package-lock.json to the working directory
COPY package*.json ./

# Install app dependencies
RUN npm install

# Copy the app source code to the working directory
COPY . .

# Define the command to run your app
CMD ["node", "auth-service.js"]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions users/index.js → api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ mongoose.connect(mongoUri).then(
// Routes
const authRoutes = require('./authservice/auth-service.js');
const userRoutes = require('./userservice/user-service.js');
const wikidataRoutes = require('./wikidataservice/wikidata-service.js');


// Middlewares added to the application
Expand All @@ -30,8 +31,7 @@ app.use(bodyParser.json());
// Routes middlewares to be used
app.use('/auth', authRoutes);
app.use('/user', userRoutes);


app.use('/wikidata', wikidataRoutes);


// Start the server
Expand Down
33 changes: 22 additions & 11 deletions users/package-lock.json → api/package-lock.json

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

5 changes: 3 additions & 2 deletions users/package.json → api/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "users",
"name": "api",
"version": "1.0.0",
"description": "User service, in charge of handling users in the application",
"description": "API service, in charge of handling the different clases of the API in the application",
"main": "service.js",
"scripts": {
"start": "node index.js",
Expand All @@ -18,6 +18,7 @@
},
"homepage": "https://github.com/arquisoft/wiq_en3a#readme",
"dependencies": {
"axios": "^1.6.7",
"bcrypt": "^5.1.1",
"body-parser": "^1.20.2",
"cors": "^2.8.5",
Expand Down
21 changes: 21 additions & 0 deletions api/userservice/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Use an official Node.js runtime as a parent image
FROM node:20

# Set the working directory in the container
WORKDIR /usr/src/userservice

# Copy package.json and package-lock.json to the working directory
COPY package*.json ./

# Install app dependencies
RUN npm install

# Copy the app source code to the working directory
COPY . .

# Expose the port the app runs on
EXPOSE 8001

# Define the command to run your app
CMD ["node", "user-service.js"]

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const User = require('./user-model')
// GET route to retrieve an specific user by username
// 'http://localhost:8002/getOneUser?username=nombre_de_usuario'

router.get('/getUser', async (req, res) => {
router.get('/getuser', async (req, res) => {
try {

// access to the database
Expand Down Expand Up @@ -76,7 +76,7 @@ router.post('/adduser', async (req, res) => {


// edit a user to update the total and correct question answered
router.post('/editUser', async (req, res) => {
router.post('/edituser', async (req, res) => {
try {

// --- find the user to be updated
Expand Down
File renamed without changes.
Empty file.
Loading

0 comments on commit f12d157

Please sign in to comment.