brut 0.20.2 → 0.21.0.pre.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 39d165900ee11f8529aa2ec3d5faf4f33d0536353d8591ca5ab39a61ebf0dc70
4
- data.tar.gz: 9aa0545b1cca012ad3df9d408e2d3b3c02d14748d873ad989be1487df290d34e
3
+ metadata.gz: 465fa110056a12dd5c33e2fac0754dfbba25c5928f23e4fb08f3f5976cf9a384
4
+ data.tar.gz: 3c6598da1ce0bf9e2655c56fb4edce22293a90d98cfef9cab855df210e5964fb
5
5
  SHA512:
6
- metadata.gz: e4d1a6a1fdbf7117347f9a684d91f0c295afab512de3e48a1a793d06c226edcdf908555dabf325e54ba1bfe259ef611190a0e7180069615381b71fcd430865b1
7
- data.tar.gz: 4400854bececb851407b21a500cfcb1fc3353583d5225ee907de21df42fb5258df2f6d322d6ac461a56eb06aa04488330858445415f816996f9e6227ac953d22
6
+ metadata.gz: 183335e5d4fc53b5d30ac5eb1c783bad929b782860d2de117ece54e1ac26e96f52466bfd36e8fc26d6e7209a1a88c8337e08a1c3cc30091ed5687baad063c137
7
+ data.tar.gz: 4c744e3e2d7f8c6e02d6ed6f3f0192af1184fea1aa4ccc66e068a68bade6ed0a4abf03b2a8a2562991dd39b1e4cad840bd3e28251ef0ab48c7cb8c6bc1cba100
@@ -0,0 +1,62 @@
1
+ # Describes your app's need for deployment, which can drive
2
+ # the automatic deploy system. You must subclass this in
3
+ # deploy/deploy_config.rb. This class is used in a somewhat
4
+ # isolated environment, so you will not have access to your
5
+ # app's Brut configuration or any of your app's code.
6
+ # To say it another way, this is a way to store
7
+ # configuration information without having to use YAML. You're welcome.
8
+ class Brut::CLI::Apps::Deploy::DeployConfig
9
+
10
+ # Override this to push to another registory
11
+ def registry_hostname = nil
12
+
13
+ # Returns the Docker platform for which the images should be built
14
+ def platform = "linux/amd64"
15
+
16
+ # Returns a hash where each key is the name of a process
17
+ # you wish to run, other than the default, 'web'.
18
+ # The keys are largely arbitrary and for documentation purposes,
19
+ # however you are advised to make them ASCII alphanumerics only
20
+ # with no whitespace.
21
+ #
22
+ # The values of each key should be an instance `ProcessDescription`.
23
+ #
24
+ # @example Running Sidekiq
25
+ #
26
+ # class AppDeployConfig < Brut::CLI::Apps::Deploy::DeployConfig
27
+ # def additional_processes = [
28
+ # ProcessDescription.new(name: "sidekiq", cmd: "bin/run sidekiq")
29
+ # ]
30
+ # end
31
+ #
32
+ #
33
+ def additional_processes = []
34
+
35
+ # Returns all processes this app needs in production.
36
+ # Generally, do not override this since it configures your
37
+ # web process. Override {#additional_processes} instead.
38
+ def processes = [
39
+ process_description("web", ["bundle", "exec", "bin/run"])
40
+ ] + (additional_processes || [])
41
+
42
+ private def process_description(name,cmd)
43
+ ProcessDescription.new(name:, cmd:)
44
+ end
45
+
46
+
47
+ # Describes a process you wish to run in production.
48
+ class ProcessDescription
49
+
50
+ attr_reader :name, :cmd
51
+
52
+ def initialize(name:, cmd:)
53
+ @name = name
54
+ @cmd = Array(cmd)
55
+ end
56
+
57
+ def cmd_directive
58
+ "CMD [ " + @cmd.map { "\"#{it}\"" }.join(", ") + " ]"
59
+ end
60
+
61
+ end
62
+ end
@@ -0,0 +1,54 @@
1
+ class Brut::CLI::Apps::Deploy::GitChecks
2
+ def initialize(executor:)
3
+ @executor = executor
4
+ end
5
+ class Results
6
+ attr_reader :errors
7
+ def initialize(errors = {})
8
+ @errors = errors
9
+ end
10
+ def errors? = errors.any?
11
+ end
12
+ def check!
13
+ branch = ""
14
+ @executor.system!("git branch --show-current") do |output|
15
+ branch << output
16
+ end
17
+ branch = branch.strip.chomp
18
+ if branch != "main"
19
+ return Results.new("main-branch" => "You are on branch '#{branch}', but should be on branch 'main'")
20
+ end
21
+
22
+ @executor.system!("git status") do |*| # reset local caches to account for Docker/host wierdness
23
+ # ignore
24
+ end
25
+ local_changes = ""
26
+ @executor.system!("git diff-index --name-only HEAD --") do |output|
27
+ local_changes << output
28
+ end
29
+ if local_changes.strip != ""
30
+ return Results.new("local-changes" => "The following files have not been checked in: #{local_changes}")
31
+ end
32
+
33
+ rev_list = ""
34
+ @executor.system!("git rev-list --left-right --count origin/main...main") do |output|
35
+ rev_list << output
36
+ end
37
+ remote_ahead, local_ahead = rev_list.strip.chomp.split(/\t/,2).map(&:to_i)
38
+ if remote_ahead != 0
39
+ if remote_ahead == 1
40
+ return Results.new("remote-ahead" => "There is 1 commit in origin you don't have")
41
+ else
42
+ return Results.new("remote-ahead" => "There are #{remote_ahead} commits in origin you don't have")
43
+ end
44
+ end
45
+ if local_ahead != 0
46
+ if local_ahead == 1
47
+ return Results.new("remote-behind" => "There is 1 commit not pushed to origin")
48
+ else
49
+ return Results.new("remote-behind" => "There are #{local_ahead} commits not pushed to origin")
50
+ end
51
+ end
52
+ Results.new
53
+ end
54
+ end