From 736f9b683de4eef721e010bf8d46d9912944a75e Mon Sep 17 00:00:00 2001 From: Raquel Brito Date: Sat, 25 Jan 2025 21:23:16 -0300 Subject: [PATCH 01/10] Update ci.yml --- .github/workflows/ci.yml | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3bf8a14..0c2fe30 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,12 +40,23 @@ jobs: test: runs-on: ubuntu-latest - # services: - # redis: - # image: redis - # ports: - # - 6379:6379 - # options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5 + services: + rabbitmq: + image: rabbitmq:3-management + ports: + - 5672:5672 + - 15672:15672 + options: --health-cmd "rabbitmq-diagnostics ping" --health-interval 10s --health-timeout 5s --health-retries 5 + postgres: + image: postgres:13 + ports: + - 5432:5432 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: password + POSTGRES_DB: ecommerce_db + options: --health-cmd "pg_isready -U postgres" --health-interval 10s --health-timeout 5s --health-retries 5 + steps: - name: Install packages run: sudo apt-get update && sudo apt-get install --no-install-recommends -y google-chrome-stable curl libjemalloc2 libvips sqlite3 @@ -59,6 +70,9 @@ jobs: ruby-version: .ruby-version bundler-cache: true + - name: Run tests + run: bundle exec rails test + - name: Keep screenshots from failed system tests uses: actions/upload-artifact@v4 if: failure() From 9d500160e7c0128e2f9cf93b234de5b7830e46ed Mon Sep 17 00:00:00 2001 From: Raquel Brito Date: Sat, 25 Jan 2025 21:29:48 -0300 Subject: [PATCH 02/10] update gem --- Gemfile | 1 + Gemfile.lock | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Gemfile b/Gemfile index ae9c794..1924d33 100644 --- a/Gemfile +++ b/Gemfile @@ -19,6 +19,7 @@ gem "dotenv", require: "dotenv/load" gem "sidekiq-unique-jobs" gem "devise" gem "oj" +gem "pg" # Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis] # gem "kredis" diff --git a/Gemfile.lock b/Gemfile.lock index dd29dfb..a2e182b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -178,6 +178,7 @@ GEM parser (3.3.7.0) ast (~> 2.4.1) racc + pg (1.5.9) pp (0.6.2) prettyprint prettyprint (0.2.0) @@ -337,6 +338,7 @@ DEPENDENCIES httparty jbuilder oj + pg pry (~> 0.14.2) puma (>= 5.0) rails (~> 7.2.2, >= 7.2.2.1) From 13b8ae91e9055273d231c4712e7ba6997b4b836c Mon Sep 17 00:00:00 2001 From: Raquel Brito Date: Sat, 25 Jan 2025 21:37:06 -0300 Subject: [PATCH 03/10] att .env --- .env | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .env diff --git a/.env b/.env new file mode 100644 index 0000000..e2812cd --- /dev/null +++ b/.env @@ -0,0 +1,32 @@ +# Servidor +PORT=3001 +LANG=en_US +RACK_ENV=development +RAILS_ENV=development + +# Sidekiq +SIDEKIQ_USERNAME=sidekiq +SIDEKIQ_PASSWORD=1234 +SIDEKIQ_CONSUMERS_QUEUES=default + +#postgre +POSTGRES_DB=ecommerce_db +POSTGRES_USER=postgres +POSTGRES_PASSWORD=password +POSTGRES_HOST=db +POSTGRES_PORT=5432 +DATABASE_NAME=ecommerce_db + +# Redis +REDIS_HOST=redis://redis +REDIS_PORT=6379 +REDIS_PASSWORD= + +# RabbitMQ +RABBITMQ_URL=amqp://guest:guest@rabbitmq:5672 +EXCHANGE=transactions + +# APIs +FIDELITY_API_URL=http://localhost:3000/api/v1/fidelity +STORE_API_URL=http://localhost:3000/api/v1/store +EXCHANGE_API_URL=http://localhost:3000/api/v1/exchange From 4abd0091df4b5169c2748c76a55140d003bfd742 Mon Sep 17 00:00:00 2001 From: Raquel Brito Date: Sat, 25 Jan 2025 21:42:30 -0300 Subject: [PATCH 04/10] Update ci.yml --- .github/workflows/ci.yml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0c2fe30..bb26202 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,8 +58,8 @@ jobs: options: --health-cmd "pg_isready -U postgres" --health-interval 10s --health-timeout 5s --health-retries 5 steps: - - name: Install packages - run: sudo apt-get update && sudo apt-get install --no-install-recommends -y google-chrome-stable curl libjemalloc2 libvips sqlite3 + - name: Install dependencies + run: sudo apt-get update && sudo apt-get install --no-install-recommends -y google-chrome-stable curl libjemalloc2 libvips sqlite3 netcat - name: Checkout code uses: actions/checkout@v4 @@ -70,6 +70,20 @@ jobs: ruby-version: .ruby-version bundler-cache: true + - name: Wait for RabbitMQ to be ready + run: | + until nc -zv rabbitmq 5672; do + echo "Waiting for RabbitMQ..." + sleep 2 + done + + - name: Wait for PostgreSQL to be ready + run: | + until nc -zv postgres 5432; do + echo "Waiting for PostgreSQL..." + sleep 2 + done + - name: Run tests run: bundle exec rails test From ae1f0f6a1132cbc285460e425befa768360a7cb6 Mon Sep 17 00:00:00 2001 From: Raquel Brito Date: Sat, 25 Jan 2025 21:45:16 -0300 Subject: [PATCH 05/10] Update ci.yml --- .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 bb26202..69962b4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -74,14 +74,14 @@ jobs: run: | until nc -zv rabbitmq 5672; do echo "Waiting for RabbitMQ..." - sleep 2 + sleep 5 done - name: Wait for PostgreSQL to be ready run: | until nc -zv postgres 5432; do echo "Waiting for PostgreSQL..." - sleep 2 + sleep 5 done - name: Run tests From 48116bbcb3795b06f21578e6d6f7b596a283d003 Mon Sep 17 00:00:00 2001 From: Raquel Brito Date: Sat, 25 Jan 2025 21:47:49 -0300 Subject: [PATCH 06/10] Update 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 69962b4..41aad28 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,7 +59,7 @@ jobs: steps: - name: Install dependencies - run: sudo apt-get update && sudo apt-get install --no-install-recommends -y google-chrome-stable curl libjemalloc2 libvips sqlite3 netcat + run: sudo apt-get update && sudo apt-get install --no-install-recommends -y google-chrome-stable curl libjemalloc2 libvips sqlite3 netcat-openbsd - name: Checkout code uses: actions/checkout@v4 From b0ad5205faf101a478799f34c304dd9a44989ab6 Mon Sep 17 00:00:00 2001 From: Raquel Brito Date: Sat, 25 Jan 2025 21:54:25 -0300 Subject: [PATCH 07/10] Update ci.yml --- .github/workflows/ci.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 41aad28..d40117f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -70,6 +70,16 @@ jobs: ruby-version: .ruby-version bundler-cache: true + # Etapa para construir os containers Docker + - name: Build Docker containers + run: | + docker-compose -f docker-compose.yml build + + # Etapa para verificar se os containers estão funcionando corretamente + - name: Start Docker containers + run: | + docker-compose -f docker-compose.yml up -d + - name: Wait for RabbitMQ to be ready run: | until nc -zv rabbitmq 5672; do From e358b3339991176701ff7af7ea6ff2de084cc829 Mon Sep 17 00:00:00 2001 From: Raquel Brito Date: Sat, 25 Jan 2025 21:56:53 -0300 Subject: [PATCH 08/10] Update ci.yml --- .github/workflows/ci.yml | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d40117f..6210d85 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,6 +58,16 @@ jobs: options: --health-cmd "pg_isready -U postgres" --health-interval 10s --health-timeout 5s --health-retries 5 steps: + - name: Set up Docker + run: | + sudo apt-get update + sudo apt-get install -y docker.io + sudo systemctl start docker + sudo systemctl enable docker + sudo curl -L "https://github.com/docker/compose/releases/download/v2.14.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose + sudo chmod +x /usr/local/bin/docker-compose + docker-compose --version + - name: Install dependencies run: sudo apt-get update && sudo apt-get install --no-install-recommends -y google-chrome-stable curl libjemalloc2 libvips sqlite3 netcat-openbsd @@ -80,20 +90,6 @@ jobs: run: | docker-compose -f docker-compose.yml up -d - - name: Wait for RabbitMQ to be ready - run: | - until nc -zv rabbitmq 5672; do - echo "Waiting for RabbitMQ..." - sleep 5 - done - - - name: Wait for PostgreSQL to be ready - run: | - until nc -zv postgres 5432; do - echo "Waiting for PostgreSQL..." - sleep 5 - done - - name: Run tests run: bundle exec rails test From ceec832684d7dc75f5d47be91e1441a5b74b7471 Mon Sep 17 00:00:00 2001 From: Raquel Brito Date: Sat, 25 Jan 2025 21:59:16 -0300 Subject: [PATCH 09/10] Update ci.yml --- .github/workflows/ci.yml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6210d85..6e1929c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,21 +41,21 @@ jobs: runs-on: ubuntu-latest services: - rabbitmq: - image: rabbitmq:3-management - ports: - - 5672:5672 - - 15672:15672 - options: --health-cmd "rabbitmq-diagnostics ping" --health-interval 10s --health-timeout 5s --health-retries 5 - postgres: - image: postgres:13 - ports: - - 5432:5432 - env: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: password - POSTGRES_DB: ecommerce_db - options: --health-cmd "pg_isready -U postgres" --health-interval 10s --health-timeout 5s --health-retries 5 + # rabbitmq: + # image: rabbitmq:3-management + # ports: + # - 5672:5672 + # - 15672:15672 + # options: --health-cmd "rabbitmq-diagnostics ping" --health-interval 10s --health-timeout 5s --health-retries 5 + # postgres: + # image: postgres:13 + # ports: + # - 5432:5432 + # env: + # POSTGRES_USER: postgres + # POSTGRES_PASSWORD: password + # POSTGRES_DB: ecommerce_db + # options: --health-cmd "pg_isready -U postgres" --health-interval 10s --health-timeout 5s --health-retries 5 steps: - name: Set up Docker From 2dceb7379d9432429d117861a760878ecc04f590 Mon Sep 17 00:00:00 2001 From: Raquel Brito Date: Sat, 25 Jan 2025 22:00:54 -0300 Subject: [PATCH 10/10] Update ci.yml --- .github/workflows/ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6e1929c..030c5ce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,7 +58,7 @@ jobs: # options: --health-cmd "pg_isready -U postgres" --health-interval 10s --health-timeout 5s --health-retries 5 steps: - - name: Set up Docker + - name: Set up Docker run: | sudo apt-get update sudo apt-get install -y docker.io @@ -85,7 +85,6 @@ jobs: run: | docker-compose -f docker-compose.yml build - # Etapa para verificar se os containers estão funcionando corretamente - name: Start Docker containers run: | docker-compose -f docker-compose.yml up -d