From 51ee4b5ddd0fb4bf25d864ca09abb3b7a085e98e Mon Sep 17 00:00:00 2001 From: Charlotte Van Petegem Date: Sat, 9 Nov 2024 10:34:31 +0100 Subject: [PATCH] Switch from delayed job to solid queue --- Gemfile | 4 +- Gemfile.lock | 20 ++- app/jobs/repository_reprocess_job.rb | 9 ++ app/models/organisation_member.rb | 13 +- app/models/repository.rb | 52 +++---- bin/delayed_job | 5 - bin/jobs | 6 + config/application.rb | 2 +- config/environments/production.rb | 2 - config/puma.rb | 1 + config/queue.yml | 18 +++ config/recurring.yml | 10 ++ .../20241109090736_remove_delayed_job.rb | 5 + .../20241109091236_add_solid_queue_tables.rb | 131 ++++++++++++++++ db/schema.rb | 144 ++++++++++++++++-- db/seeds.rb | 1 + runner.dockerfile | 2 +- test/jobs/repository_reprocess_job_test.rb | 7 + 18 files changed, 364 insertions(+), 68 deletions(-) create mode 100644 app/jobs/repository_reprocess_job.rb delete mode 100755 bin/delayed_job create mode 100755 bin/jobs create mode 100644 config/queue.yml create mode 100644 config/recurring.yml create mode 100644 db/migrate/20241109090736_remove_delayed_job.rb create mode 100644 db/migrate/20241109091236_add_solid_queue_tables.rb create mode 100644 test/jobs/repository_reprocess_job_test.rb diff --git a/Gemfile b/Gemfile index e69276a..39ca6cc 100644 --- a/Gemfile +++ b/Gemfile @@ -31,8 +31,8 @@ gem 'github_api' gem 'sentry-rails' gem 'sentry-ruby' -# Use delayed job for executing jobs in the background -gem 'delayed_job_active_record' +# Use solid queue for executing jobs in the background +gem 'solid_queue' # Set CORS headers gem 'rack-cors' diff --git a/Gemfile.lock b/Gemfile.lock index 3590b10..f3d4463 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -103,15 +103,12 @@ GEM debug (1.9.2) irb (~> 1.10) reline (>= 0.3.8) - delayed_job (4.1.12) - activesupport (>= 3.0, < 8.0) - delayed_job_active_record (4.1.10) - activerecord (>= 3.0, < 8.0) - delayed_job (>= 3.0, < 5) descendants_tracker (0.0.4) thread_safe (~> 0.3, >= 0.3.1) drb (2.2.1) erubi (1.13.0) + et-orbi (1.2.11) + tzinfo faraday (1.10.3) faraday-em_http (~> 1.0) faraday-em_synchrony (~> 1.0) @@ -135,6 +132,9 @@ GEM faraday-patron (1.0.0) faraday-rack (1.0.0) faraday-retry (1.0.3) + fugit (1.11.1) + et-orbi (~> 1, >= 1.2.11) + raabro (~> 1.4) github_api (0.19.0) addressable (~> 2.4) descendants_tracker (~> 0.0.4) @@ -202,6 +202,7 @@ GEM public_suffix (5.0.4) puma (6.4.3) nio4r (~> 2.0) + raabro (1.4.0) racc (1.8.1) rack (3.1.8) rack-cors (2.0.2) @@ -285,6 +286,13 @@ GEM sentry-ruby (5.21.0) bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) + solid_queue (1.0.1) + activejob (>= 7.1) + activerecord (>= 7.1) + concurrent-ruby (>= 1.3.1) + fugit (~> 1.11.0) + railties (>= 7.1) + thor (~> 1.3.1) sprockets (4.2.1) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) @@ -330,7 +338,6 @@ DEPENDENCIES capybara cssbundling-rails debug - delayed_job_active_record github_api jbuilder pg (~> 1.5) @@ -343,6 +350,7 @@ DEPENDENCIES selenium-webdriver sentry-rails sentry-ruby + solid_queue sprockets-rails tzinfo-data unicorn (~> 6.1) diff --git a/app/jobs/repository_reprocess_job.rb b/app/jobs/repository_reprocess_job.rb new file mode 100644 index 0000000..0dc5bfb --- /dev/null +++ b/app/jobs/repository_reprocess_job.rb @@ -0,0 +1,9 @@ +class RepositoryReprocessJob < ApplicationJob + queue_as :default + + def perform(repository) + OrganisationMember.create_all_from_organisation(repository.organisation) + repository.pull_or_clone + repository.process_commits + end +end diff --git a/app/models/organisation_member.rb b/app/models/organisation_member.rb index 20a86bc..41a9908 100644 --- a/app/models/organisation_member.rb +++ b/app/models/organisation_member.rb @@ -14,12 +14,13 @@ class OrganisationMember < ApplicationRecord validates :github_name, uniqueness: { scope: :organisation } def self.create_all_from_organisation(organisation) - OrganisationMember.where(organisation:).destroy_all - # rubocop:disable Rails/FindEach - # This is not a rails structure - Rails.application.config.github.orgs.members.all(organisation).each do |member| - OrganisationMember.create(organisation:, github_name: member['login']) + members = Rails.application.config.github.orgs.members.all(organisation) + + OrganisationMember.transaction do + OrganisationMember.where(organisation:).destroy_all + members.each do |member| + OrganisationMember.create(organisation:, github_name: member['login']) + end end - # rubocop:enable Rails/FindEach end end diff --git a/app/models/repository.rb b/app/models/repository.rb index b34dcda..152895b 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -23,7 +23,7 @@ class Repository < ApplicationRecord validate :not_filtered before_create :set_path - after_save :reprocess_delayed + after_save :reprocess_in_background def self.create_or_update_from_github_api(organisation, name, github_url, clone_url) Repository.find_or_initialize_by(organisation:, name:) do |r| @@ -32,34 +32,6 @@ def self.create_or_update_from_github_api(organisation, name, github_url, clone_ end.save end - private - - def set_path - self.path = Rails.root.join("repos/#{organisation.parameterize}_#{name.parameterize}") - end - - def not_filtered - errors.add(:name, 'filtered') if Rails.application.config.repo_name_deny_list.include?(name) - end - - def reprocess_delayed - delay.reprocess - end - - def reprocess - OrganisationMember.create_all_from_organisation(organisation) - pull_or_clone - process_commits - end - - def process_commits - rugged_repo.tap do |r| - walker = Rugged::Walker.new(r) - r.branches.each { |b| walker.push b.target_id } - walker.each { |c| Commit.from_rugged(c, self) } - end - end - def pull_or_clone if Dir.exist?(path) logger.info("Fetching #{name} and resetting to FETCH_HEAD") @@ -72,6 +44,28 @@ def pull_or_clone end end + def process_commits + rugged_repo.tap do |r| + walker = Rugged::Walker.new(r) + r.branches.each { |b| walker.push b.target_id } + walker.each { |c| Commit.from_rugged(c, self) } + end + end + + private + + def set_path + self.path = Rails.root.join("repos/#{organisation.parameterize}_#{name.parameterize}") + end + + def not_filtered + errors.add(:name, 'filtered') if Rails.application.config.repo_name_deny_list.include?(name) + end + + def reprocess_in_background + RepositoryReprocessJob.perform_later(self) + end + def rugged_repo Rugged::Repository.new(path) end diff --git a/bin/delayed_job b/bin/delayed_job deleted file mode 100755 index edf1959..0000000 --- a/bin/delayed_job +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env ruby - -require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment')) -require 'delayed/command' -Delayed::Command.new(ARGV).daemonize diff --git a/bin/jobs b/bin/jobs new file mode 100755 index 0000000..dcf59f3 --- /dev/null +++ b/bin/jobs @@ -0,0 +1,6 @@ +#!/usr/bin/env ruby + +require_relative "../config/environment" +require "solid_queue/cli" + +SolidQueue::Cli.start(ARGV) diff --git a/config/application.rb b/config/application.rb index 101aaf9..a02903d 100644 --- a/config/application.rb +++ b/config/application.rb @@ -23,7 +23,7 @@ class Application < Rails::Application config.load_defaults 7.2 config.active_support.cache_format_version = 7.1 config.autoload_lib(ignore: %w[assets tasks]) - config.active_job.queue_adapter = :delayed_job + config.active_job.queue_adapter = :solid_queue config.organisations = %w[ZeusWPI 12urenloop] config.repo_name_deny_list = %w[ Bestuurstaakjes diff --git a/config/environments/production.rb b/config/environments/production.rb index c0da809..937b7d5 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -62,8 +62,6 @@ # Use a different cache store in production. # config.cache_store = :mem_cache_store - # Use a real queuing backend for Active Job (and separate queues per environment). - # config.active_job.queue_adapter = :resque # config.active_job.queue_name_prefix = "gamification2_production" # Enable locale fallbacks for I18n (makes lookups for any locale fall back to diff --git a/config/puma.rb b/config/puma.rb index 632d820..ac65cb1 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -28,6 +28,7 @@ # Allow puma to be restarted by `bin/rails restart` command. plugin :tmp_restart +plugin :solid_queue # Only use a pidfile when requested pidfile ENV['PIDFILE'] if ENV['PIDFILE'] diff --git a/config/queue.yml b/config/queue.yml new file mode 100644 index 0000000..47c6814 --- /dev/null +++ b/config/queue.yml @@ -0,0 +1,18 @@ +default: &default + dispatchers: + - polling_interval: 1 + batch_size: 500 + workers: + - queues: "*" + threads: 1 + processes: <%= ENV.fetch("JOB_CONCURRENCY", 1) %> + polling_interval: 0.1 + +development: + <<: *default + +test: + <<: *default + +production: + <<: *default diff --git a/config/recurring.yml b/config/recurring.yml new file mode 100644 index 0000000..d045b19 --- /dev/null +++ b/config/recurring.yml @@ -0,0 +1,10 @@ +# production: +# periodic_cleanup: +# class: CleanSoftDeletedRecordsJob +# queue: background +# args: [ 1000, { batch_size: 500 } ] +# schedule: every hour +# periodic_command: +# command: "SoftDeletedRecord.due.delete_all" +# priority: 2 +# schedule: at 5am every day diff --git a/db/migrate/20241109090736_remove_delayed_job.rb b/db/migrate/20241109090736_remove_delayed_job.rb new file mode 100644 index 0000000..dc611f3 --- /dev/null +++ b/db/migrate/20241109090736_remove_delayed_job.rb @@ -0,0 +1,5 @@ +class RemoveDelayedJob < ActiveRecord::Migration[7.2] + def change + drop_table :delayed_jobs + end +end diff --git a/db/migrate/20241109091236_add_solid_queue_tables.rb b/db/migrate/20241109091236_add_solid_queue_tables.rb new file mode 100644 index 0000000..11f68b6 --- /dev/null +++ b/db/migrate/20241109091236_add_solid_queue_tables.rb @@ -0,0 +1,131 @@ +class AddSolidQueueTables < ActiveRecord::Migration[7.2] + def change + create_table 'solid_queue_blocked_executions', force: :cascade do |t| + t.bigint 'job_id', null: false + t.string 'queue_name', null: false + t.integer 'priority', default: 0, null: false + t.string 'concurrency_key', null: false + t.datetime 'expires_at', null: false + t.datetime 'created_at', null: false + t.index %w[concurrency_key priority job_id], name: 'index_solid_queue_blocked_executions_for_release' + t.index %w[expires_at concurrency_key], name: 'index_solid_queue_blocked_executions_for_maintenance' + t.index ['job_id'], name: 'index_solid_queue_blocked_executions_on_job_id', unique: true + end + + create_table 'solid_queue_claimed_executions', force: :cascade do |t| + t.bigint 'job_id', null: false + t.bigint 'process_id' + t.datetime 'created_at', null: false + t.index ['job_id'], name: 'index_solid_queue_claimed_executions_on_job_id', unique: true + t.index %w[process_id job_id], name: 'index_solid_queue_claimed_executions_on_process_id_and_job_id' + end + + create_table 'solid_queue_failed_executions', force: :cascade do |t| + t.bigint 'job_id', null: false + t.text 'error' + t.datetime 'created_at', null: false + t.index ['job_id'], name: 'index_solid_queue_failed_executions_on_job_id', unique: true + end + + create_table 'solid_queue_jobs', force: :cascade do |t| + t.string 'queue_name', null: false + t.string 'class_name', null: false + t.text 'arguments' + t.integer 'priority', default: 0, null: false + t.string 'active_job_id' + t.datetime 'scheduled_at' + t.datetime 'finished_at' + t.string 'concurrency_key' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.index ['active_job_id'], name: 'index_solid_queue_jobs_on_active_job_id' + t.index ['class_name'], name: 'index_solid_queue_jobs_on_class_name' + t.index ['finished_at'], name: 'index_solid_queue_jobs_on_finished_at' + t.index %w[queue_name finished_at], name: 'index_solid_queue_jobs_for_filtering' + t.index %w[scheduled_at finished_at], name: 'index_solid_queue_jobs_for_alerting' + end + + create_table 'solid_queue_pauses', force: :cascade do |t| + t.string 'queue_name', null: false + t.datetime 'created_at', null: false + t.index ['queue_name'], name: 'index_solid_queue_pauses_on_queue_name', unique: true + end + + create_table 'solid_queue_processes', force: :cascade do |t| + t.string 'kind', null: false + t.datetime 'last_heartbeat_at', null: false + t.bigint 'supervisor_id' + t.integer 'pid', null: false + t.string 'hostname' + t.text 'metadata' + t.datetime 'created_at', null: false + t.string 'name', null: false + t.index ['last_heartbeat_at'], name: 'index_solid_queue_processes_on_last_heartbeat_at' + t.index %w[name supervisor_id], name: 'index_solid_queue_processes_on_name_and_supervisor_id', unique: true + t.index ['supervisor_id'], name: 'index_solid_queue_processes_on_supervisor_id' + end + + create_table 'solid_queue_ready_executions', force: :cascade do |t| + t.bigint 'job_id', null: false + t.string 'queue_name', null: false + t.integer 'priority', default: 0, null: false + t.datetime 'created_at', null: false + t.index ['job_id'], name: 'index_solid_queue_ready_executions_on_job_id', unique: true + t.index %w[priority job_id], name: 'index_solid_queue_poll_all' + t.index %w[queue_name priority job_id], name: 'index_solid_queue_poll_by_queue' + end + + create_table 'solid_queue_recurring_executions', force: :cascade do |t| + t.bigint 'job_id', null: false + t.string 'task_key', null: false + t.datetime 'run_at', null: false + t.datetime 'created_at', null: false + t.index ['job_id'], name: 'index_solid_queue_recurring_executions_on_job_id', unique: true + t.index %w[task_key run_at], name: 'index_solid_queue_recurring_executions_on_task_key_and_run_at', unique: true + end + + create_table 'solid_queue_recurring_tasks', force: :cascade do |t| + t.string 'key', null: false + t.string 'schedule', null: false + t.string 'command', limit: 2048 + t.string 'class_name' + t.text 'arguments' + t.string 'queue_name' + t.integer 'priority', default: 0 + t.boolean 'static', default: true, null: false + t.text 'description' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.index ['key'], name: 'index_solid_queue_recurring_tasks_on_key', unique: true + t.index ['static'], name: 'index_solid_queue_recurring_tasks_on_static' + end + + create_table 'solid_queue_scheduled_executions', force: :cascade do |t| + t.bigint 'job_id', null: false + t.string 'queue_name', null: false + t.integer 'priority', default: 0, null: false + t.datetime 'scheduled_at', null: false + t.datetime 'created_at', null: false + t.index ['job_id'], name: 'index_solid_queue_scheduled_executions_on_job_id', unique: true + t.index %w[scheduled_at priority job_id], name: 'index_solid_queue_dispatch_all' + end + + create_table 'solid_queue_semaphores', force: :cascade do |t| + t.string 'key', null: false + t.integer 'value', default: 1, null: false + t.datetime 'expires_at', null: false + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.index ['expires_at'], name: 'index_solid_queue_semaphores_on_expires_at' + t.index %w[key value], name: 'index_solid_queue_semaphores_on_key_and_value' + t.index ['key'], name: 'index_solid_queue_semaphores_on_key', unique: true + end + + add_foreign_key 'solid_queue_blocked_executions', 'solid_queue_jobs', column: 'job_id', on_delete: :cascade + add_foreign_key 'solid_queue_claimed_executions', 'solid_queue_jobs', column: 'job_id', on_delete: :cascade + add_foreign_key 'solid_queue_failed_executions', 'solid_queue_jobs', column: 'job_id', on_delete: :cascade + add_foreign_key 'solid_queue_ready_executions', 'solid_queue_jobs', column: 'job_id', on_delete: :cascade + add_foreign_key 'solid_queue_recurring_executions', 'solid_queue_jobs', column: 'job_id', on_delete: :cascade + add_foreign_key 'solid_queue_scheduled_executions', 'solid_queue_jobs', column: 'job_id', on_delete: :cascade + end +end diff --git a/db/schema.rb b/db/schema.rb index 34f52e3..4046543 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2022_07_20_145251) do +ActiveRecord::Schema[7.2].define(version: 2024_11_09_091236) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -38,21 +38,6 @@ t.index ["repository_id"], name: "index_commits_on_repository_id" end - create_table "delayed_jobs", force: :cascade do |t| - t.integer "priority", default: 0, null: false - t.integer "attempts", default: 0, null: false - t.text "handler", null: false - t.text "last_error" - t.datetime "run_at" - t.datetime "locked_at" - t.datetime "failed_at" - t.string "locked_by" - t.string "queue" - t.datetime "created_at" - t.datetime "updated_at" - t.index ["priority", "run_at"], name: "delayed_jobs_priority" - end - create_table "git_identities", force: :cascade do |t| t.string "name", null: false t.string "email", null: false @@ -80,7 +65,134 @@ t.index ["organisation", "name"], name: "index_repositories_on_organisation_and_name", unique: true end + create_table "solid_queue_blocked_executions", force: :cascade do |t| + t.bigint "job_id", null: false + t.string "queue_name", null: false + t.integer "priority", default: 0, null: false + t.string "concurrency_key", null: false + t.datetime "expires_at", null: false + t.datetime "created_at", null: false + t.index ["concurrency_key", "priority", "job_id"], name: "index_solid_queue_blocked_executions_for_release" + t.index ["expires_at", "concurrency_key"], name: "index_solid_queue_blocked_executions_for_maintenance" + t.index ["job_id"], name: "index_solid_queue_blocked_executions_on_job_id", unique: true + end + + create_table "solid_queue_claimed_executions", force: :cascade do |t| + t.bigint "job_id", null: false + t.bigint "process_id" + t.datetime "created_at", null: false + t.index ["job_id"], name: "index_solid_queue_claimed_executions_on_job_id", unique: true + t.index ["process_id", "job_id"], name: "index_solid_queue_claimed_executions_on_process_id_and_job_id" + end + + create_table "solid_queue_failed_executions", force: :cascade do |t| + t.bigint "job_id", null: false + t.text "error" + t.datetime "created_at", null: false + t.index ["job_id"], name: "index_solid_queue_failed_executions_on_job_id", unique: true + end + + create_table "solid_queue_jobs", force: :cascade do |t| + t.string "queue_name", null: false + t.string "class_name", null: false + t.text "arguments" + t.integer "priority", default: 0, null: false + t.string "active_job_id" + t.datetime "scheduled_at" + t.datetime "finished_at" + t.string "concurrency_key" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["active_job_id"], name: "index_solid_queue_jobs_on_active_job_id" + t.index ["class_name"], name: "index_solid_queue_jobs_on_class_name" + t.index ["finished_at"], name: "index_solid_queue_jobs_on_finished_at" + t.index ["queue_name", "finished_at"], name: "index_solid_queue_jobs_for_filtering" + t.index ["scheduled_at", "finished_at"], name: "index_solid_queue_jobs_for_alerting" + end + + create_table "solid_queue_pauses", force: :cascade do |t| + t.string "queue_name", null: false + t.datetime "created_at", null: false + t.index ["queue_name"], name: "index_solid_queue_pauses_on_queue_name", unique: true + end + + create_table "solid_queue_processes", force: :cascade do |t| + t.string "kind", null: false + t.datetime "last_heartbeat_at", null: false + t.bigint "supervisor_id" + t.integer "pid", null: false + t.string "hostname" + t.text "metadata" + t.datetime "created_at", null: false + t.string "name", null: false + t.index ["last_heartbeat_at"], name: "index_solid_queue_processes_on_last_heartbeat_at" + t.index ["name", "supervisor_id"], name: "index_solid_queue_processes_on_name_and_supervisor_id", unique: true + t.index ["supervisor_id"], name: "index_solid_queue_processes_on_supervisor_id" + end + + create_table "solid_queue_ready_executions", force: :cascade do |t| + t.bigint "job_id", null: false + t.string "queue_name", null: false + t.integer "priority", default: 0, null: false + t.datetime "created_at", null: false + t.index ["job_id"], name: "index_solid_queue_ready_executions_on_job_id", unique: true + t.index ["priority", "job_id"], name: "index_solid_queue_poll_all" + t.index ["queue_name", "priority", "job_id"], name: "index_solid_queue_poll_by_queue" + end + + create_table "solid_queue_recurring_executions", force: :cascade do |t| + t.bigint "job_id", null: false + t.string "task_key", null: false + t.datetime "run_at", null: false + t.datetime "created_at", null: false + t.index ["job_id"], name: "index_solid_queue_recurring_executions_on_job_id", unique: true + t.index ["task_key", "run_at"], name: "index_solid_queue_recurring_executions_on_task_key_and_run_at", unique: true + end + + create_table "solid_queue_recurring_tasks", force: :cascade do |t| + t.string "key", null: false + t.string "schedule", null: false + t.string "command", limit: 2048 + t.string "class_name" + t.text "arguments" + t.string "queue_name" + t.integer "priority", default: 0 + t.boolean "static", default: true, null: false + t.text "description" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["key"], name: "index_solid_queue_recurring_tasks_on_key", unique: true + t.index ["static"], name: "index_solid_queue_recurring_tasks_on_static" + end + + create_table "solid_queue_scheduled_executions", force: :cascade do |t| + t.bigint "job_id", null: false + t.string "queue_name", null: false + t.integer "priority", default: 0, null: false + t.datetime "scheduled_at", null: false + t.datetime "created_at", null: false + t.index ["job_id"], name: "index_solid_queue_scheduled_executions_on_job_id", unique: true + t.index ["scheduled_at", "priority", "job_id"], name: "index_solid_queue_dispatch_all" + end + + create_table "solid_queue_semaphores", force: :cascade do |t| + t.string "key", null: false + t.integer "value", default: 1, null: false + t.datetime "expires_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["expires_at"], name: "index_solid_queue_semaphores_on_expires_at" + t.index ["key", "value"], name: "index_solid_queue_semaphores_on_key_and_value" + t.index ["key"], name: "index_solid_queue_semaphores_on_key", unique: true + end + add_foreign_key "commits", "coders" add_foreign_key "commits", "repositories" add_foreign_key "git_identities", "coders" + add_foreign_key "solid_queue_blocked_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade + add_foreign_key "solid_queue_claimed_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade + add_foreign_key "solid_queue_failed_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade + add_foreign_key "solid_queue_ready_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade + add_foreign_key "solid_queue_recurring_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade + add_foreign_key "solid_queue_scheduled_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade end diff --git a/db/seeds.rb b/db/seeds.rb index 0b97d91..d1bc160 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -11,6 +11,7 @@ repos = github.repos.list :all, org: org repos.each do |hash| next if hash['private'] + saved = Repository.create_or_update_from_github_api(hash['owner']['login'], hash['name'], hash['html_url'], hash['clone_url']) puts "Creating or updating #{hash['owner']['login']}/#{hash['name']}" if saved end diff --git a/runner.dockerfile b/runner.dockerfile index 32cb704..9d0346e 100644 --- a/runner.dockerfile +++ b/runner.dockerfile @@ -11,4 +11,4 @@ WORKDIR /app COPY . . RUN bundle -CMD bundle exec rails jobs:work +CMD bin/jobs diff --git a/test/jobs/repository_reprocess_job_test.rb b/test/jobs/repository_reprocess_job_test.rb new file mode 100644 index 0000000..d516d8c --- /dev/null +++ b/test/jobs/repository_reprocess_job_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class RepositoryReprocessJobTest < ActiveJob::TestCase + # test "the truth" do + # assert true + # end +end