Skip to content

Commit

Permalink
Fix deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
andersonkrs committed Oct 5, 2024
1 parent 90762e5 commit 0b70dc3
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 13 deletions.
26 changes: 21 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -114,6 +114,10 @@ jobs:
with:
bundler-cache: true

- uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
Expand All @@ -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

2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 8 additions & 3 deletions test/controllers/health_check_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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"
}
})

Expand All @@ -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)
Expand All @@ -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)
Expand Down
6 changes: 2 additions & 4 deletions test/jobs/concerns/unique_jobs_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0b70dc3

Please sign in to comment.