forked from fga-eps-mds/2024.1-CALCULUS-StudioMaker
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from fga-eps-mds/dev
Atualizando Main
- Loading branch information
Showing
7 changed files
with
205 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Deploy Studio Maker in Azure | ||
|
||
# Dispara o workflow para push e pull request na branch 'dev' | ||
on: | ||
push: | ||
branches: | ||
- dev | ||
|
||
|
||
|
||
|
||
jobs: | ||
run-script: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: executing remote ssh commands using password | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.IP_VM_AZURE_DEV }} | ||
username: ${{ secrets.USER_VM_AZURE_DEV }} | ||
password: ${{ secrets.USER_VM_AZURE_DEV }} | ||
port: 22 | ||
request_pty: true | ||
script: | | ||
ls -alt | ||
cd /home/Calculus-admin1/app | ||
pwd | ||
sudo ./manage_process_back_studio.sh | ||
echo "Starting deploy Studio Service" | ||
sudo ./deploy_back_studio.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<testExecutions version="1"> | ||
<file path="test/trail.service.spec.ts"> | ||
<testCase name="TrailService should be defined" duration="12" /> | ||
<testCase name="TrailService should throw NotFoundException if journey is not found when creating a trail" duration="7" /> | ||
<testCase name="TrailService should throw NotFoundException if trail is not found when adding content" duration="3" /> | ||
<testCase name="TrailService should throw NotFoundException if trail is not found when removing content" duration="2" /> | ||
<testCase name="TrailService should find a trail by ID" duration="11" /> | ||
<testCase name="TrailService should throw NotFoundException if trail is not found when finding by ID" duration="3" /> | ||
<testCase name="TrailService should return all trails" duration="3" /> | ||
<testCase name="TrailService should update a trail" duration="4" /> | ||
<testCase name="TrailService should throw NotFoundException if trail is not found when updating" duration="3" /> | ||
<testCase name="TrailService should throw NotFoundException if trail is not found when deleting" duration="2" /> | ||
</file> | ||
<file path="test/content.service.spec.ts"> | ||
<testCase name="ContentService should be defined" duration="3" /> | ||
<testCase name="ContentService createContent should throw NotFoundException if trail does not exist" duration="3" /> | ||
<testCase name="ContentService findContentById should return content by id" duration="2" /> | ||
<testCase name="ContentService findContentById should throw NotFoundException if content does not exist" duration="2" /> | ||
<testCase name="ContentService findAllContents should return all contents" duration="2" /> | ||
<testCase name="ContentService updateContent should update content and return the updated content" duration="2" /> | ||
<testCase name="ContentService updateContent should throw NotFoundException if content does not exist" duration="2" /> | ||
<testCase name="ContentService deleteContent should delete content" duration="1" /> | ||
<testCase name="ContentService deleteContent should throw NotFoundException if content does not exist" duration="2" /> | ||
</file> | ||
<file path="test/journey.service.spec.ts"> | ||
<testCase name="JourneyService should be defined" duration="4" /> | ||
<testCase name="JourneyService should throw UnauthorizedException if token is invalid" duration="6" /> | ||
<testCase name="JourneyService should throw NotFoundException if journey is not found" duration="2" /> | ||
<testCase name="JourneyService should return all journeys" duration="2" /> | ||
<testCase name="JourneyService should return journeys by user ID" duration="1" /> | ||
<testCase name="JourneyService should update a journey" duration="8" /> | ||
<testCase name="JourneyService should delete a journey" duration="2" /> | ||
<testCase name="JourneyService should throw NotFoundException if journey is not found when adding a trail" duration="2" /> | ||
<testCase name="JourneyService should return user id when token is valid" duration="3" /> | ||
<testCase name="JourneyService should return null when token is invalid" duration="2" /> | ||
</file> | ||
<file path="test/content.controller.spec.ts"> | ||
<testCase name="ContentController should be defined" duration="5" /> | ||
<testCase name="ContentController createContent should create content" duration="2" /> | ||
<testCase name="ContentController createContent should throw NotFoundException if required fields are missing" duration="6" /> | ||
<testCase name="ContentController findContentById should return content by id" duration="3" /> | ||
<testCase name="ContentController findContentById should throw NotFoundException if content is not found" duration="4" /> | ||
<testCase name="ContentController findAllContents should return all contents" duration="2" /> | ||
<testCase name="ContentController updateContent should update content and return the updated content" duration="2" /> | ||
<testCase name="ContentController updateContent should throw NotFoundException if content is not found" duration="2" /> | ||
<testCase name="ContentController deleteContent should delete content" duration="4" /> | ||
<testCase name="ContentController deleteContent should throw NotFoundException if content is not found" duration="2" /> | ||
</file> | ||
<file path="test/trail.controller.spec.ts"> | ||
<testCase name="TrailController should be defined" duration="3" /> | ||
<testCase name="TrailController createTrail should create a trail" duration="2" /> | ||
<testCase name="TrailController createTrail should throw NotFoundException if journeyId is not provided" duration="11" /> | ||
<testCase name="TrailController getTrailById should return a trail by id" duration="4" /> | ||
<testCase name="TrailController getAllTrails should return all trails" duration="2" /> | ||
<testCase name="TrailController updateTrail should update a trail" duration="2" /> | ||
<testCase name="TrailController addContentToTrail should add content to a trail" duration="2" /> | ||
<testCase name="TrailController addContentToTrail should throw NotFoundException if contentId is not provided" duration="2" /> | ||
<testCase name="TrailController removeContentFromTrail should remove content from a trail" duration="2" /> | ||
<testCase name="TrailController deleteTrail should delete a trail" duration="2" /> | ||
</file> | ||
<file path="test/journey.controller.spec.ts"> | ||
<testCase name="JourneyController should be defined" duration="12" /> | ||
<testCase name="JourneyController create should create a journey" duration="4" /> | ||
<testCase name="JourneyController create should throw UnauthorizedException if token is not provided" duration="17" /> | ||
<testCase name="JourneyController findAll should return all journeys" duration="6" /> | ||
<testCase name="JourneyController findByUser should return journeys by user id" duration="5" /> | ||
<testCase name="JourneyController findById should return a journey by id" duration="4" /> | ||
<testCase name="JourneyController update should update a journey" duration="4" /> | ||
<testCase name="JourneyController delete should delete a journey" duration="3" /> | ||
<testCase name="JourneyController addTrailToJourney should add a trail to a journey" duration="5" /> | ||
</file> | ||
</testExecutions> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/bin/bash | ||
|
||
SESSION_NAME="backend-user-session" | ||
ENV="dev" | ||
DIR1="/home/Calculus-admin1/app/2024.1-CALCULUS-StudioMaker" | ||
|
||
# Comandos renomeados para refletir a ordem de execução | ||
CMD1="git fetch" | ||
CMD2="git checkout $ENV" | ||
CMD3="git pull origin $ENV" | ||
CMD4="npm install" | ||
CMD5="npm run start" | ||
CMD6="echo Starting Deploy Studio Maker backend" | ||
|
||
# Função para iniciar a sessão tmux e executar comandos | ||
start_tmux_session() { | ||
# Criar uma nova sessão tmux | ||
tmux kill-session -t $SESSION_NAME 2>/dev/null | ||
tmux new-session -d -s $SESSION_NAME | ||
|
||
# Executar os comandos na pasta do frontend | ||
tmux send-keys -t $SESSION_NAME "cd $DIR1" C-m | ||
tmux send-keys -t $SESSION_NAME "$CMD1" C-m | ||
tmux send-keys -t $SESSION_NAME "$CMD2" C-m | ||
tmux send-keys -t $SESSION_NAME "$CMD3" C-m | ||
tmux send-keys -t $SESSION_NAME "$CMD4" C-m | ||
tmux send-keys -t $SESSION_NAME "$CMD5" C-m | ||
tmux send-keys -t $SESSION_NAME "$CMD6" C-m | ||
|
||
# Anexar à sessão tmux para visualizar os comandos em execução | ||
# tmux attach-session -t $SESSION_NAME | ||
} | ||
|
||
# Função para executar o health check | ||
run_healthcheck() { | ||
PORT=3002 | ||
CHECK_INTERVAL=5 | ||
|
||
echo "Deploy backend iniciado" | ||
echo "Iniciando health check para a porta $PORT..." | ||
|
||
while true; do | ||
# Executa o comando para verificar se a porta está em uso | ||
OUTPUT=$(ss -tuln | grep ":$PORT") | ||
|
||
# Verifica se há algum resultado | ||
if [ -n "$OUTPUT" ]; then | ||
echo "A porta $PORT está em uso. Encerrando o health check." | ||
echo "Deploy realizado com sucesso!" | ||
break | ||
else | ||
echo "A porta $PORT não está em uso. Verificando novamente em $CHECK_INTERVAL segundos..." | ||
sleep $CHECK_INTERVAL | ||
fi | ||
done | ||
} | ||
|
||
# Iniciar a sessão tmux e executar os comandos | ||
start_tmux_session | ||
|
||
# Após a execução do tmux, iniciar o health check | ||
run_healthcheck |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
# Portas que precisam ser verificadas | ||
PORT1=3002 | ||
|
||
# Função para encerrar processos que estão usando a porta | ||
kill_process_on_port() { | ||
local PORT=$1 | ||
PID=$(lsof -t -i:$PORT) | ||
if [ -n "$PID" ]; then | ||
echo "Terminating process on port $PORT (PID: $PID)" | ||
sudo kill -9 $PID | ||
else | ||
echo "No process running on port $PORT" | ||
fi | ||
} | ||
|
||
|
||
# Encerrar processos nas portas especificadas | ||
kill_process_on_port $PORT1 | ||
|
||
# Encerrar processos relacionados ao `nest` | ||
echo "Terminating all processes for 'nest'" | ||
#sudo pkill nest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters