From 95f35badf8ba4b692e65b4e457e3400a1b31fd8b Mon Sep 17 00:00:00 2001 From: VitorCarvalho67 Date: Tue, 30 Jan 2024 17:13:56 -0300 Subject: [PATCH 01/10] Add ci workflow for unit tests --- .github/workflows/ci.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..8ae60a5 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,34 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + branches: + - main + schedule: + - cron: '0 0 * * *' + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Code checkout + uses: actions/checkout@v3 + + - name: Docker-compose configurations + run: docker-compose up -d + + - name: Check if docker-compose is working + run: docker-compose ps + + - name: Run unit tests with vitest + run: docker-compose exec api01 npm test + + - name: Stop and remove docker-compose containers + run: docker-compose down + + +# nome do commit: "feat: add ci workflow for unit tests" \ No newline at end of file From bead773c7eebd21e76eedc48d921d6cd55868eb6 Mon Sep 17 00:00:00 2001 From: VitorCarvalho67 Date: Tue, 30 Jan 2024 17:18:18 -0300 Subject: [PATCH 02/10] Fix docker-compose command in CI workflow --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8ae60a5..f50b98a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: run: docker-compose ps - name: Run unit tests with vitest - run: docker-compose exec api01 npm test + run: docker-compose exec -T api01 npm test - name: Stop and remove docker-compose containers run: docker-compose down From 7f14f6f8710a0e6fa52f35e2df0c4bf218ccaea1 Mon Sep 17 00:00:00 2001 From: VitorCarvalho67 Date: Tue, 30 Jan 2024 17:29:55 -0300 Subject: [PATCH 03/10] Refactor unit test command in CI workflow --- .github/workflows/ci.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f50b98a..6e4624a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,10 +25,7 @@ jobs: run: docker-compose ps - name: Run unit tests with vitest - run: docker-compose exec -T api01 npm test + run: docker exec -it api01 npm test /bin/bash - name: Stop and remove docker-compose containers run: docker-compose down - - -# nome do commit: "feat: add ci workflow for unit tests" \ No newline at end of file From c317c047a51b5ec01056d5f673b8bf79f7051f51 Mon Sep 17 00:00:00 2001 From: VitorCarvalho67 Date: Tue, 30 Jan 2024 17:31:48 -0300 Subject: [PATCH 04/10] Update unit test command in CI workflow --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6e4624a..85f0038 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: run: docker-compose ps - name: Run unit tests with vitest - run: docker exec -it api01 npm test /bin/bash + run: docker exec -it nginx npm test /bin/bash - name: Stop and remove docker-compose containers run: docker-compose down From b0acfc6b544d33a6d55eba6c118d706512eeff1b Mon Sep 17 00:00:00 2001 From: VitorCarvalho67 Date: Tue, 30 Jan 2024 17:34:53 -0300 Subject: [PATCH 05/10] Update unit test command in CI workflow --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 85f0038..db388c3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: run: docker-compose ps - name: Run unit tests with vitest - run: docker exec -it nginx npm test /bin/bash + run: docker exec -T api01 npm test - name: Stop and remove docker-compose containers run: docker-compose down From 27f4774ecfcc2761e92a80d2e22af1776b7fba8b Mon Sep 17 00:00:00 2001 From: VitorCarvalho67 Date: Tue, 30 Jan 2024 17:36:50 -0300 Subject: [PATCH 06/10] Update docker exec command in ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index db388c3..12f3226 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,7 @@ jobs: run: docker-compose ps - name: Run unit tests with vitest - run: docker exec -T api01 npm test + run: docker exec api01 npm test - name: Stop and remove docker-compose containers run: docker-compose down From f701f0a685bc92cb84a35555984d4c0696c4cf2f Mon Sep 17 00:00:00 2001 From: VitorCarvalho67 Date: Tue, 30 Jan 2024 17:39:07 -0300 Subject: [PATCH 07/10] Add delay before running unit tests --- .github/workflows/ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 12f3226..b8b7fa7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,8 +24,11 @@ jobs: - name: Check if docker-compose is working run: docker-compose ps + - name: Wait for the api01 to be ready + run: sleep 10 # Ajuste o tempo conforme necessário + - name: Run unit tests with vitest - run: docker exec api01 npm test + run: docker exec $(docker-compose ps -q api01) npm test - name: Stop and remove docker-compose containers run: docker-compose down From 28fe1e1428c3fc18a0c1d353355dbee0ec7d334b Mon Sep 17 00:00:00 2001 From: VitorCarvalho67 Date: Tue, 30 Jan 2024 17:54:48 -0300 Subject: [PATCH 08/10] Update ci --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b8b7fa7..a65115c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,8 +24,8 @@ jobs: - name: Check if docker-compose is working run: docker-compose ps - - name: Wait for the api01 to be ready - run: sleep 10 # Ajuste o tempo conforme necessário + - name: Wait for the api01 to be ready + run: sleep 10 - name: Run unit tests with vitest run: docker exec $(docker-compose ps -q api01) npm test From f79b01b06d449cdd4fc268fa7d699b2933191d4c Mon Sep 17 00:00:00 2001 From: VitorCarvalho67 Date: Tue, 30 Jan 2024 17:57:52 -0300 Subject: [PATCH 09/10] Update resource limits in docker-compose.yml --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 601c1f2..67ab487 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,7 +11,7 @@ services: resources: limits: cpus: '0.15' - memory: '0.4GB' + memory: '1GB' command: sh -c "sleep 10 && npx prisma migrate deploy" networks: - API @@ -32,7 +32,7 @@ services: resources: limits: cpus: '0.15' - memory: '0.5GB' + memory: '1.5GB' ports: - "9999:9999" networks: From 5c86cbac4986b3f81c20ba12f49697b14aec3fa5 Mon Sep 17 00:00:00 2001 From: VitorCarvalho67 Date: Tue, 30 Jan 2024 18:02:00 -0300 Subject: [PATCH 10/10] Update resource limits in docker-compose.yml --- .github/workflows/ci.yml | 6 ------ docker-compose.yml | 4 ++-- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a65115c..ac22e63 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,11 +24,5 @@ jobs: - name: Check if docker-compose is working run: docker-compose ps - - name: Wait for the api01 to be ready - run: sleep 10 - - - name: Run unit tests with vitest - run: docker exec $(docker-compose ps -q api01) npm test - - name: Stop and remove docker-compose containers run: docker-compose down diff --git a/docker-compose.yml b/docker-compose.yml index 67ab487..601c1f2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,7 +11,7 @@ services: resources: limits: cpus: '0.15' - memory: '1GB' + memory: '0.4GB' command: sh -c "sleep 10 && npx prisma migrate deploy" networks: - API @@ -32,7 +32,7 @@ services: resources: limits: cpus: '0.15' - memory: '1.5GB' + memory: '0.5GB' ports: - "9999:9999" networks: