shipit-engine 0.5.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/shipit/api/cacheable.rb +13 -0
- data/app/controllers/concerns/shipit/api/paginable.rb +37 -0
- data/app/controllers/concerns/shipit/api/rendering.rb +25 -0
- data/app/controllers/concerns/{api/paginable.rb → shipit/pagination.rb} +5 -13
- data/app/controllers/shipit/api/base_controller.rb +68 -0
- data/app/controllers/shipit/api/deploys_controller.rb +17 -0
- data/app/controllers/shipit/api/hooks_controller.rb +53 -0
- data/app/controllers/shipit/api/locks_controller.rb +32 -0
- data/app/controllers/shipit/api/outputs_controller.rb +17 -0
- data/app/controllers/shipit/api/stacks_controller.rb +21 -0
- data/app/controllers/shipit/api/tasks_controller.rb +20 -0
- data/app/controllers/shipit/commit_checks_controller.rb +26 -0
- data/app/controllers/shipit/deploys_controller.rb +47 -0
- data/app/controllers/shipit/github_authentication_controller.rb +27 -0
- data/app/controllers/shipit/rollbacks_controller.rb +26 -0
- data/app/controllers/shipit/shipit_controller.rb +62 -0
- data/app/controllers/shipit/stacks_controller.rb +81 -0
- data/app/controllers/shipit/status_controller.rb +7 -0
- data/app/controllers/shipit/tasks_controller.rb +48 -0
- data/app/controllers/shipit/webhooks_controller.rb +101 -0
- data/app/helpers/shipit/chunks_helper.rb +8 -0
- data/app/helpers/shipit/deploys_helper.rb +28 -0
- data/app/helpers/shipit/github_url_helper.rb +48 -0
- data/app/helpers/shipit/shipit_helper.rb +64 -0
- data/app/helpers/shipit/stacks_helper.rb +78 -0
- data/app/helpers/shipit/tasks_helper.rb +11 -0
- data/app/jobs/shipit/background_job.rb +24 -0
- data/app/jobs/shipit/background_job/unique.rb +28 -0
- data/app/jobs/shipit/cache_deploy_spec_job.rb +12 -0
- data/app/jobs/shipit/chunk_rollup_job.rb +21 -0
- data/app/jobs/shipit/clear_git_cache_job.rb +9 -0
- data/app/jobs/shipit/deliver_hook_job.rb +9 -0
- data/app/jobs/shipit/destroy_stack_job.rb +9 -0
- data/app/jobs/shipit/emit_event_job.rb +10 -0
- data/app/jobs/shipit/fetch_commit_stats_job.rb +9 -0
- data/app/jobs/shipit/fetch_deployed_revision_job.rb +23 -0
- data/app/jobs/shipit/git_mirror_update_job.rb +12 -0
- data/app/jobs/shipit/github_sync_job.rb +55 -0
- data/app/jobs/shipit/perform_commit_checks_job.rb +7 -0
- data/app/jobs/shipit/perform_task_job.rb +57 -0
- data/app/jobs/shipit/refresh_github_user_job.rb +9 -0
- data/app/jobs/shipit/refresh_statuses_job.rb +14 -0
- data/app/jobs/shipit/setup_github_hook_job.rb +11 -0
- data/app/models/shipit/anonymous_user.rb +43 -0
- data/app/models/shipit/api_client.rb +44 -0
- data/app/models/shipit/commit.rb +209 -0
- data/app/models/shipit/commit_checks.rb +90 -0
- data/app/models/shipit/delivery.rb +47 -0
- data/app/models/shipit/deploy.rb +153 -0
- data/app/models/shipit/deploy_spec.rb +150 -0
- data/app/models/shipit/deploy_spec/bundler_discovery.rb +61 -0
- data/app/models/shipit/deploy_spec/capistrano_discovery.rb +29 -0
- data/app/models/shipit/deploy_spec/file_system.rb +64 -0
- data/app/models/shipit/deploy_spec/pypi_discovery.rb +34 -0
- data/app/models/shipit/deploy_spec/rubygems_discovery.rb +34 -0
- data/app/models/shipit/github_hook.rb +148 -0
- data/app/models/shipit/hook.rb +86 -0
- data/app/models/shipit/membership.rb +8 -0
- data/app/models/shipit/missing_status.rb +21 -0
- data/app/models/shipit/output_chunk.rb +11 -0
- data/app/models/shipit/rollback.rb +31 -0
- data/app/models/shipit/stack.rb +308 -0
- data/app/models/shipit/status.rb +44 -0
- data/app/models/shipit/status_group.rb +35 -0
- data/app/models/shipit/task.rb +201 -0
- data/app/models/shipit/task_definition.rb +38 -0
- data/app/models/shipit/team.rb +69 -0
- data/app/models/shipit/unknown_status.rb +43 -0
- data/app/models/shipit/user.rb +83 -0
- data/app/models/shipit/variable_definition.rb +21 -0
- data/app/serializers/concerns/shipit/conditional_attributes.rb +22 -0
- data/app/serializers/shipit/anonymous_user_serializer.rb +4 -0
- data/app/serializers/shipit/commit_serializer.rb +8 -0
- data/app/serializers/shipit/deploy_serializer.rb +15 -0
- data/app/serializers/shipit/hook_serializer.rb +12 -0
- data/app/serializers/shipit/rollback_serializer.rb +7 -0
- data/app/serializers/shipit/short_commit_serializer.rb +9 -0
- data/app/serializers/shipit/stack_serializer.rb +33 -0
- data/app/serializers/shipit/tail_task_serializer.rb +39 -0
- data/app/serializers/shipit/task_serializer.rb +30 -0
- data/app/serializers/shipit/user_serializer.rb +5 -0
- data/app/views/{commits → shipit/commits}/_commit.html.erb +1 -1
- data/app/views/{commits → shipit/commits}/_commit_author.html.erb +0 -0
- data/app/views/{deploys → shipit/deploys}/_checklist.html.erb +0 -0
- data/app/views/{deploys → shipit/deploys}/_checks.html.erb +0 -0
- data/app/views/{deploys → shipit/deploys}/_concurrent_deploy_warning.html.erb +0 -0
- data/app/views/{deploys → shipit/deploys}/_deploy.html.erb +1 -1
- data/app/views/{deploys → shipit/deploys}/_monitoring.html.erb +0 -0
- data/app/views/{deploys → shipit/deploys}/_summary.html.erb +0 -0
- data/app/views/{deploys → shipit/deploys}/new.html.erb +3 -3
- data/app/views/{deploys → shipit/deploys}/rollback.html.erb +2 -2
- data/app/views/{deploys → shipit/deploys}/show.html.erb +1 -1
- data/app/views/{github_authentication → shipit/github_authentication}/failed.html.erb +0 -0
- data/app/views/{stacks → shipit/stacks}/_header.html.erb +0 -0
- data/app/views/{stacks → shipit/stacks}/index.html.erb +0 -0
- data/app/views/{stacks → shipit/stacks}/new.html.erb +0 -0
- data/app/views/{stacks → shipit/stacks}/settings.html.erb +1 -1
- data/app/views/{stacks → shipit/stacks}/show.html.erb +2 -2
- data/app/views/{statuses → shipit/statuses}/_group.html.erb +1 -1
- data/app/views/{statuses → shipit/statuses}/_status.html.erb +0 -0
- data/app/views/{tasks → shipit/tasks}/_task.html.erb +1 -1
- data/app/views/{tasks → shipit/tasks}/_task_output.html.erb +1 -1
- data/app/views/{tasks → shipit/tasks}/index.html.erb +1 -1
- data/app/views/{tasks → shipit/tasks}/new.html.erb +1 -1
- data/app/views/{tasks → shipit/tasks}/show.html.erb +1 -1
- data/db/migrate/20160104151742_increase_tasks_type_size_back.rb +5 -0
- data/db/migrate/20160104151833_convert_sti_columns.rb +10 -0
- data/lib/shipit.rb +11 -10
- data/lib/shipit/command.rb +171 -0
- data/lib/shipit/commands.rb +25 -0
- data/lib/shipit/deploy_commands.rb +21 -0
- data/lib/shipit/engine.rb +3 -0
- data/lib/shipit/rollback_commands.rb +7 -0
- data/lib/shipit/stack_commands.rb +60 -0
- data/lib/shipit/task_commands.rb +68 -0
- data/lib/shipit/version.rb +1 -1
- data/lib/tasks/cron.rake +3 -3
- data/test/controllers/api/base_controller_test.rb +18 -14
- data/test/controllers/api/deploys_controller_test.rb +56 -52
- data/test/controllers/api/hooks_controller_test.rb +62 -58
- data/test/controllers/api/locks_controller_test.rb +38 -34
- data/test/controllers/api/outputs_controller_test.rb +15 -11
- data/test/controllers/api/stacks_controller_test.rb +56 -52
- data/test/controllers/api/tasks_controller_test.rb +30 -26
- data/test/controllers/commit_checks_controller_test.rb +29 -27
- data/test/controllers/deploys_controller_test.rb +68 -66
- data/test/controllers/github_authentication_controller_test.rb +9 -7
- data/test/controllers/rollbacks_controller_test.rb +43 -41
- data/test/controllers/stacks_controller_test.rb +131 -128
- data/test/controllers/status_controller_test.rb +8 -6
- data/test/controllers/tasks_controller_test.rb +70 -68
- data/test/controllers/webhooks_controller_test.rb +127 -125
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/schema.rb +2 -2
- data/test/dummy/db/seeds.rb +133 -131
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/fixtures/{api_clients.yml → shipit/api_clients.yml} +0 -0
- data/test/fixtures/{commits.yml → shipit/commits.yml} +0 -0
- data/test/fixtures/{deliveries.yml → shipit/deliveries.yml} +0 -0
- data/test/fixtures/{github_hooks.yml → shipit/github_hooks.yml} +4 -4
- data/test/fixtures/{hooks.yml → shipit/hooks.yml} +0 -0
- data/test/fixtures/{memberships.yml → shipit/memberships.yml} +0 -0
- data/test/fixtures/{output_chunks.yml → shipit/output_chunks.yml} +0 -0
- data/test/fixtures/{stacks.yml → shipit/stacks.yml} +0 -0
- data/test/fixtures/{statuses.yml → shipit/statuses.yml} +0 -0
- data/test/fixtures/{tasks.yml → shipit/tasks.yml} +8 -8
- data/test/fixtures/{teams.yml → shipit/teams.yml} +0 -0
- data/test/fixtures/{users.yml → shipit/users.yml} +0 -0
- data/test/helpers/api_helper.rb +1 -1
- data/test/helpers/fixture_aliases_helper.rb +4 -4
- data/test/jobs/cache_deploy_spec_job_test.rb +15 -13
- data/test/jobs/chunk_rollup_job_test.rb +30 -28
- data/test/jobs/deliver_hook_job_test.rb +11 -9
- data/test/jobs/destroy_stack_job_test.rb +11 -9
- data/test/jobs/emit_event_job_test.rb +10 -8
- data/test/jobs/fetch_commit_stats_job_test.rb +10 -8
- data/test/jobs/fetch_deployed_revision_job_test.rb +24 -22
- data/test/jobs/github_sync_job_test.rb +51 -49
- data/test/jobs/perform_task_job_test.rb +78 -76
- data/test/jobs/refresh_github_user_job_test.rb +10 -8
- data/test/jobs/refresh_status_job_test.rb +14 -12
- data/test/jobs/unique_job_test.rb +18 -15
- data/test/models/api_client_test.rb +20 -18
- data/test/models/commit_checks_test.rb +63 -61
- data/test/models/commits_test.rb +317 -314
- data/test/models/delivery_test.rb +29 -27
- data/test/models/deploys_test.rb +289 -287
- data/test/models/github_hook_test.rb +45 -43
- data/test/models/hook_test.rb +44 -42
- data/test/models/membership_test.rb +9 -7
- data/test/models/missing_status_test.rb +16 -14
- data/test/models/output_chunk_test.rb +14 -12
- data/test/models/rollbacks_test.rb +14 -12
- data/test/models/stacks_test.rb +272 -270
- data/test/models/status_group_test.rb +18 -16
- data/test/models/status_test.rb +42 -40
- data/test/models/task_definitions_test.rb +27 -25
- data/test/models/team_test.rb +39 -37
- data/test/models/users_test.rb +61 -59
- data/test/unit/command_test.rb +43 -41
- data/test/unit/commands_test.rb +8 -6
- data/test/unit/csv_serializer_test.rb +28 -26
- data/test/unit/deploy_commands_test.rb +179 -176
- data/test/unit/deploy_spec_test.rb +237 -235
- data/test/unit/github_url_helper_test.rb +19 -17
- data/test/unit/shipit_test.rb +44 -42
- metadata +139 -137
- data/app/controllers/api/base_controller.rb +0 -66
- data/app/controllers/api/deploys_controller.rb +0 -15
- data/app/controllers/api/hooks_controller.rb +0 -51
- data/app/controllers/api/locks_controller.rb +0 -30
- data/app/controllers/api/outputs_controller.rb +0 -15
- data/app/controllers/api/stacks_controller.rb +0 -19
- data/app/controllers/api/tasks_controller.rb +0 -18
- data/app/controllers/commit_checks_controller.rb +0 -24
- data/app/controllers/concerns/api/cacheable.rb +0 -11
- data/app/controllers/concerns/api/rendering.rb +0 -23
- data/app/controllers/concerns/pagination.rb +0 -25
- data/app/controllers/deploys_controller.rb +0 -45
- data/app/controllers/github_authentication_controller.rb +0 -25
- data/app/controllers/rollbacks_controller.rb +0 -24
- data/app/controllers/shipit_controller.rb +0 -54
- data/app/controllers/stacks_controller.rb +0 -79
- data/app/controllers/status_controller.rb +0 -5
- data/app/controllers/tasks_controller.rb +0 -46
- data/app/controllers/webhooks_controller.rb +0 -99
- data/app/helpers/chunks_helper.rb +0 -6
- data/app/helpers/deploys_helper.rb +0 -26
- data/app/helpers/github_url_helper.rb +0 -46
- data/app/helpers/shipit_helper.rb +0 -62
- data/app/helpers/stacks_helper.rb +0 -76
- data/app/helpers/tasks_helper.rb +0 -9
- data/app/jobs/background_job.rb +0 -22
- data/app/jobs/background_job/unique.rb +0 -26
- data/app/jobs/cache_deploy_spec_job.rb +0 -10
- data/app/jobs/chunk_rollup_job.rb +0 -19
- data/app/jobs/clear_git_cache_job.rb +0 -7
- data/app/jobs/deliver_hook_job.rb +0 -7
- data/app/jobs/destroy_stack_job.rb +0 -7
- data/app/jobs/emit_event_job.rb +0 -8
- data/app/jobs/fetch_commit_stats_job.rb +0 -7
- data/app/jobs/fetch_deployed_revision_job.rb +0 -21
- data/app/jobs/git_mirror_update_job.rb +0 -10
- data/app/jobs/github_sync_job.rb +0 -53
- data/app/jobs/perform_commit_checks_job.rb +0 -5
- data/app/jobs/perform_task_job.rb +0 -55
- data/app/jobs/refresh_github_user_job.rb +0 -7
- data/app/jobs/refresh_statuses_job.rb +0 -12
- data/app/jobs/setup_github_hook_job.rb +0 -9
- data/app/models/anonymous_user.rb +0 -41
- data/app/models/api_client.rb +0 -42
- data/app/models/commit.rb +0 -207
- data/app/models/commit_checks.rb +0 -88
- data/app/models/delivery.rb +0 -45
- data/app/models/deploy.rb +0 -151
- data/app/models/deploy_spec.rb +0 -148
- data/app/models/deploy_spec/bundler_discovery.rb +0 -59
- data/app/models/deploy_spec/capistrano_discovery.rb +0 -27
- data/app/models/deploy_spec/file_system.rb +0 -62
- data/app/models/deploy_spec/pypi_discovery.rb +0 -32
- data/app/models/deploy_spec/rubygems_discovery.rb +0 -32
- data/app/models/github_hook.rb +0 -144
- data/app/models/hook.rb +0 -84
- data/app/models/membership.rb +0 -6
- data/app/models/missing_status.rb +0 -18
- data/app/models/output_chunk.rb +0 -9
- data/app/models/rollback.rb +0 -29
- data/app/models/stack.rb +0 -306
- data/app/models/status.rb +0 -42
- data/app/models/status_group.rb +0 -33
- data/app/models/task.rb +0 -197
- data/app/models/task_definition.rb +0 -36
- data/app/models/team.rb +0 -67
- data/app/models/unknown_status.rb +0 -41
- data/app/models/user.rb +0 -81
- data/app/models/variable_definition.rb +0 -19
- data/app/serializers/anonymous_user_serializer.rb +0 -2
- data/app/serializers/commit_serializer.rb +0 -6
- data/app/serializers/concerns/conditional_attributes.rb +0 -20
- data/app/serializers/deploy_serializer.rb +0 -13
- data/app/serializers/hook_serializer.rb +0 -10
- data/app/serializers/rollback_serializer.rb +0 -5
- data/app/serializers/short_commit_serializer.rb +0 -7
- data/app/serializers/stack_serializer.rb +0 -31
- data/app/serializers/tail_task_serializer.rb +0 -37
- data/app/serializers/task_serializer.rb +0 -28
- data/app/serializers/user_serializer.rb +0 -3
- data/lib/command.rb +0 -169
- data/lib/commands.rb +0 -23
- data/lib/deploy_commands.rb +0 -19
- data/lib/rollback_commands.rb +0 -5
- data/lib/stack_commands.rb +0 -58
- data/lib/task_commands.rb +0 -66
@@ -1,79 +0,0 @@
|
|
1
|
-
class StacksController < ShipitController
|
2
|
-
before_action :load_stack, only: %i(update destroy settings sync_webhooks clear_git_cache refresh)
|
3
|
-
|
4
|
-
def new
|
5
|
-
@stack = Stack.new
|
6
|
-
end
|
7
|
-
|
8
|
-
def index
|
9
|
-
@user_stacks = current_user.stacks_contributed_to
|
10
|
-
|
11
|
-
@stacks = Stack.order('(undeployed_commits_count > 0) desc', tasks_count: :desc).to_a
|
12
|
-
end
|
13
|
-
|
14
|
-
def show
|
15
|
-
@stack = Stack.from_param!(params[:id])
|
16
|
-
return if flash.empty? && !stale?(last_modified: @stack.updated_at)
|
17
|
-
|
18
|
-
@tasks = @stack.tasks.order(id: :desc).preload(:since_commit, :until_commit, :user).limit(10)
|
19
|
-
@commits = @stack.commits.reachable.preload(:author, :statuses).order(id: :desc)
|
20
|
-
if deployed_commit = @stack.last_deployed_commit
|
21
|
-
@commits = @commits.where('id > ?', deployed_commit.id)
|
22
|
-
end
|
23
|
-
@commits = @commits.to_a
|
24
|
-
end
|
25
|
-
|
26
|
-
def create
|
27
|
-
@stack = Stack.create(create_params)
|
28
|
-
respond_with(@stack)
|
29
|
-
end
|
30
|
-
|
31
|
-
def destroy
|
32
|
-
@stack.schedule_for_destroy!
|
33
|
-
redirect_to stacks_url
|
34
|
-
end
|
35
|
-
|
36
|
-
def settings
|
37
|
-
end
|
38
|
-
|
39
|
-
def refresh
|
40
|
-
RefreshStatusesJob.perform_later(stack_id: @stack.id)
|
41
|
-
GithubSyncJob.perform_later(stack_id: @stack.id)
|
42
|
-
flash[:success] = 'Refresh scheduled'
|
43
|
-
redirect_to :back
|
44
|
-
end
|
45
|
-
|
46
|
-
def update
|
47
|
-
options = {}
|
48
|
-
unless @stack.update(update_params)
|
49
|
-
options = {flash: {warning: @stack.errors.full_messages.to_sentence}}
|
50
|
-
end
|
51
|
-
redirect_to(params[:return_to].presence || stack_settings_path(@stack), options)
|
52
|
-
end
|
53
|
-
|
54
|
-
def sync_webhooks
|
55
|
-
@stack.setup_hooks
|
56
|
-
redirect_to stack_settings_path(@stack)
|
57
|
-
end
|
58
|
-
|
59
|
-
def clear_git_cache
|
60
|
-
ClearGitCacheJob.perform_later(@stack)
|
61
|
-
redirect_to stack_settings_path(@stack)
|
62
|
-
end
|
63
|
-
|
64
|
-
private
|
65
|
-
|
66
|
-
def load_stack
|
67
|
-
@stack = Stack.from_param!(params[:id])
|
68
|
-
end
|
69
|
-
|
70
|
-
def create_params
|
71
|
-
params.require(:stack).permit(:repo_name, :repo_owner, :environment, :branch, :deploy_url, :ignore_ci)
|
72
|
-
end
|
73
|
-
|
74
|
-
def update_params
|
75
|
-
params.require(:stack).permit(:deploy_url, :lock_reason, :continuous_deployment, :ignore_ci).tap do |params|
|
76
|
-
params[:lock_author_id] = params[:lock_reason].present? ? current_user.id : nil
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
class TasksController < ShipitController
|
2
|
-
include Pagination
|
3
|
-
|
4
|
-
before_action :stack
|
5
|
-
|
6
|
-
self.default_page_size = 20
|
7
|
-
|
8
|
-
def index
|
9
|
-
paginator = paginate(stack.tasks)
|
10
|
-
@tasks = paginator.to_a
|
11
|
-
@links = paginator.links
|
12
|
-
end
|
13
|
-
|
14
|
-
def new
|
15
|
-
@definition = stack.find_task_definition(params[:definition_id])
|
16
|
-
@task = stack.tasks.build(definition: @definition)
|
17
|
-
end
|
18
|
-
|
19
|
-
def show
|
20
|
-
task
|
21
|
-
end
|
22
|
-
|
23
|
-
def create
|
24
|
-
@task = stack.trigger_task(params[:definition_id], current_user)
|
25
|
-
redirect_to [stack, @task]
|
26
|
-
end
|
27
|
-
|
28
|
-
def abort
|
29
|
-
task.abort!(rollback_once_aborted: params[:rollback].present?)
|
30
|
-
head :ok
|
31
|
-
end
|
32
|
-
|
33
|
-
def tail
|
34
|
-
render json: TailTaskSerializer.new(task, context: params)
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
def task
|
40
|
-
@task ||= stack.tasks.find(params[:id])
|
41
|
-
end
|
42
|
-
|
43
|
-
def stack
|
44
|
-
@stack ||= Stack.from_param!(params[:stack_id])
|
45
|
-
end
|
46
|
-
end
|
@@ -1,99 +0,0 @@
|
|
1
|
-
class WebhooksController < ActionController::Base
|
2
|
-
before_action :check_if_ping, :verify_signature
|
3
|
-
|
4
|
-
respond_to :json
|
5
|
-
|
6
|
-
def push
|
7
|
-
branch = params['ref'].gsub('refs/heads/', '')
|
8
|
-
|
9
|
-
if branch == stack.branch
|
10
|
-
GithubSyncJob.perform_later(stack_id: stack.id)
|
11
|
-
GitMirrorUpdateJob.perform_later(stack)
|
12
|
-
end
|
13
|
-
|
14
|
-
head :ok
|
15
|
-
end
|
16
|
-
|
17
|
-
def state
|
18
|
-
branches = params[:branches] || []
|
19
|
-
if branches.find { |branch| branch[:name] == stack.branch }
|
20
|
-
commit = stack.commits.find_by_sha!(params[:sha])
|
21
|
-
commit.add_status(params.permit(:state, :description, :target_url, :context, :created_at))
|
22
|
-
end
|
23
|
-
head :ok
|
24
|
-
end
|
25
|
-
|
26
|
-
params do
|
27
|
-
requires :team do
|
28
|
-
requires :id, Integer
|
29
|
-
requires :name, String
|
30
|
-
requires :slug, String
|
31
|
-
requires :url, String
|
32
|
-
end
|
33
|
-
requires :organization do
|
34
|
-
requires :login, String
|
35
|
-
end
|
36
|
-
requires :member do
|
37
|
-
requires :login, String
|
38
|
-
end
|
39
|
-
end
|
40
|
-
def membership
|
41
|
-
team = find_or_create_team!
|
42
|
-
member = User.find_or_create_by_login!(params.member.login)
|
43
|
-
|
44
|
-
case membership_action
|
45
|
-
when 'added'
|
46
|
-
team.add_member(member)
|
47
|
-
when 'removed'
|
48
|
-
team.members.delete(member)
|
49
|
-
else
|
50
|
-
raise ArgumentError, "Don't know how to perform action: `#{params.action.inspect}`"
|
51
|
-
end
|
52
|
-
head :ok
|
53
|
-
end
|
54
|
-
|
55
|
-
def index
|
56
|
-
render text: "working"
|
57
|
-
end
|
58
|
-
|
59
|
-
private
|
60
|
-
|
61
|
-
def find_or_create_team!
|
62
|
-
Team.find_or_create_by!(github_id: params.team.id) do |team|
|
63
|
-
team.github_team = params.team
|
64
|
-
team.organization = params.organization.login
|
65
|
-
team.automatically_setup_hooks = true
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def verify_signature
|
70
|
-
request.body.rewind
|
71
|
-
head(422) unless webhook.verify_signature(request.headers['X-Hub-Signature'], request.body.read)
|
72
|
-
end
|
73
|
-
|
74
|
-
def check_if_ping
|
75
|
-
head :ok if event == 'ping'
|
76
|
-
end
|
77
|
-
|
78
|
-
def webhook
|
79
|
-
@webhook ||= if params[:stack_id]
|
80
|
-
stack.github_hooks.find_by!(event: event)
|
81
|
-
else
|
82
|
-
GithubHook::Organization.find_by!(organization: params.organization.login, event: event)
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def event
|
87
|
-
request.headers['X-Github-Event'] || action_name
|
88
|
-
end
|
89
|
-
|
90
|
-
def membership_action
|
91
|
-
# GitHub send an `action` parameter that is shadowed by Rails url parameters
|
92
|
-
# It's also impossible to pass an `action` parameters from a test case.
|
93
|
-
request.request_parameters['action'] || params[:_action]
|
94
|
-
end
|
95
|
-
|
96
|
-
def stack
|
97
|
-
@stack ||= Stack.find(params[:stack_id])
|
98
|
-
end
|
99
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module DeploysHelper
|
2
|
-
def render_checklist(checklist)
|
3
|
-
return if checklist.blank?
|
4
|
-
render 'deploys/checklist', checklist: checklist
|
5
|
-
end
|
6
|
-
|
7
|
-
def render_monitoring(stack)
|
8
|
-
return unless stack.monitoring?
|
9
|
-
render 'deploys/monitoring', stack: stack
|
10
|
-
end
|
11
|
-
|
12
|
-
def render_checks(commit)
|
13
|
-
return unless commit.stack.checks?
|
14
|
-
render 'deploys/checks', commit: commit
|
15
|
-
end
|
16
|
-
|
17
|
-
def render_monitoring_panel(panel_spec)
|
18
|
-
if url = panel_spec['image']
|
19
|
-
image_tag(url, panel_spec.slice('height', 'width', 'alt'))
|
20
|
-
elsif url = panel_spec['iframe']
|
21
|
-
content_tag(:iframe, '', panel_spec.slice('height', 'width').merge('src' => url))
|
22
|
-
else
|
23
|
-
content_tag(:span, "#{panel_spec.inspect} is not a valid monitoring panel spec")
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
module GithubUrlHelper
|
2
|
-
def github_avatar(user, options = {})
|
3
|
-
uri = user.avatar_uri
|
4
|
-
attributes = options.slice(:class).merge(alt: user.try!(:name))
|
5
|
-
if options[:size]
|
6
|
-
uri.query ||= ''
|
7
|
-
uri.query += "&s=#{options[:size]}"
|
8
|
-
attributes[:width] = options[:size]
|
9
|
-
attributes[:height] = options[:size]
|
10
|
-
end
|
11
|
-
|
12
|
-
image_tag(uri.to_s, attributes)
|
13
|
-
end
|
14
|
-
|
15
|
-
def github_commit_range_url(stack, since_commit, until_commit)
|
16
|
-
github_repo_url(stack.repo_owner, stack.repo_name, 'compare', "#{since_commit.sha}...#{until_commit.sha}")
|
17
|
-
end
|
18
|
-
|
19
|
-
def github_user_url(user, *args)
|
20
|
-
[Shipit.github_url, user, *args].join('/')
|
21
|
-
end
|
22
|
-
|
23
|
-
def render_github_user(user)
|
24
|
-
link_to(github_user_url(user.login), class: 'user main-user') do
|
25
|
-
github_avatar(user, size: 20) + user.name
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def github_repo_url(owner, repo, *args)
|
30
|
-
github_user_url(owner, repo, *args)
|
31
|
-
end
|
32
|
-
|
33
|
-
def github_commit_url(commit)
|
34
|
-
github_repo_url(commit.stack.repo_owner, commit.stack.repo_name, 'commit', commit.sha)
|
35
|
-
end
|
36
|
-
|
37
|
-
def github_diff_url(owner, repo, from_sha, to_sha)
|
38
|
-
github_repo_url(owner, repo, 'compare', "#{from_sha}...#{to_sha}")
|
39
|
-
end
|
40
|
-
|
41
|
-
def link_to_github_deploy(deploy)
|
42
|
-
url = github_commit_range_url(deploy.stack, *deploy.commit_range)
|
43
|
-
text = deploy.commit_range.map(&:short_sha).join('...')
|
44
|
-
link_to(text, url, class: 'number')
|
45
|
-
end
|
46
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
module ShipitHelper
|
2
|
-
def include_plugins(stack)
|
3
|
-
stack.plugins.flat_map do |plugin, config|
|
4
|
-
plugin_tags(plugin, config)
|
5
|
-
end.join.html_safe
|
6
|
-
end
|
7
|
-
|
8
|
-
def plugin_tags(plugin, config)
|
9
|
-
tags = []
|
10
|
-
tags << tag('meta', name: "#{plugin}-config", content: config.to_json) if config
|
11
|
-
tags << javascript_include_tag("plugins/#{plugin}")
|
12
|
-
tags << stylesheet_link_tag("plugins/#{plugin}")
|
13
|
-
tags
|
14
|
-
end
|
15
|
-
|
16
|
-
def missing_github_oauth_message
|
17
|
-
(<<-MESSAGE).html_safe
|
18
|
-
Shipit requires a GitHub application to authenticate users.
|
19
|
-
If you haven't created an application on GitHub yet, you can do so in the
|
20
|
-
#{link_to 'Settings', Shipit.github_url('/settings/applications/new'), target: '_blank'}
|
21
|
-
section of your profile. You can also create applications for organizations.
|
22
|
-
MESSAGE
|
23
|
-
end
|
24
|
-
|
25
|
-
def missing_github_oauth_id_message
|
26
|
-
(<<-MESSAGE).html_safe
|
27
|
-
Copy the Client ID from your GitHub application,
|
28
|
-
and paste it into the secrets.yml file under <code>github_oauth.id</code>.
|
29
|
-
MESSAGE
|
30
|
-
end
|
31
|
-
|
32
|
-
def missing_github_oauth_secret_message
|
33
|
-
(<<-MESSAGE).html_safe
|
34
|
-
Copy the Client Secret from your GitHub application,
|
35
|
-
and paste it into the secrets.yml file under <code>github_oauth.secret</code>.
|
36
|
-
MESSAGE
|
37
|
-
end
|
38
|
-
|
39
|
-
def missing_github_api_credentials_message
|
40
|
-
(<<-MESSAGE).html_safe
|
41
|
-
Shipit needs API access to GitHub. You can
|
42
|
-
#{link_to 'create an access token', Shipit.github_url('/settings/tokens'), target: '_blank'}
|
43
|
-
with the following permissions:
|
44
|
-
<code>admin:repo_hook</code>, <code>admin:org_hook</code> and <code>repo</code>
|
45
|
-
and add it to the secrets.yml file under the key <code>github_api.access_token</code>.
|
46
|
-
MESSAGE
|
47
|
-
end
|
48
|
-
|
49
|
-
def missing_redis_url_message
|
50
|
-
(<<-MESSAGE).html_safe
|
51
|
-
Shipit needs a Redis server. Please configure the Redis URL in the secrets.yml file of your app,
|
52
|
-
under the key <code>redis_url</code>.
|
53
|
-
MESSAGE
|
54
|
-
end
|
55
|
-
|
56
|
-
def missing_host_message
|
57
|
-
(<<-MESSAGE).html_safe
|
58
|
-
Shipit needs the host of the application before generating links in background jobs.
|
59
|
-
Add the host name to the secrets.yml file, under the <code>host</code> key.
|
60
|
-
MESSAGE
|
61
|
-
end
|
62
|
-
end
|
@@ -1,76 +0,0 @@
|
|
1
|
-
module StacksHelper
|
2
|
-
COMMIT_TITLE_LENGTH = 79
|
3
|
-
|
4
|
-
def redeploy_button(commit)
|
5
|
-
url = new_stack_deploy_path(@stack, sha: commit.sha)
|
6
|
-
classes = %W(btn btn--primary deploy-action #{commit.state})
|
7
|
-
|
8
|
-
unless commit.stack.deployable?
|
9
|
-
classes.push(ignore_lock? ? 'btn--warning' : 'btn--disabled')
|
10
|
-
end
|
11
|
-
|
12
|
-
caption = 'Redeploy'
|
13
|
-
caption = 'Locked' if commit.stack.locked? && !ignore_lock?
|
14
|
-
caption = 'Deploy in progress...' if commit.stack.deploying?
|
15
|
-
|
16
|
-
link_to(caption, url, class: classes)
|
17
|
-
end
|
18
|
-
|
19
|
-
def ignore_lock?
|
20
|
-
params[:force].present?
|
21
|
-
end
|
22
|
-
|
23
|
-
def deploy_button(commit)
|
24
|
-
url = new_stack_deploy_path(@stack, sha: commit.sha)
|
25
|
-
classes = %W(btn btn--primary deploy-action #{commit.state})
|
26
|
-
if deploy_button_disabled?(commit)
|
27
|
-
classes.push(params[:force].present? ? 'btn--warning' : 'btn--disabled')
|
28
|
-
end
|
29
|
-
|
30
|
-
link_to(deploy_button_caption(commit), url, class: classes)
|
31
|
-
end
|
32
|
-
|
33
|
-
def github_change_url(commit)
|
34
|
-
commit.pull_request_url || github_commit_url(commit)
|
35
|
-
end
|
36
|
-
|
37
|
-
def render_commit_message(commit)
|
38
|
-
message = commit.pull_request_title || commit.message
|
39
|
-
content_tag(:span, message.truncate(COMMIT_TITLE_LENGTH), class: 'event-message')
|
40
|
-
end
|
41
|
-
|
42
|
-
def render_commit_message_with_link(commit)
|
43
|
-
link_to(render_commit_message(commit), github_change_url(commit), target: '_blank')
|
44
|
-
end
|
45
|
-
|
46
|
-
def render_commit_id_link(commit)
|
47
|
-
if commit.pull_request?
|
48
|
-
pull_request_link(commit) + " (#{render_raw_commit_id_link(commit)})".html_safe
|
49
|
-
else
|
50
|
-
render_raw_commit_id_link(commit)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def pull_request_link(commit)
|
55
|
-
link_to("##{commit.pull_request_id}", commit.pull_request_url, target: '_blank', class: 'number')
|
56
|
-
end
|
57
|
-
|
58
|
-
def render_raw_commit_id_link(commit)
|
59
|
-
link_to(commit.short_sha, github_commit_url(commit), target: '_blank', class: 'number')
|
60
|
-
end
|
61
|
-
|
62
|
-
private
|
63
|
-
|
64
|
-
def deploy_button_disabled?(commit)
|
65
|
-
!commit.deployable? || !commit.stack.deployable?
|
66
|
-
end
|
67
|
-
|
68
|
-
def deploy_button_caption(commit)
|
69
|
-
state = commit.status.state
|
70
|
-
state = 'locked' if commit.stack.locked? && !ignore_lock?
|
71
|
-
if commit.deployable?
|
72
|
-
state = commit.stack.deploying? ? 'deploying' : 'enabled'
|
73
|
-
end
|
74
|
-
t("deploy_button.caption.#{state}")
|
75
|
-
end
|
76
|
-
end
|