shipit-engine 0.33.0 → 0.34.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -2
- data/app/assets/stylesheets/_pages/_deploy.scss +0 -2
- data/app/controllers/shipit/api/ccmenu_controller.rb +1 -1
- data/app/controllers/shipit/api/deploys_controller.rb +2 -0
- data/app/controllers/shipit/api/rollbacks_controller.rb +2 -1
- data/app/controllers/shipit/api/stacks_controller.rb +1 -0
- data/app/controllers/shipit/deploys_controller.rb +1 -1
- data/app/controllers/shipit/stacks_controller.rb +2 -2
- data/app/controllers/shipit/tasks_controller.rb +2 -2
- data/app/controllers/shipit/webhooks_controller.rb +23 -4
- data/app/helpers/shipit/shipit_helper.rb +0 -1
- data/app/jobs/shipit/deliver_hook_job.rb +1 -1
- data/app/jobs/shipit/github_sync_job.rb +13 -9
- data/app/jobs/shipit/update_github_last_deployed_ref_job.rb +1 -1
- data/app/models/shipit/anonymous_user.rb +6 -2
- data/app/models/shipit/check_run.rb +36 -0
- data/app/models/shipit/commit.rb +20 -9
- data/app/models/shipit/commit_checks.rb +13 -13
- data/app/models/shipit/commit_deployment.rb +3 -3
- data/app/models/shipit/commit_deployment_status.rb +3 -3
- data/app/models/shipit/deploy.rb +16 -11
- data/app/models/shipit/deploy_spec/lerna_discovery.rb +12 -4
- data/app/models/shipit/duration.rb +2 -0
- data/app/models/shipit/hook.rb +26 -2
- data/app/models/shipit/merge_request.rb +9 -7
- data/app/models/shipit/pull_request.rb +1 -1
- data/app/models/shipit/release_status.rb +1 -1
- data/app/models/shipit/repository.rb +9 -3
- data/app/models/shipit/review_stack.rb +16 -2
- data/app/models/shipit/stack.rb +59 -25
- data/app/models/shipit/status/group.rb +1 -1
- data/app/models/shipit/task.rb +6 -2
- data/app/models/shipit/task_execution_strategy/default.rb +4 -5
- data/app/models/shipit/team.rb +4 -2
- data/app/models/shipit/user.rb +4 -0
- data/app/models/shipit/webhooks/handlers/pull_request/review_stack_adapter.rb +1 -1
- data/app/models/shipit/webhooks/handlers/push_handler.rb +4 -1
- data/app/serializers/shipit/merge_request_serializer.rb +1 -1
- data/app/validators/subset_validator.rb +1 -1
- data/app/views/layouts/merge_status.html.erb +1 -1
- data/app/views/shipit/stacks/_banners.html.erb +2 -1
- data/app/views/shipit/stacks/new.html.erb +1 -1
- data/config/secrets.development.example.yml +24 -0
- data/config/secrets.development.shopify.yml +20 -9
- data/db/migrate/20210325194053_remove_stacks_branch_default.rb +5 -0
- data/db/migrate/20210504200438_add_github_updated_at_to_check_runs.rb +5 -0
- data/lib/shipit.rb +39 -15
- data/lib/shipit/command.rb +7 -6
- data/lib/shipit/commands.rb +9 -2
- data/lib/shipit/engine.rb +2 -0
- data/lib/shipit/flock.rb +8 -1
- data/lib/shipit/github_app.rb +7 -5
- data/lib/shipit/octokit_iterator.rb +3 -3
- data/lib/shipit/simple_message_verifier.rb +2 -2
- data/lib/shipit/stack_commands.rb +28 -4
- data/lib/shipit/task_commands.rb +6 -0
- data/lib/shipit/version.rb +1 -1
- data/lib/snippets/publish-lerna-independent-packages +35 -34
- data/lib/snippets/publish-lerna-independent-packages-legacy +39 -0
- data/test/controllers/api/ccmenu_controller_test.rb +1 -1
- data/test/controllers/api/deploys_controller_test.rb +17 -0
- data/test/controllers/api/stacks_controller_test.rb +21 -7
- data/test/controllers/webhooks_controller_test.rb +26 -11
- data/test/dummy/app/assets/config/manifest.js +3 -0
- data/test/dummy/config/application.rb +1 -1
- data/test/dummy/config/database.yml +9 -0
- data/test/dummy/config/environments/development.rb +1 -1
- data/test/dummy/config/secrets_double_github_app.yml +79 -0
- data/test/dummy/db/schema.rb +5 -4
- data/test/dummy/db/seeds.rb +1 -0
- data/test/fixtures/payloads/check_suite_master.json +2 -30
- data/test/fixtures/payloads/push_master.json +1 -1
- data/test/fixtures/payloads/push_not_master.json +1 -1
- data/test/fixtures/shipit/commits.yml +2 -2
- data/test/fixtures/shipit/hooks.yml +1 -0
- data/test/fixtures/shipit/tasks.yml +1 -1
- data/test/helpers/json_helper.rb +5 -1
- data/test/jobs/github_sync_job_test.rb +2 -1
- data/test/models/commit_deployment_status_test.rb +3 -3
- data/test/models/commits_test.rb +2 -0
- data/test/models/deploy_spec_test.rb +7 -0
- data/test/models/deploys_test.rb +18 -0
- data/test/models/hook_test.rb +30 -1
- data/test/models/merge_request_test.rb +19 -4
- data/test/models/shipit/check_run_test.rb +124 -5
- data/test/models/shipit/review_stack_test.rb +38 -6
- data/test/models/shipit/stacks_test.rb +42 -4
- data/test/models/shipit/webhooks/handlers/pull_request/review_stack_adapter_test.rb +24 -0
- data/test/models/tasks_test.rb +22 -0
- data/test/test_helper.rb +15 -0
- data/test/unit/anonymous_user_serializer_test.rb +1 -1
- data/test/unit/command_test.rb +5 -0
- data/test/unit/commit_serializer_test.rb +1 -1
- data/test/unit/deploy_commands_test.rb +70 -14
- data/test/unit/deploy_serializer_test.rb +1 -1
- data/test/unit/github_app_test.rb +2 -3
- data/test/unit/github_apps_test.rb +416 -0
- data/test/unit/shipit_deployment_checks_test.rb +77 -0
- data/test/unit/shipit_test.rb +14 -0
- data/test/unit/user_serializer_test.rb +1 -1
- metadata +202 -191
@@ -1,3 +1,11 @@
|
|
1
|
+
<% if ENV['DATABASE_URL'].present? %>
|
2
|
+
development:
|
3
|
+
database: shipit_engine_development
|
4
|
+
|
5
|
+
test:
|
6
|
+
database: shipit_engine_test
|
7
|
+
|
8
|
+
<% else %>
|
1
9
|
default: &default
|
2
10
|
adapter: sqlite3
|
3
11
|
|
@@ -8,3 +16,4 @@ development:
|
|
8
16
|
test:
|
9
17
|
<<: *default
|
10
18
|
database: db/test.sqlite3
|
19
|
+
<% end %>
|
@@ -50,7 +50,7 @@ Rails.application.configure do
|
|
50
50
|
|
51
51
|
# Raises error for missing translations
|
52
52
|
# config.action_view.raise_on_missing_translations = true
|
53
|
-
if Rails.application.config_for(:database)
|
53
|
+
if Rails.application.config_for(:database)&.dig('adapter') == 'sqlite3'
|
54
54
|
config.to_prepare do
|
55
55
|
Shipit::DeferredTouch.enabled = false
|
56
56
|
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
github:
|
2
|
+
OrgOne:
|
3
|
+
domain: # defaults to github.com
|
4
|
+
app_id: 42
|
5
|
+
installation_id: 43
|
6
|
+
bot_login: "shipit[bot]"
|
7
|
+
webhook_secret: # nil
|
8
|
+
# Randomly generated
|
9
|
+
private_key: |
|
10
|
+
-----BEGIN RSA PRIVATE KEY-----
|
11
|
+
MIIEpAIBAAKCAQEA7iUQC2uUq/gtQg0gxtyaccuicYgmq1LUr1mOWbmwM1Cv63+S
|
12
|
+
73qo8h87FX+YyclY5fZF6SMXIys02JOkImGgbnvEOLcHnImCYrWs03msOzEIO/pG
|
13
|
+
M0YedAPtQ2MEiLIu4y8htosVxeqfEOPiq9kQgFxNKyETzjdIA9q1md8sofuJUmPv
|
14
|
+
ibacW1PecuAMnn+P8qf0XIDp7uh6noB751KvhCaCNTAPtVE9NZ18OmNG9GOyX/pu
|
15
|
+
pQHIrPgTpTG6KlAe3r6LWvemzwsMtuRGU+K+KhK9dFIlSE+v9rA32KScO8efOh6s
|
16
|
+
Gu3rWorV4iDu14U62rzEfdzzc63YL94sUbZxbwIDAQABAoIBADLJ8r8MxZtbhYN1
|
17
|
+
u0zOFZ45WL6v09dsBfITvnlCUeLPzYUDIzoxxcBFittN6C744x3ARS6wjimw+EdM
|
18
|
+
TZALlCSb/sA9wMDQzt7wchhz9Zh2H5RzDu+2f54sjDh38KqancdT8PO2fAFGxX/b
|
19
|
+
qicOVyeZB9gv6MJtJc20olBbuXAeBNfcDABF9oxF+0i+Ssg7B4VXiqgcjtGbr/Og
|
20
|
+
qRll7AqyTArVx2xEcVfZxeZ4zGnigzcJq4te7yYpxzwk+RxblkPh54Yt4WxZ+8DI
|
21
|
+
Rsn3r6ajlpwzpwvsJFU2Txq7xBTzGQMFmy/Pnjk83kP2cogxB2+tRyjITGqTwD8b
|
22
|
+
gg9PFCkCgYEA+7u8A0l0Cz6p0SI6c7ftVePVRiIhpawWN7og/wEmI6zUjm/3rA+R
|
23
|
+
hrhaVKuOD8QF/HdDsqTck5gjGAjTmJz6r33/cl1Tz+pr62znsrB4r0yMKvQbKN81
|
24
|
+
WGaWOsi2+ZXqLNv5h5wpUF0MTKlXHeKnwP5kuEvGwVn6WURFCh6PhLMCgYEA8i5e
|
25
|
+
JjulJVGyd5HuoY3xyO7E6DjidsqRnVRq+hYpORjnHvTmSwe4+tH4ha2p9Kv2Y6k3
|
26
|
+
C1NYY/fSMQoYCCRaYyJleI+la/9tsZqAmtms4ZB8KhFmPHf9fW75i6G0xKWyZ8K+
|
27
|
+
E2Ft/UaEiM282593cguV6+Kt5uExnyPxLLK4FlUCgYEAwRJ/JGI8/7bjFkTTYheq
|
28
|
+
j5q75BufhOrU6471acAe2XPgXxLfefdC3Xodxh0CS3NESBvNL4Ikr4sbN37lk4Kq
|
29
|
+
/th7iOKtuqUIeru/hZy2I3VpeDRbdGCmEJQ2GwYA2LKztg5Nd0Y9paaIHXAwIfrK
|
30
|
+
QUqcQ4HTAk8ZpUeoUBeaaeMCgYANLmbjb9WiPVsYVPIHCwHA7PX8qbPxwT7BsGmO
|
31
|
+
KQyfVfKmZa/vH4F67Vi4deZNMdrcO8aKMEQcVM2065a5QrlEsgeR00eupB1lUEJ1
|
32
|
+
qylUsZeAdqf43JMIc7TTW77KATa/nQLZbTEeWus1wvTngztuEqFbUGAks9cOkVc8
|
33
|
+
FpIcbQKBgQDVIL8gPLmn0f+4oLF8MBC+oxtKpz14X5iJ1saGFkzW5I+nIEskpS0S
|
34
|
+
qtirnTCnJFGdCrFwctnxiuiCmyGwpBYdjIfHyvYAHnqAtMnESzCUyeSFZiquVW5W
|
35
|
+
MvbMmDPoV27XOHU9kIq6NXtfrkpufiyo6/VEYWozXalxKLNuqLYfPQ==
|
36
|
+
-----END RSA PRIVATE KEY-----
|
37
|
+
oauth:
|
38
|
+
id: Iv1.bf2c2c45b449bfd9
|
39
|
+
secret: ef694cd6e45223075d78d138ef014049052665f1
|
40
|
+
teams:
|
41
|
+
OrgTwo:
|
42
|
+
domain: # defaults to github.com
|
43
|
+
app_id: 42
|
44
|
+
installation_id: 43
|
45
|
+
bot_login: "shipit[bot]"
|
46
|
+
webhook_secret: # nil
|
47
|
+
# Randomly generated
|
48
|
+
private_key: |
|
49
|
+
-----BEGIN RSA PRIVATE KEY-----
|
50
|
+
MIIEpAIBAAKCAQEA7iUQC2uUq/gtQg0gxtyaccuicYgmq1LUr1mOWbmwM1Cv63+S
|
51
|
+
73qo8h87FX+YyclY5fZF6SMXIys02JOkImGgbnvEOLcHnImCYrWs03msOzEIO/pG
|
52
|
+
M0YedAPtQ2MEiLIu4y8htosVxeqfEOPiq9kQgFxNKyETzjdIA9q1md8sofuJUmPv
|
53
|
+
ibacW1PecuAMnn+P8qf0XIDp7uh6noB751KvhCaCNTAPtVE9NZ18OmNG9GOyX/pu
|
54
|
+
pQHIrPgTpTG6KlAe3r6LWvemzwsMtuRGU+K+KhK9dFIlSE+v9rA32KScO8efOh6s
|
55
|
+
Gu3rWorV4iDu14U62rzEfdzzc63YL94sUbZxbwIDAQABAoIBADLJ8r8MxZtbhYN1
|
56
|
+
u0zOFZ45WL6v09dsBfITvnlCUeLPzYUDIzoxxcBFittN6C744x3ARS6wjimw+EdM
|
57
|
+
TZALlCSb/sA9wMDQzt7wchhz9Zh2H5RzDu+2f54sjDh38KqancdT8PO2fAFGxX/b
|
58
|
+
qicOVyeZB9gv6MJtJc20olBbuXAeBNfcDABF9oxF+0i+Ssg7B4VXiqgcjtGbr/Og
|
59
|
+
qRll7AqyTArVx2xEcVfZxeZ4zGnigzcJq4te7yYpxzwk+RxblkPh54Yt4WxZ+8DI
|
60
|
+
Rsn3r6ajlpwzpwvsJFU2Txq7xBTzGQMFmy/Pnjk83kP2cogxB2+tRyjITGqTwD8b
|
61
|
+
gg9PFCkCgYEA+7u8A0l0Cz6p0SI6c7ftVePVRiIhpawWN7og/wEmI6zUjm/3rA+R
|
62
|
+
hrhaVKuOD8QF/HdDsqTck5gjGAjTmJz6r33/cl1Tz+pr62znsrB4r0yMKvQbKN81
|
63
|
+
WGaWOsi2+ZXqLNv5h5wpUF0MTKlXHeKnwP5kuEvGwVn6WURFCh6PhLMCgYEA8i5e
|
64
|
+
JjulJVGyd5HuoY3xyO7E6DjidsqRnVRq+hYpORjnHvTmSwe4+tH4ha2p9Kv2Y6k3
|
65
|
+
C1NYY/fSMQoYCCRaYyJleI+la/9tsZqAmtms4ZB8KhFmPHf9fW75i6G0xKWyZ8K+
|
66
|
+
E2Ft/UaEiM282593cguV6+Kt5uExnyPxLLK4FlUCgYEAwRJ/JGI8/7bjFkTTYheq
|
67
|
+
j5q75BufhOrU6471acAe2XPgXxLfefdC3Xodxh0CS3NESBvNL4Ikr4sbN37lk4Kq
|
68
|
+
/th7iOKtuqUIeru/hZy2I3VpeDRbdGCmEJQ2GwYA2LKztg5Nd0Y9paaIHXAwIfrK
|
69
|
+
QUqcQ4HTAk8ZpUeoUBeaaeMCgYANLmbjb9WiPVsYVPIHCwHA7PX8qbPxwT7BsGmO
|
70
|
+
KQyfVfKmZa/vH4F67Vi4deZNMdrcO8aKMEQcVM2065a5QrlEsgeR00eupB1lUEJ1
|
71
|
+
qylUsZeAdqf43JMIc7TTW77KATa/nQLZbTEeWus1wvTngztuEqFbUGAks9cOkVc8
|
72
|
+
FpIcbQKBgQDVIL8gPLmn0f+4oLF8MBC+oxtKpz14X5iJ1saGFkzW5I+nIEskpS0S
|
73
|
+
qtirnTCnJFGdCrFwctnxiuiCmyGwpBYdjIfHyvYAHnqAtMnESzCUyeSFZiquVW5W
|
74
|
+
MvbMmDPoV27XOHU9kIq6NXtfrkpufiyo6/VEYWozXalxKLNuqLYfPQ==
|
75
|
+
-----END RSA PRIVATE KEY-----
|
76
|
+
oauth:
|
77
|
+
id: Iv1.bf2c2c45b449bfd9
|
78
|
+
secret: ef694cd6e45223075d78d138ef014049052665f1
|
79
|
+
teams:
|
data/test/dummy/db/schema.rb
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
# of editing this file, please use the migrations feature of Active Record to
|
3
3
|
# incrementally modify your database, and then regenerate this schema definition.
|
4
4
|
#
|
5
|
-
# This file is the source Rails uses to define your schema when running `rails
|
6
|
-
# db:schema:load`. When creating a new database, `rails db:schema:load` tends to
|
5
|
+
# This file is the source Rails uses to define your schema when running `bin/rails
|
6
|
+
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
|
7
7
|
# be faster and is potentially less error prone than running all of your
|
8
8
|
# migrations from scratch. Old migrations may fail to apply correctly if those
|
9
9
|
# migrations use external dependencies or application code.
|
10
10
|
#
|
11
11
|
# It's strongly recommended that you check this file into your version control system.
|
12
12
|
|
13
|
-
ActiveRecord::Schema.define(version:
|
13
|
+
ActiveRecord::Schema.define(version: 2021_05_04_200438) do
|
14
14
|
|
15
15
|
create_table "api_clients", force: :cascade do |t|
|
16
16
|
t.text "permissions", limit: 65535
|
@@ -33,6 +33,7 @@ ActiveRecord::Schema.define(version: 2020_10_08_152744) do
|
|
33
33
|
t.string "html_url"
|
34
34
|
t.datetime "created_at", null: false
|
35
35
|
t.datetime "updated_at", null: false
|
36
|
+
t.datetime "github_updated_at"
|
36
37
|
t.index ["commit_id"], name: "index_check_runs_on_commit_id"
|
37
38
|
t.index ["github_id", "commit_id"], name: "index_check_runs_on_github_id_and_commit_id", unique: true
|
38
39
|
t.index ["stack_id"], name: "index_check_runs_on_stack_id"
|
@@ -234,7 +235,7 @@ ActiveRecord::Schema.define(version: 2020_10_08_152744) do
|
|
234
235
|
t.string "environment", limit: 50, default: "production", null: false
|
235
236
|
t.datetime "created_at"
|
236
237
|
t.datetime "updated_at"
|
237
|
-
t.string "branch", limit: 255,
|
238
|
+
t.string "branch", limit: 255, null: false
|
238
239
|
t.string "deploy_url", limit: 255
|
239
240
|
t.string "lock_reason", limit: 4096
|
240
241
|
t.integer "tasks_count", limit: 4, default: 0, null: false
|
data/test/dummy/db/seeds.rb
CHANGED
@@ -31,6 +31,7 @@ module Shipit
|
|
31
31
|
name: Faker::Internet.domain_name.parameterize,
|
32
32
|
owner: Faker::Company.name.parameterize
|
33
33
|
),
|
34
|
+
branch: "main",
|
34
35
|
deploy_url: "https://#{Faker::Internet.domain_name.parameterize}.#{Faker::Internet.domain_suffix}/",
|
35
36
|
cached_deploy_spec: DeploySpec.load(%(
|
36
37
|
{
|
@@ -67,24 +67,7 @@
|
|
67
67
|
"name": "shipit-engine",
|
68
68
|
"full_name": "Shopify/shipit-engine",
|
69
69
|
"owner": {
|
70
|
-
"login": "
|
71
|
-
"id": 340,
|
72
|
-
"node_id": "MDQ6VXNlcjIxMDMxMDY3",
|
73
|
-
"avatar_url": "http://alambic.github.com/avatars/u/340?",
|
74
|
-
"gravatar_id": "",
|
75
|
-
"url": "https://api.github.com/users/github",
|
76
|
-
"html_url": "http://github.com/github",
|
77
|
-
"followers_url": "https://api.github.com/users/github/followers",
|
78
|
-
"following_url": "https://api.github.com/users/github/following{/other_user}",
|
79
|
-
"gists_url": "https://api.github.com/users/github/gists{/gist_id}",
|
80
|
-
"starred_url": "https://api.github.com/users/github/starred{/owner}{/repo}",
|
81
|
-
"subscriptions_url": "https://api.github.com/users/github/subscriptions",
|
82
|
-
"organizations_url": "https://api.github.com/users/github/orgs",
|
83
|
-
"repos_url": "https://api.github.com/users/github/repos",
|
84
|
-
"events_url": "https://api.github.com/users/github/events{/privacy}",
|
85
|
-
"received_events_url": "https://api.github.com/users/github/received_events",
|
86
|
-
"type": "Organization",
|
87
|
-
"site_admin": false
|
70
|
+
"login": "Shopify"
|
88
71
|
},
|
89
72
|
"private": false,
|
90
73
|
"html_url": "http://github.com/Shopify/shipit-engine",
|
@@ -155,18 +138,7 @@
|
|
155
138
|
"default_branch": "master"
|
156
139
|
},
|
157
140
|
"organization": {
|
158
|
-
"login": "
|
159
|
-
"id": 340,
|
160
|
-
"node_id": "MDEyOk9yZ2FuaXphdGlvbjM4MzAyODk5",
|
161
|
-
"url": "https://api.github.com/orgs/github",
|
162
|
-
"repos_url": "https://api.github.com/orgs/github/repos",
|
163
|
-
"events_url": "https://api.github.com/orgs/github/events",
|
164
|
-
"hooks_url": "https://api.github.com/orgs/github/hooks",
|
165
|
-
"issues_url": "https://api.github.com/orgs/github/issues",
|
166
|
-
"members_url": "https://api.github.com/orgs/github/members{/member}",
|
167
|
-
"public_members_url": "https://api.github.com/orgs/github/public_members{/member}",
|
168
|
-
"avatar_url": "http://alambic.github.com/avatars/u/340?",
|
169
|
-
"description": "How people build software."
|
141
|
+
"login": "Shopify"
|
170
142
|
},
|
171
143
|
"sender": {
|
172
144
|
"login": "octocat",
|
@@ -45,8 +45,8 @@ fourth:
|
|
45
45
|
sha: 467578b362bf2b4df5903e1c7960929361c3435a
|
46
46
|
message: "Merge pull request #7 from shipit-engine/yoloshipit\n\nyoloshipit!"
|
47
47
|
stack: shipit
|
48
|
-
author:
|
49
|
-
committer:
|
48
|
+
author: ~
|
49
|
+
committer: ~
|
50
50
|
authored_at: <%= 4.days.ago.to_s(:db) %>
|
51
51
|
committed_at: <%= 3.days.ago.to_s(:db) %>
|
52
52
|
additions: 420
|
data/test/helpers/json_helper.rb
CHANGED
@@ -3,7 +3,11 @@ module JSONHelper
|
|
3
3
|
UNDEFINED = Object.new.freeze
|
4
4
|
private_constant :UNDEFINED
|
5
5
|
|
6
|
-
def assert_json(path = nil, expected_value = UNDEFINED,
|
6
|
+
def assert_json(path = nil, expected_value = UNDEFINED, &block)
|
7
|
+
assert_json_document(response.body, path, expected_value, &block)
|
8
|
+
end
|
9
|
+
|
10
|
+
def assert_json_document(document, path, expected_value = UNDEFINED)
|
7
11
|
value = follow_path(path.to_s.split('.'), document: document)
|
8
12
|
if block_given?
|
9
13
|
yield value
|
@@ -91,7 +91,7 @@ module Shipit
|
|
91
91
|
last = stub(sha: 123)
|
92
92
|
first = stub(sha: 345)
|
93
93
|
Shipit::FirstParentCommitsIterator.any_instance.stubs(:each).multiple_yields(last, first)
|
94
|
-
@job.stubs(lookup_commit: nil)
|
94
|
+
@job.stubs(lookup_commit: nil, stack: @stack)
|
95
95
|
|
96
96
|
commits, parent = @job.fetch_missing_commits { stub }
|
97
97
|
assert_nil parent
|
@@ -104,6 +104,7 @@ module Shipit
|
|
104
104
|
Shipit::FirstParentCommitsIterator.any_instance.stubs(:each).multiple_yields(last, first)
|
105
105
|
@job.stubs(:lookup_commit).with(123).returns(nil)
|
106
106
|
@job.stubs(:lookup_commit).with(345).returns(first)
|
107
|
+
@job.stubs(stack: @stack)
|
107
108
|
|
108
109
|
commits, parent = @job.fetch_missing_commits { stub }
|
109
110
|
assert_equal first, parent
|
@@ -12,7 +12,7 @@ module Shipit
|
|
12
12
|
|
13
13
|
test 'creation on GitHub' do
|
14
14
|
response = stub(id: 44, url: 'https://example.com')
|
15
|
-
@author.github_api.expects(:create_deployment_status).with(
|
15
|
+
@author.github_api.class.any_instance.expects(:create_deployment_status).with(
|
16
16
|
@deployment.api_url,
|
17
17
|
'in_progress',
|
18
18
|
accept: "application/vnd.github.flash-preview+json",
|
@@ -33,7 +33,7 @@ module Shipit
|
|
33
33
|
status = deployment.statuses.create!(status: 'success')
|
34
34
|
status.stubs(:description).returns('desc' * limit)
|
35
35
|
create_status_response = stub(id: 'abcd', url: 'https://github.com/status/abcd')
|
36
|
-
status.author.github_api.expects(:create_deployment_status).with do
|
36
|
+
status.author.github_api.class.any_instance.expects(:create_deployment_status).with do |_url, _status, kwargs|
|
37
37
|
kwargs[:description].size <= limit
|
38
38
|
end.returns(create_status_response)
|
39
39
|
|
@@ -47,7 +47,7 @@ module Shipit
|
|
47
47
|
stack = status.stack
|
48
48
|
stack.deploy_url = "stack-deploy-url"
|
49
49
|
create_status_response = stub(id: 'abcd', url: 'https://github.com/status/abcd')
|
50
|
-
status.author.github_api.expects(:create_deployment_status).with do
|
50
|
+
status.author.github_api.class.any_instance.expects(:create_deployment_status).with do |_url, _status, kwargs|
|
51
51
|
kwargs[:environment_url] == 'stack-deploy-url'
|
52
52
|
end.returns(create_status_response)
|
53
53
|
|
data/test/models/commits_test.rb
CHANGED
@@ -828,6 +828,13 @@ module Shipit
|
|
828
828
|
@spec.stubs(:lerna?).returns(true)
|
829
829
|
@spec.stubs(:lerna_config).returns('lerna' => '2.0.0', 'version' => 'independent')
|
830
830
|
assert_equal 'assert-lerna-independent-version-tags', @spec.deploy_steps[0]
|
831
|
+
assert_equal 'publish-lerna-independent-packages-legacy', @spec.deploy_steps[1]
|
832
|
+
end
|
833
|
+
|
834
|
+
test '#publish_lerna_packages checks if independent version tags exist, checks if a newer version of lerna is used, and then invokes lerna deploy script' do
|
835
|
+
@spec.stubs(:lerna?).returns(true)
|
836
|
+
@spec.stubs(:lerna_config).returns('lerna' => '3.0.0', 'version' => 'independent')
|
837
|
+
assert_equal 'assert-lerna-independent-version-tags', @spec.deploy_steps[0]
|
831
838
|
assert_equal 'publish-lerna-independent-packages', @spec.deploy_steps[1]
|
832
839
|
end
|
833
840
|
|
data/test/models/deploys_test.rb
CHANGED
@@ -802,6 +802,12 @@ module Shipit
|
|
802
802
|
assert_equal @user, @stack.lock_author
|
803
803
|
end
|
804
804
|
|
805
|
+
test "#trigger_rollback does not lock the stack if not requested" do
|
806
|
+
refute @stack.locked?
|
807
|
+
@deploy.trigger_rollback(@user, lock: false)
|
808
|
+
refute @stack.reload.locked?
|
809
|
+
end
|
810
|
+
|
805
811
|
test "#trigger_rollback marks the rollback as `ignored_safeties` if the force option was used" do
|
806
812
|
rollback = @deploy.trigger_rollback(@user, force: true)
|
807
813
|
assert_predicate rollback, :ignored_safeties?
|
@@ -967,6 +973,18 @@ module Shipit
|
|
967
973
|
end
|
968
974
|
end
|
969
975
|
|
976
|
+
test "succeeding a deploy sets the release status as pending and does not schedule job if the status delay is negative (-1)" do
|
977
|
+
@deploy = shipit_deploys(:canaries_running)
|
978
|
+
@deploy.stack.expects(:release_status_delay).at_least_once.returns(Duration.parse(-1))
|
979
|
+
|
980
|
+
assert_difference -> { ReleaseStatus.count }, +1 do
|
981
|
+
assert_not_equal 'success', @deploy.last_release_status.state
|
982
|
+
@deploy.report_complete!
|
983
|
+
assert_equal 'validating', @deploy.status
|
984
|
+
assert_equal 'pending', @deploy.last_release_status.state
|
985
|
+
end
|
986
|
+
end
|
987
|
+
|
970
988
|
test "triggering a rollback via abort! sets the release status as failure" do
|
971
989
|
@deploy = shipit_deploys(:canaries_running)
|
972
990
|
@deploy.ping
|
data/test/models/hook_test.rb
CHANGED
@@ -36,6 +36,35 @@ module Shipit
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
+
test ".deliver! sends request with correct method, headers, and body" do
|
40
|
+
stub_request(:post, @hook.delivery_url).to_return(body: 'OK')
|
41
|
+
body = { 'foo' => 42 }
|
42
|
+
expected_body = JSON.pretty_generate(body)
|
43
|
+
expected_signature = Hook::DeliverySigner.new(@hook.secret).sign(expected_body)
|
44
|
+
|
45
|
+
perform_enqueued_jobs(only: DeliverHookJob) do
|
46
|
+
@hook.deliver!(:deploy, body)
|
47
|
+
end
|
48
|
+
assert_performed_jobs 1
|
49
|
+
assert_requested :post, @hook.delivery_url do |req|
|
50
|
+
req.headers['X-Shipit-Signature'] == expected_signature
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
test ".deliver! sends without signature if no secret is configured" do
|
55
|
+
stub_request(:post, @hook.delivery_url).to_return(body: 'OK')
|
56
|
+
@hook.update!(secret: '')
|
57
|
+
body = { 'foo' => 42 }
|
58
|
+
|
59
|
+
perform_enqueued_jobs(only: DeliverHookJob) do
|
60
|
+
@hook.deliver!(:deploy, body)
|
61
|
+
end
|
62
|
+
assert_performed_jobs 1
|
63
|
+
assert_requested :post, @hook.delivery_url do |req|
|
64
|
+
!req.headers.key?('X-Shipit-Signature')
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
39
68
|
test ".scoped? returns true if the hook has a stack_id" do
|
40
69
|
@hook.stack_id = nil
|
41
70
|
refute @hook.scoped?
|
@@ -73,7 +102,7 @@ module Shipit
|
|
73
102
|
locked_stack = Stack.first
|
74
103
|
locked_stack.lock("Some Reason", nil)
|
75
104
|
serialized = Hook.coerce_payload(stack: locked_stack)
|
76
|
-
|
105
|
+
assert_json_document(serialized, "stack.lock_author.anonymous", true)
|
77
106
|
end
|
78
107
|
end
|
79
108
|
end
|
@@ -60,7 +60,7 @@ module Shipit
|
|
60
60
|
|
61
61
|
assert_nil MergeRequest.extract_number(@stack, 'https://github.com/ACME/shipit-engine/pull/42')
|
62
62
|
|
63
|
-
Shipit.github.expects(:domain).returns('github.acme.com').at_least_once
|
63
|
+
Shipit.github.class.any_instance.expects(:domain).returns('github.acme.com').at_least_once
|
64
64
|
assert_equal 42, MergeRequest.extract_number(@stack, 'https://github.acme.com/Shopify/shipit-engine/pull/42')
|
65
65
|
assert_nil MergeRequest.extract_number(@stack, 'https://github.com/Shopify/shipit-engine/pull/42')
|
66
66
|
end
|
@@ -125,6 +125,21 @@ module Shipit
|
|
125
125
|
created_at: 1.day.ago,
|
126
126
|
)])
|
127
127
|
|
128
|
+
Shipit.github.api.expects(:check_runs).with(@stack.github_repo_name, head_sha).returns(stub(
|
129
|
+
check_runs: [stub(
|
130
|
+
id: 123456,
|
131
|
+
name: 'check run',
|
132
|
+
conclusion: 'success',
|
133
|
+
output: stub(
|
134
|
+
title: 'a test checkrun',
|
135
|
+
),
|
136
|
+
details_url: 'http://example.com',
|
137
|
+
html_url: 'http://example.com',
|
138
|
+
completed_at: Time.now,
|
139
|
+
started_at: 1.minute.ago,
|
140
|
+
)]
|
141
|
+
))
|
142
|
+
|
128
143
|
merge_request.refresh!
|
129
144
|
|
130
145
|
assert_predicate merge_request, :mergeable?
|
@@ -233,9 +248,9 @@ module Shipit
|
|
233
248
|
end
|
234
249
|
params = job.arguments.first
|
235
250
|
assert_equal 'merge', params[:event]
|
236
|
-
|
237
|
-
|
238
|
-
|
251
|
+
assert_json_document params[:payload], 'status', 'rejected'
|
252
|
+
assert_json_document params[:payload], 'merge_request.rejection_reason', 'merge_conflict'
|
253
|
+
assert_json_document params[:payload], 'merge_request.number', @pr.number
|
239
254
|
end
|
240
255
|
|
241
256
|
test "#merge! doesnt delete the branch if there are open PRs against it" do
|