From 0b70dc3d9bf7713aff7ff3be914134f9be9cf319 Mon Sep 17 00:00:00 2001 From: Anderson Macedo Date: Sat, 5 Oct 2024 13:42:40 -0300 Subject: [PATCH] Fix deployment --- .github/workflows/ci.yml | 26 +++++++++++++++---- Gemfile.lock | 2 +- .../health_check_controller_test.rb | 11 +++++--- test/jobs/concerns/unique_jobs_test.rb | 6 ++--- 4 files changed, 32 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 746f7283..70c8c7dc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -100,9 +100,9 @@ jobs: env: DOCKER_BUILDKIT: 1 - DOCKER_REGISTRY_PASSWORD: ${{ secrets.DOCKER_REGISTRY_PASSWORD }} - COOLIFY_WEBHOOK: ${{ secrets.COOLIFY_WEBHOOK }} - COOLIFY_TOKEN: ${{ secrets.COOLIFY_TOKEN }} + RAILS_ENV: production + RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }} + KAMAL_REGISTRY_PASSWORD: ${{ secrets.DOCKER_REGISTRY_PASSWORD }} steps: - uses: actions/checkout@v4 @@ -114,6 +114,10 @@ jobs: with: bundler-cache: true + - uses: webfactory/ssh-agent@v0.7.0 + with: + ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} + - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v2 @@ -124,15 +128,27 @@ jobs: username: andersonskm password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }} + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: andersonskm/malheatmap + labels: | + service=malheatmap + - name: Build and push uses: docker/build-push-action@v5 with: context: . push: true - platforms: linux/amd64 tags: andersonskm/malheatmap:${{ github.sha }},andersonskm/malheatmap:latest cache-from: type=gha cache-to: type=gha,mode=max + labels: ${{ steps.meta.outputs.labels }} + + - name: Export master key + run: echo "$RAILS_MASTER_KEY" > config/credentials/production.key - name: Run deploy command - run: ./bin/trigger-deployment + run: bin/kamal deploy -v --skip_push + diff --git a/Gemfile.lock b/Gemfile.lock index 40178460..6cf922cd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -88,7 +88,7 @@ GEM safely_block (>= 0.4) bootsnap (1.18.4) msgpack (~> 1.2) - brakeman (6.1.2) + brakeman (6.2.1) racc builder (3.3.0) capybara (3.40.0) diff --git a/test/controllers/health_check_controller_test.rb b/test/controllers/health_check_controller_test.rb index 6a154bba..68d0b080 100644 --- a/test/controllers/health_check_controller_test.rb +++ b/test/controllers/health_check_controller_test.rb @@ -11,6 +11,7 @@ class HealthCheckControllerTest < ActionDispatch::IntegrationTest test "returns service unavailable if queues are down" do SolidQueue::Process.create!({ + name: "test", last_heartbeat_at: 1.hour.ago, kind: "Worker", pid: 123, @@ -26,6 +27,7 @@ class HealthCheckControllerTest < ActionDispatch::IntegrationTest test "returns ok if the queueing backend is up" do SolidQueue::Process.create!({ + name: "test", last_heartbeat_at: 10.seconds.ago, kind: "Worker", pid: 123, @@ -35,11 +37,12 @@ class HealthCheckControllerTest < ActionDispatch::IntegrationTest }) SolidQueue::Process.create!({ + name: "test", last_heartbeat_at: 10.seconds.ago, kind: "Worker", pid: 456, metadata: { - queues: "active_storage,low,logging" + queues: "active_storage,low,logging,solid_queue_recurring" } }) @@ -51,11 +54,12 @@ class HealthCheckControllerTest < ActionDispatch::IntegrationTest test "returns service unavailable if there is a stuck execution expired" do job = SolidQueue::Job.create!(queue_name: "default", class_name: "CronJob") process = SolidQueue::Process.create!({ + name: "test", last_heartbeat_at: 10.seconds.ago, kind: "Worker", pid: 123, metadata: { - queues: "screenshots,default,active_storage,low,logging" + queues: "screenshots,default,active_storage,low,logging,solid_queue_recurring" } }) process.claimed_executions.create(job: job, created_at: 6.hours.ago) @@ -68,11 +72,12 @@ class HealthCheckControllerTest < ActionDispatch::IntegrationTest test "returns ok if there is a stuck execution but not expired" do job = SolidQueue::Job.create!(queue_name: "backups", class_name: "CronJob") process = SolidQueue::Process.create!({ + name: "test", last_heartbeat_at: 10.seconds.ago, kind: "Worker", pid: 123, metadata: { - queues: "screenshots,default,active_storage,low,logging" + queues: "screenshots,default,active_storage,low,logging,solid_queue_recurring" } }) process.claimed_executions.create(job: job, created_at: (2.hours + 10.minutes).ago) diff --git a/test/jobs/concerns/unique_jobs_test.rb b/test/jobs/concerns/unique_jobs_test.rb index d7e442a6..6c92abfd 100644 --- a/test/jobs/concerns/unique_jobs_test.rb +++ b/test/jobs/concerns/unique_jobs_test.rb @@ -5,17 +5,15 @@ class Bucket < ApplicationRecord class InvalidElement < StandardError; end def fill_with(liquid) - raise InvalidElement if liquid.blank? - Rails.logger.debug(liquid) end end class BucketJob < ApplicationJob - uniqueness_control key: ->(record, _) { [record.id, record.updated_at&.to_fs(:number)] }, + uniqueness_control key: ->(record) { [record.id, record.updated_at&.to_fs(:number)] }, expires_in: 30.minutes - def perform(bucket, liquid = :water) + def perform(bucket) bucket.fill_with(liquid) end end