hephaestus 0.8.11 → 0.8.12.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/CHANGELOG.md +12 -0
- data/README.md +3 -1
- data/bin/hephaestus +37 -19
- data/lib/hephaestus/app_builder.rb +23 -145
- data/lib/hephaestus/app_name.rb +33 -0
- data/lib/hephaestus/generators/app_generator.rb +79 -75
- data/lib/hephaestus/generators/base.rb +0 -1
- data/lib/hephaestus/generators/config_generator.rb +3 -114
- data/lib/hephaestus/generators/core_generator.rb +18 -58
- data/lib/hephaestus/generators/db_generator.rb +12 -0
- data/lib/hephaestus/generators/deployment_generator.rb +3 -8
- data/lib/hephaestus/generators/lib_generator.rb +0 -10
- data/lib/hephaestus/generators/license_generator.rb +4 -1
- data/lib/hephaestus/generators/rubocop_generator.rb +1 -1
- data/lib/hephaestus/version.rb +1 -1
- data/lib/hephaestus.rb +2 -1
- data/templates/Dockerfile +7 -75
- data/templates/Gemfile +73 -0
- data/templates/Procfile +2 -0
- data/templates/app/controllers/app_controller.rb.tt +35 -0
- data/templates/app/controllers/application_controller.rb +1 -7
- data/templates/app/controllers/concerns/authable.rb.tt +50 -0
- data/templates/app/controllers/settings_controller.rb +5 -28
- data/templates/app/controllers/yetto_controller.rb +9 -10
- data/templates/app/lib/body_parameter/yetto_parameters.rb +8 -29
- data/templates/app/lib/{constants/app.rb → constants.rb} +1 -3
- data/templates/app/services/{http_service.rb → app_service.rb.tt} +6 -6
- data/templates/app/views/settings/new.json.jbuilder.tt +18 -0
- data/templates/bin/bundle +115 -0
- data/templates/bin/docker-entrypoint +20 -10
- data/templates/bin/foreman +27 -0
- data/templates/bin/jobs +7 -0
- data/templates/bin/rails +6 -0
- data/templates/bin/rake +6 -0
- data/templates/bin/setup +28 -0
- data/templates/bin/tapioca +27 -0
- data/templates/config/application.rb.tt +36 -0
- data/templates/config/boot.rb +7 -0
- data/templates/config/environment.rb +8 -0
- data/templates/config/environments/blank.rb +7 -0
- data/templates/config/initializers/environment.rb +2 -36
- data/templates/config/locales/en.yml +5 -31
- data/templates/config/puma.rb +5 -0
- data/templates/config/routes.rb.tt +28 -0
- data/templates/config.ru +9 -0
- data/templates/db/queue_schema.rb +132 -0
- data/templates/db/schema.rb +17 -0
- data/templates/hephaestus_env.sample +12 -0
- data/templates/hephaestus_github/dependabot.yml +27 -0
- data/templates/hephaestus_github/workflows/automerge.yml +14 -0
- data/templates/hephaestus_github/workflows/deploy.yml +30 -0
- data/templates/hephaestus_github/workflows/licenses.yml +17 -0
- data/templates/hephaestus_github/workflows/lint.yml +17 -0
- data/templates/hephaestus_github/workflows/security.yml +19 -0
- data/templates/hephaestus_github/workflows/sorbet.yml +19 -0
- data/templates/hephaestus_github/workflows/test.yml.tt +21 -0
- data/templates/hephaestus_github/workflows/updater.yml +18 -0
- data/templates/hephaestus_vscode/extensions.json +9 -0
- data/templates/hephaestus_vscode/launch.json +13 -0
- data/templates/hephaestus_vscode/settings.json +58 -0
- data/templates/lib/schemas/api/2023-03-06/components/parameters/headers/yetto.json +42 -0
- data/templates/lib/schemas/api/2023-03-06/components/parameters/plugInstallation.json +12 -0
- data/templates/lib/schemas/api/2023-03-06/components/schemas/plug.json +9 -0
- data/templates/lib/schemas/api/2023-03-06/components/schemas/responses.json +64 -0
- data/templates/lib/schemas/api/2023-03-06/components/schemas/yetto.json +116 -0
- data/templates/lib/schemas/api/2023-03-06/openapi.json +30 -0
- data/templates/lib/schemas/api/2023-03-06/paths/app.json +90 -0
- data/templates/lib/schemas/api/2023-03-06/paths/yetto/message_created.json +51 -0
- data/templates/lib/schemas/api/2023-03-06/paths/yetto/plug_installation_created.json +51 -0
- data/templates/script/docker-build-prod.tt +11 -0
- data/templates/script/docker-run.tt +8 -0
- data/templates/script/edit-credentials +12 -3
- data/templates/script/hmac_text +1 -1
- data/templates/script/ngrok.tt +7 -0
- data/templates/script/server +6 -45
- data/templates/test/controllers/app_controller_test.rb.tt +188 -0
- data/templates/test/controllers/settings_controller_test.rb.tt +125 -0
- data/templates/test/controllers/yetto_controller_test.rb +100 -71
- data/templates/test/fixtures/files/plug_installation_settings/valid.json +1 -1
- data/templates/test/support/rails.rb +16 -36
- data/templates/test/support/webmocks/app_webmock.rb.tt +29 -0
- data/templates/test/test_helper.rb +1 -31
- data/templates/vendor/fly/{fly-production.toml → fly-production.toml.tt} +24 -11
- data/templates/vendor/fly/{fly-staging.toml → fly-staging.toml.tt} +18 -15
- metadata +59 -72
- data/lib/hephaestus/exit_on_failure.rb +0 -22
- data/templates/Gemfile.erb +0 -120
- data/templates/Procfile.debug +0 -2
- data/templates/Procfile.dev +0 -2
- data/templates/app/controllers/app_controller.rb +0 -72
- data/templates/app/controllers/concerns/authable.rb +0 -50
- data/templates/app/controllers/staff_controller.rb +0 -15
- data/templates/app/jobs/update_yetto_job.rb +0 -26
- data/templates/app/lib/headers/yetto.rb +0 -19
- data/templates/app/lib/headers.rb +0 -5
- data/templates/app/lib/path_parameter/settings_parameters.rb +0 -22
- data/templates/app/lib/path_parameter/yetto_parameters.rb +0 -28
- data/templates/app/lib/path_parameter.rb +0 -8
- data/templates/app/lib/plug_app/http.rb +0 -37
- data/templates/app/lib/plug_app/middleware/malformed_request.rb +0 -110
- data/templates/app/lib/plug_app/middleware/openapi_validation.rb +0 -83
- data/templates/app/lib/plug_app/middleware/tracing_attributes.rb +0 -46
- data/templates/app/lib/query_parameter.rb +0 -6
- data/templates/app/serializers/error_serializer.rb +0 -16
- data/templates/app/services/yetto_service.rb +0 -51
- data/templates/app/views/settings/new.json.jbuilder +0 -21
- data/templates/compose.yml +0 -5
- data/templates/config/initializers/000-oj.rb +0 -6
- data/templates/config/initializers/cors.rb +0 -19
- data/templates/config/initializers/filter_parameter_logging.rb +0 -25
- data/templates/config/initializers/inflections.rb +0 -20
- data/templates/config/initializers/lograge.rb +0 -25
- data/templates/config/initializers/opentelemetry.rb +0 -32
- data/templates/config/initializers/sidekiq.rb +0 -11
- data/templates/config/initializers/slack_webhook_logger.rb +0 -17
- data/templates/config/sidekiq.yml +0 -20
- data/templates/script/ngrok +0 -5
- data/templates/test/controllers/settings_controller_test.rb +0 -27
- data/templates/test/fixtures/plug_installation_settings/invalid.json +0 -3
- data/templates/test/fixtures/plug_installation_settings/valid.json +0 -3
- data/templates/test/jobs/update_yetto_job_test.rb +0 -26
- data/templates/test/support/api.rb +0 -76
- data/templates/test/support/webmocks/slack_webmock.rb +0 -24
- data/templates/test/support/webmocks/yetto_webmock.rb +0 -119
- data/templates/test/support/webmocks.rb +0 -5
@@ -0,0 +1,125 @@
|
|
1
|
+
# typed: false
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "test_helper"
|
5
|
+
|
6
|
+
class SettingsControllerTest < ActionDispatch::IntegrationTest
|
7
|
+
include Hephaestus::API::TestHelpers
|
8
|
+
|
9
|
+
include Hephaestus::Webmocks::SlackWebmock
|
10
|
+
include Hephaestus::Webmocks::YettoWebmock
|
11
|
+
include Webmocks::<%= capital_plug_name %>Webmock
|
12
|
+
|
13
|
+
def setup
|
14
|
+
super
|
15
|
+
@valid_<%= plug_name %>_installations = JSON.parse(file_fixture_path("plug_installation_settings", "valid.json").read).deep_symbolize_keys
|
16
|
+
@response = create_installation
|
17
|
+
end
|
18
|
+
|
19
|
+
test "GET /settings without asking for JSON fails" do
|
20
|
+
api(:get, "/settings", headers: nil)
|
21
|
+
|
22
|
+
assert_response :not_acceptable
|
23
|
+
end
|
24
|
+
|
25
|
+
test "GET /settings asking for JSON without number works" do
|
26
|
+
settings_json = api(:get, "/settings")
|
27
|
+
|
28
|
+
assert_response :ok
|
29
|
+
|
30
|
+
settings = settings_json["settings"]
|
31
|
+
|
32
|
+
assert_equal "2023-03-06", settings_json["version"]
|
33
|
+
assert_equal 1, settings.length
|
34
|
+
assert settings.key?("step")
|
35
|
+
end
|
36
|
+
|
37
|
+
test "GET /settings asking for JSON with number works" do
|
38
|
+
settings_json = api(:get, "/settings?step=2")
|
39
|
+
|
40
|
+
assert_response :ok
|
41
|
+
|
42
|
+
settings = settings_json["settings"]
|
43
|
+
|
44
|
+
assert_equal "2023-03-06", settings_json["version"]
|
45
|
+
assert_equal 1, settings.length
|
46
|
+
assert settings.key?("step")
|
47
|
+
end
|
48
|
+
|
49
|
+
test "GET /edit does not panic if Yetto is unavailable" do
|
50
|
+
stub_post_access_token(@plug_installation_id)
|
51
|
+
stub_get_plug_installation(@plug_installation_id, status: 500)
|
52
|
+
|
53
|
+
stub_send_to_slack_log
|
54
|
+
api(:get, "/settings/org_id/inbox_id/#{@plug_installation_id}/edit")
|
55
|
+
|
56
|
+
assert_response :not_acceptable
|
57
|
+
|
58
|
+
assert_requested_send_to_slack_log
|
59
|
+
assert_requested_post_access_token(@plug_installation_id)
|
60
|
+
end
|
61
|
+
|
62
|
+
test "GET /edit does not panic if Yetto provides bad token data" do
|
63
|
+
stub_post_access_token(@plug_installation_id)
|
64
|
+
|
65
|
+
response = {
|
66
|
+
credentials: {},
|
67
|
+
}
|
68
|
+
|
69
|
+
stub_get_plug_installation(@plug_installation_id, response:)
|
70
|
+
|
71
|
+
stub_send_to_slack_log
|
72
|
+
api(:get, "/settings/org_id/inbox_id/#{@plug_installation_id}/edit")
|
73
|
+
|
74
|
+
# error page returned
|
75
|
+
assert_response :bad_request
|
76
|
+
|
77
|
+
assert_requested_send_to_slack_log
|
78
|
+
assert_requested_post_access_token(@plug_installation_id)
|
79
|
+
end
|
80
|
+
|
81
|
+
test "GET /edit works even if step is not provided" do
|
82
|
+
stub_post_access_token(@plug_installation_id)
|
83
|
+
stub_get_plug_installation(@plug_installation_id, response: @response)
|
84
|
+
stub_request_<%= plug_name %>_app_installations
|
85
|
+
|
86
|
+
api(:get, "/settings/org_id/#{@inbox_id}/#{@plug_installation_id}/edit")
|
87
|
+
|
88
|
+
assert_response :ok
|
89
|
+
|
90
|
+
assert_requested_post_access_token(@plug_installation_id)
|
91
|
+
assert_requested_get_plug_installation(@plug_installation_id)
|
92
|
+
assert_requested_<%= plug_name %>_app_installations
|
93
|
+
end
|
94
|
+
|
95
|
+
test "GET /edit works if step is explicitly provided" do
|
96
|
+
stub_post_access_token(@plug_installation_id)
|
97
|
+
stub_get_plug_installation(@plug_installation_id, response: @response)
|
98
|
+
stub_request_<%= plug_name %>_app_installation_repositories
|
99
|
+
|
100
|
+
api(:get, "/settings/org_id/inbox_id/#{@plug_installation_id}/edit?step=2")
|
101
|
+
|
102
|
+
assert_response :ok
|
103
|
+
|
104
|
+
assert_requested_post_access_token(@plug_installation_id)
|
105
|
+
assert_requested_get_plug_installation(@plug_installation_id)
|
106
|
+
assert_requested_<%= plug_name %>_app_installation_repositories
|
107
|
+
end
|
108
|
+
|
109
|
+
test "GET /edit does not panic if <%= capital_plug_name %> is down" do
|
110
|
+
stub_post_access_token(@plug_installation_id)
|
111
|
+
stub_get_plug_installation(@plug_installation_id, response: @response)
|
112
|
+
stub_request_<%= plug_name %>_app_installation_repositories(status: 500)
|
113
|
+
stub_send_to_slack_log
|
114
|
+
|
115
|
+
api(:get, "/settings/org_id/inbox_id/#{@plug_installation_id}/edit?step=2")
|
116
|
+
|
117
|
+
assert_response :not_acceptable
|
118
|
+
|
119
|
+
assert_requested_send_to_slack_log
|
120
|
+
assert_requested_<%= plug_name %>_app_installation_repositories
|
121
|
+
assert_requested_post_access_token(@plug_installation_id)
|
122
|
+
end
|
123
|
+
|
124
|
+
# TODO: Add your own settings tests here
|
125
|
+
end
|
@@ -4,55 +4,61 @@
|
|
4
4
|
require "test_helper"
|
5
5
|
|
6
6
|
class YettoControllerTest < ActionDispatch::IntegrationTest
|
7
|
-
include API::TestHelpers
|
7
|
+
include Hephaestus::API::TestHelpers
|
8
8
|
|
9
|
-
include Webmocks::YettoWebmock
|
9
|
+
include Hephaestus::Webmocks::YettoWebmock
|
10
10
|
|
11
11
|
def setup
|
12
12
|
super
|
13
13
|
@after_create_plug_installation = {
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
yetto: {
|
15
|
+
plug_installation: {
|
16
|
+
id: @plug_installation_id,
|
17
|
+
settings: {},
|
18
|
+
},
|
19
|
+
organization: {
|
20
|
+
id: @organization_id,
|
21
|
+
},
|
22
|
+
plug: {
|
23
|
+
id: @plug_id,
|
24
|
+
},
|
25
|
+
inbox: {
|
26
|
+
id: @inbox_id,
|
19
27
|
},
|
20
|
-
},
|
21
|
-
organization: {
|
22
|
-
id: @organization_id,
|
23
|
-
},
|
24
|
-
plug: {
|
25
|
-
id: @plug_id,
|
26
|
-
},
|
27
|
-
inbox: {
|
28
|
-
id: @inbox_id,
|
29
28
|
},
|
30
29
|
}
|
31
30
|
|
32
31
|
@after_create_message = {
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
message: {
|
39
|
-
id: @message_id,
|
40
|
-
text_content: "blern",
|
41
|
-
html_content: "<p>blern</p>",
|
42
|
-
metadata: {},
|
43
|
-
conversation: {
|
44
|
-
id: @conversation_id,
|
45
|
-
title: "Hey there?",
|
46
|
-
metadata: {
|
47
|
-
"in-reply-to" => "123",
|
48
|
-
},
|
32
|
+
yetto: {
|
33
|
+
plug_installation: {
|
34
|
+
id: @plug_installation_id,
|
35
|
+
settings: {}, # This is where you would put your settings that identify your platform
|
36
|
+
credentials: {},
|
49
37
|
},
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
38
|
+
message: {
|
39
|
+
id: @message_id,
|
40
|
+
text_content: "blern",
|
41
|
+
html_content: "<p>blern</p>",
|
42
|
+
metadata: {},
|
43
|
+
conversation: {
|
44
|
+
id: @conversation_id,
|
45
|
+
title: "Hey there?",
|
46
|
+
metadata: {
|
47
|
+
"in-reply-to" => "123",
|
48
|
+
},
|
49
|
+
inbox: {
|
50
|
+
id: @inbox_id,
|
51
|
+
organization: {
|
52
|
+
id: @organization_id,
|
53
|
+
status: "active",
|
54
|
+
},
|
55
|
+
},
|
56
|
+
},
|
57
|
+
created_by_membership: {
|
58
|
+
user: {
|
59
|
+
name: "someone",
|
60
|
+
},
|
61
|
+
},
|
56
62
|
},
|
57
63
|
},
|
58
64
|
}
|
@@ -60,41 +66,12 @@ class YettoControllerTest < ActionDispatch::IntegrationTest
|
|
60
66
|
|
61
67
|
def headers(body)
|
62
68
|
{
|
63
|
-
Headers::
|
64
|
-
Headers::
|
65
|
-
Headers::
|
69
|
+
Hephaestus::Headers::HEADER_EVENT => "created",
|
70
|
+
Hephaestus::Headers::HEADER_RECORD_TYPE => "plug_installation",
|
71
|
+
Hephaestus::Headers::HEADER_SIGNATURE => yetto_auth_header(body),
|
66
72
|
}
|
67
73
|
end
|
68
74
|
|
69
|
-
test "it handles null headers" do
|
70
|
-
api(:post, "/plug_installation/created", headers: nil)
|
71
|
-
|
72
|
-
assert_response :bad_request
|
73
|
-
end
|
74
|
-
|
75
|
-
test "it handles missing headers" do
|
76
|
-
api(:post, "/plug_installation/created", headers: {})
|
77
|
-
|
78
|
-
assert_response :bad_request
|
79
|
-
end
|
80
|
-
|
81
|
-
test "it handles incorrect headers" do
|
82
|
-
api(:post, "/plug_installation/created", headers: { "X-Yetto-Signature" => "Basic jabroni:lies" })
|
83
|
-
|
84
|
-
assert_response :bad_request
|
85
|
-
|
86
|
-
api(:post, "/plug_installation/created", headers: { "X-Yetto-Signature" => "sha256=123456" })
|
87
|
-
|
88
|
-
assert_response :bad_request
|
89
|
-
end
|
90
|
-
|
91
|
-
test "it handles missing body" do
|
92
|
-
body = {}
|
93
|
-
api(:post, "/plug_installation/created", headers: headers(body), body: body)
|
94
|
-
|
95
|
-
assert_response :bad_request
|
96
|
-
end
|
97
|
-
|
98
75
|
test "it handles wrong event" do
|
99
76
|
body = @after_create_plug_installation
|
100
77
|
api(:post, "/bloop/plug_installation", headers: headers(body), body: body)
|
@@ -105,7 +82,7 @@ class YettoControllerTest < ActionDispatch::IntegrationTest
|
|
105
82
|
test "it handles wrong record type" do
|
106
83
|
body = @after_create_plug_installation
|
107
84
|
|
108
|
-
api(:post, "/
|
85
|
+
api(:post, "/plug_instunk/created", headers: headers(body), body: body)
|
109
86
|
|
110
87
|
assert_response :not_found
|
111
88
|
end
|
@@ -126,4 +103,56 @@ class YettoControllerTest < ActionDispatch::IntegrationTest
|
|
126
103
|
|
127
104
|
assert_response :bad_request
|
128
105
|
end
|
106
|
+
|
107
|
+
test "it performs some job to do something to your platform" do
|
108
|
+
incoming_body = @after_create_message
|
109
|
+
|
110
|
+
job_args = {
|
111
|
+
create_issue_data: {
|
112
|
+
gh_installation_id: @after_create_message[:yetto][:plug_installation][:settings][:github_installations],
|
113
|
+
gh_repo_id: @after_create_message[:yetto][:plug_installation][:settings][:github_repositories].to_i,
|
114
|
+
title: @after_create_message[:yetto][:message][:conversation][:title],
|
115
|
+
body: @after_create_message[:yetto][:message][:text_content],
|
116
|
+
},
|
117
|
+
message: {
|
118
|
+
id: @message_id,
|
119
|
+
author: {
|
120
|
+
name: "someone",
|
121
|
+
},
|
122
|
+
metadata: {},
|
123
|
+
},
|
124
|
+
conversation: {
|
125
|
+
id: @conversation_id,
|
126
|
+
},
|
127
|
+
plug_installation: {
|
128
|
+
id: @plug_installation_id,
|
129
|
+
},
|
130
|
+
inbox: {
|
131
|
+
id: @inbox_id,
|
132
|
+
},
|
133
|
+
}
|
134
|
+
|
135
|
+
assert_enqueued_with(job: "SomeJob", args: assert_expected_args(job_args)) do
|
136
|
+
api(:post, "/message/created", body: incoming_body, headers: headers(incoming_body))
|
137
|
+
|
138
|
+
assert_response :no_content
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
# You should also add jobs for when your installation is created, updated, or destroy, similar to
|
143
|
+
# the below EXAMPLE showing how to test the job that is enqueued when a plug installation is updated.
|
144
|
+
# test "it performs UpdateYettoJob after the installation is updated" do
|
145
|
+
# incoming_body = @after_update_plug_installation
|
146
|
+
|
147
|
+
# job_args = {
|
148
|
+
# gh_installation_id: incoming_body[:yetto][:plug_installation][:settings][:github_installations],
|
149
|
+
# gh_repo_id: incoming_body[:yetto][:plug_installation][:settings][:github_repositories].to_i,
|
150
|
+
# }
|
151
|
+
|
152
|
+
# assert_enqueued_with(job: CreateLabelJob, args: assert_expected_args(job_args)) do
|
153
|
+
# api(:post, "/plug_installation/updated", body: incoming_body, headers: headers(incoming_body))
|
154
|
+
|
155
|
+
# assert_response :no_content
|
156
|
+
# end
|
157
|
+
# end
|
129
158
|
end
|
@@ -1,40 +1,20 @@
|
|
1
1
|
# typed: false
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
@conversation_id ||= "cnv_#{Faker::Alphanumeric.alphanumeric(number: 26).upcase}"
|
21
|
-
end
|
22
|
-
|
23
|
-
def file_fixture_path(dir, name)
|
24
|
-
Rails.root.join("test", "fixtures", "files", dir, name)
|
25
|
-
end
|
26
|
-
|
27
|
-
def assert_expected_args(expected_args)
|
28
|
-
lambda do |job_args_arr|
|
29
|
-
job_args_arr.first.each do |actual_args|
|
30
|
-
actual_key = actual_args.first
|
31
|
-
actual_value = actual_args.second
|
32
|
-
|
33
|
-
expected_value = expected_args[actual_key]
|
34
|
-
|
35
|
-
assert_equal(expected_value, actual_value, "Expected `#{actual_key}` to be `#{expected_value.nil? ? "nil" : expected_value}`, but was `#{actual_value.nil? ? "nil" : actual_value}`")
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
4
|
+
def create_installation(valid: true, expires_at: 8.hours.from_now)
|
5
|
+
{
|
6
|
+
installed_on_inbox: {
|
7
|
+
id: @inbox_id,
|
8
|
+
organization: {
|
9
|
+
id: @organization_id,
|
10
|
+
status: "active",
|
11
|
+
},
|
12
|
+
},
|
13
|
+
plug: {
|
14
|
+
id: @plug_id,
|
15
|
+
},
|
16
|
+
# TODO: fill these out!
|
17
|
+
settings: {},
|
18
|
+
credentials: {},
|
19
|
+
}
|
40
20
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# typed: false
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Webmocks
|
5
|
+
module <%= capital_plug_name %>Webmock
|
6
|
+
extend T::Sig
|
7
|
+
extend T::Helpers
|
8
|
+
|
9
|
+
# TODO: Add webmocks here which are specific to your application
|
10
|
+
# For example, if your application interacts with GitHub, you can add webmocks for GitHub here
|
11
|
+
#
|
12
|
+
# sig { params(state: String).returns(T.untyped) }
|
13
|
+
# def assert_requested_user_access_token(state)
|
14
|
+
# assert_requested(:post, "https://github.com/login/oauth/access_token?#{token_query_params(state)}")
|
15
|
+
# end
|
16
|
+
|
17
|
+
# sig { params(state: String, valid: T::Boolean, status: Integer).returns(T.untyped) }
|
18
|
+
# def stub_request_user_access_token(state, valid: true, status: 200)
|
19
|
+
# response_body = JSON.parse(file_fixture_path("gh_access_token", valid ? "valid.json" : "invalid.json").read).deep_symbolize_keys
|
20
|
+
# stub_request(:post, "https://github.com/login/oauth/access_token?#{token_query_params(state)}")
|
21
|
+
# .to_return(
|
22
|
+
# status: status,
|
23
|
+
# headers: { content_type: "application/json; charset=utf-8" },
|
24
|
+
# body: response_body.to_json,
|
25
|
+
# )
|
26
|
+
# end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -1,37 +1,7 @@
|
|
1
1
|
# typed: false
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require "
|
4
|
+
require "hephaestus/test_helper"
|
5
5
|
|
6
|
-
if ENV["COVERAGE"] == "1"
|
7
|
-
require "simplecov"
|
8
|
-
require "simplecov-console"
|
9
|
-
|
10
|
-
SimpleCov.start("rails")
|
11
|
-
|
12
|
-
# do not crash on failure; we want a distinct job to report the coverage error
|
13
|
-
module SimpleCov
|
14
|
-
class << self
|
15
|
-
def result_exit_status(_)
|
16
|
-
SimpleCov::ExitCodes::SUCCESS
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
require "httpx"
|
23
|
-
require "webmock/minitest"
|
24
|
-
require "httpx/adapters/webmock"
|
25
|
-
WebMock.enable!
|
26
|
-
WebMock.disable_net_connect!(allow_localhost: true)
|
27
|
-
|
28
|
-
require_relative "support/rails"
|
29
|
-
|
30
|
-
require "minitest/pride"
|
31
|
-
|
32
|
-
require "webmock/minitest"
|
33
6
|
# Load everything else from test/support
|
34
7
|
Dir[File.expand_path("support/**/*.rb", __dir__)].each { |rb| require(rb) }
|
35
|
-
|
36
|
-
# https://github.com/freerange/mocha#rails
|
37
|
-
require "mocha/minitest"
|
@@ -2,16 +2,12 @@
|
|
2
2
|
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
|
3
3
|
#
|
4
4
|
|
5
|
-
app = "plug
|
5
|
+
app = "plug-<%= plug_name %>-production"
|
6
6
|
primary_region = "iad"
|
7
7
|
|
8
|
-
[env]
|
9
|
-
RAILS_ENV = "production"
|
10
|
-
LD_PRELOAD_PATH = "/usr/lib/x86_64-linux-gnu/libjemalloc.so.2"
|
11
|
-
|
12
8
|
[processes]
|
13
|
-
web = "
|
14
|
-
|
9
|
+
web = "/app/bin/rails server"
|
10
|
+
supervisor = "/app/bin/jobs"
|
15
11
|
|
16
12
|
[[vm]]
|
17
13
|
cpu_kind = "performance"
|
@@ -23,7 +19,17 @@ processes = ["web"]
|
|
23
19
|
cpu_kind = "performance"
|
24
20
|
cpus = 1
|
25
21
|
memory = "2gb"
|
26
|
-
processes = ["
|
22
|
+
processes = ["supervisor"]
|
23
|
+
|
24
|
+
[[restart]]
|
25
|
+
policy = "always"
|
26
|
+
retries = 5
|
27
|
+
processes = ["supervisor"]
|
28
|
+
|
29
|
+
[[restart]]
|
30
|
+
policy = "on-failure"
|
31
|
+
retries = 5
|
32
|
+
processes = ["web"]
|
27
33
|
|
28
34
|
[http_service]
|
29
35
|
internal_port = 3000
|
@@ -39,13 +45,20 @@ hard_limit = 250
|
|
39
45
|
|
40
46
|
[checks]
|
41
47
|
[checks.alive]
|
42
|
-
type = "
|
43
|
-
interval = "
|
48
|
+
type = "http"
|
49
|
+
interval = "10s"
|
44
50
|
timeout = "2s"
|
45
51
|
grace_period = "5s"
|
52
|
+
method = "GET"
|
53
|
+
path = "/up"
|
54
|
+
protocol = "http"
|
55
|
+
tls_skip_verify = false
|
56
|
+
processes = ["web"]
|
57
|
+
[checks.alive.headers]
|
58
|
+
X-Forwarded-Proto = "https"
|
46
59
|
|
47
60
|
[[statics]]
|
48
|
-
guest_path = "/plug
|
61
|
+
guest_path = "/plug-<%= plug_name %>/public"
|
49
62
|
url_prefix = "/"
|
50
63
|
|
51
64
|
[deploy]
|
@@ -1,13 +1,13 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
#
|
2
|
+
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
|
3
|
+
#
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
LD_PRELOAD_PATH = "/usr/lib/x86_64-linux-gnu/libjemalloc.so.2"
|
5
|
+
app = "plug-<%= plug_name %>-staging"
|
6
|
+
primary_region = "iad"
|
7
7
|
|
8
8
|
[processes]
|
9
|
-
web = "
|
10
|
-
|
9
|
+
web = "/app/bin/rails server"
|
10
|
+
supervisor = "/app/bin/jobs"
|
11
11
|
|
12
12
|
[[vm]]
|
13
13
|
cpu_kind = "shared"
|
@@ -19,7 +19,11 @@ processes = ["web"]
|
|
19
19
|
cpu_kind = "shared"
|
20
20
|
cpus = 2
|
21
21
|
memory = "1gb"
|
22
|
-
processes = ["
|
22
|
+
processes = ["supervisor"]
|
23
|
+
|
24
|
+
[[restart]]
|
25
|
+
policy = "on-failure"
|
26
|
+
retries = 5
|
23
27
|
|
24
28
|
[http_service]
|
25
29
|
internal_port = 3000
|
@@ -33,15 +37,14 @@ type = "requests"
|
|
33
37
|
soft_limit = 200
|
34
38
|
hard_limit = 250
|
35
39
|
|
36
|
-
[
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
grace_period = "5s"
|
40
|
+
[[services]]
|
41
|
+
auto_stop_machines = "stop"
|
42
|
+
auto_start_machines = true
|
43
|
+
min_machines_running = 0
|
44
|
+
processes = ["supervisor"]
|
42
45
|
|
43
46
|
[[statics]]
|
44
|
-
guest_path = "/plug
|
47
|
+
guest_path = "/plug-<%= plug_name %>/public"
|
45
48
|
url_prefix = "/"
|
46
49
|
|
47
50
|
[deploy]
|