releasecop 0.0.15 → 0.0.17

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: af566f86d4d9ba07fffb0d31d5178ae98b71fa236407191062a27e90d5330576
4
- data.tar.gz: 10f0cf6103e2e17008f0ae0a5f1aa9bef9ba15aba6187ba391e2b6dc13e44f58
3
+ metadata.gz: e67b286ebaca81d5f18df0fa1a22434288d31149aa015dfa5f5a862ca7d46a41
4
+ data.tar.gz: ca42df31717398673e2df330b5d98152379a309c8fd6c761c0e6af341436ab38
5
5
  SHA512:
6
- metadata.gz: cc1a98899976b864d535b63108ccb33bbe14aa66a13c0d1c1cd18dc58d9623b3196ce635d6afcb8655015c3cf5f9bc43ad35e09404dd12e9fd8e33da136b8303
7
- data.tar.gz: 77151af1cc35f98a96d43e489015d2fedd10508a010d500a81f5e522d5a15119979b75907f26281b078632616e75ec59c55d4b6b2dde3d035a272a0dc3c63bbd
6
+ metadata.gz: 4eb0cfface184b1789c90487ecc269c9883aa99f641225b516b9b4b5c94e2cb95540c940389b90b16d5dfa9dcf555ce773dd69b4c2a11558b7d43269a59ba6d5
7
+ data.tar.gz: affe10bd19328c250a3746e7eea0e36fed6f71ac4dca8963404843914db2d0135dd2b4714ecdf37371d8fee72bfe09d6cc399ad272d3f007e281accd45d69c30
data/CHANGELOG.md CHANGED
@@ -1,7 +1,13 @@
1
1
  (Next)
2
2
  ------------
3
+ * Add `path` option for environments with `hokusai`, to run hokusai from a subdirectory of the repo.
3
4
  * Your contribution here...
4
5
 
6
+ 0.0.16 (2022-07-27)
7
+ ------------
8
+ * Update README to document both master and main branch approaches.
9
+ * Require fileutils (fixes uninitialized constant Releasecop::Cli::FileUtils (NameError))
10
+
5
11
  0.0.15 (2019-04-05)
6
12
  ---
7
13
  * Update for compatibility with hokusai >=0.5.4 (now incompatible with earlier versions) (57ee7ae56)
data/README.md CHANGED
@@ -22,8 +22,8 @@ In the manifest, each project lists the environments to which code is deployed _
22
22
  {"name": "production", "git": "git@heroku.com:charge-production.git"}
23
23
  ],
24
24
  "heat": [
25
- {"name": "master", "git": "git@github.com:artsy/heat.git"},
26
- {"name": "master-succeeded", "git": "git@github.com:artsy/heat.git", "branch": "master-succeeded"},
25
+ {"name": "main", "git": "git@github.com:artsy/heat.git", "branch": "main"},
26
+ {"name": "succeeded", "git": "git@github.com:artsy/heat.git", "branch": "succeeded"},
27
27
  {"name": "production", "git": "git@github.com:artsy/heat.git", "branch": "production"}
28
28
  ]
29
29
  }
@@ -39,8 +39,8 @@ Example output:
39
39
  staging is up-to-date with master
40
40
  production is up-to-date with staging
41
41
  heat...
42
- master-succeeded is up-to-date with master
43
- production is behind master-succeeded by:
42
+ succeeded is up-to-date with main
43
+ production is behind succeeded by:
44
44
  4557f60 2015-03-24 Upgrade to 3.9 (timsmith)
45
45
  f33acc4 2015-03-25 Add support for avatars (janeR)
46
46
  2 project(s) checked. 1 environment(s) out-of-date.
@@ -69,6 +69,14 @@ At this time releasecop is not compatible with projects using [Heroku Pipelines]
69
69
 
70
70
  Releasecop will determine the git SHAs corresponding with each pipeline stage via the `hokusai registry images` command.
71
71
 
72
+ If the project's hokusai configuration doesn't live at the top level of the repo (e.g., in a monorepo), add a `path` property with the subdirectory containing its `hokusai/` directory. `hokusai` commands will be run from there:
73
+
74
+ ```json
75
+ {"name": "production", "git": "git@github.com:artsy/artsy-agent.git", "hokusai": "production", "path": "apps/agent-web"}
76
+ ```
77
+
78
+ Note that `path` only affects where hokusai is run; comparisons still cover every commit in the repo.
79
+
72
80
  ### Tagged Releases
73
81
 
74
82
  Many teams create git tags corresponding to each milestone or release. The `tag_pattern` property can be used to match sets of tags corresponding to an environment. E.g.:
@@ -76,7 +84,7 @@ Many teams create git tags corresponding to each milestone or release. The `tag_
76
84
  ```json
77
85
  {
78
86
  "causality": [
79
- {"name": "master", "git": "git@github.com:artsy/causality.git" },
87
+ {"name": "main", "git": "git@github.com:artsy/causality.git", "branch": "main" },
80
88
  {"name": "staging", "git": "git@github.com:artsy/causality.git", "tag_pattern": "staging-*"},
81
89
  {"name": "production", "git": "git@github.com:artsy/causality.git", "tag_pattern": "release-*"}
82
90
  ]
@@ -85,5 +93,8 @@ Many teams create git tags corresponding to each milestone or release. The `tag_
85
93
 
86
94
  The most recent commit matching each tag expression is presumed to correspond with the state of each environment. Tag patterns follow `git` conventions, so, e.g., `staging-*` will be treated as `/refs/tags/staging-*`.
87
95
 
96
+ ### A note about default branch names
97
+
98
+ For backwards compatibility, `releasecop` assumes a default branch name of `master`. To override this behavior, set the `RELEASECOP_DEFAULT_BRANCH` environment variable (to e.g. `main`).
88
99
 
89
100
  Copyright (c) 2015-2018 Joey Aghion, Artsy
@@ -1,13 +1,13 @@
1
1
  module Releasecop
2
2
  class ManifestItem
3
- OPTION_KEYS = %w[hokusai tag_pattern aws_access_key_id aws_secret_access_key]
3
+ OPTION_KEYS = %w[hokusai path tag_pattern aws_access_key_id aws_secret_access_key]
4
4
  attr_reader :git, :branch, :name
5
5
 
6
6
  def initialize(repo_name, item)
7
7
  @repo_name = repo_name
8
8
  @git = item['git']
9
9
  @name = item['name']
10
- @branch = item['branch'] || 'master'
10
+ @branch = item['branch'] || ENV['RELEASECOP_DEFAULT_BRANCH'] || 'master'
11
11
  @options = item.select { |k, _v| OPTION_KEYS.include?(k) }
12
12
  end
13
13
 
@@ -24,13 +24,26 @@ module Releasecop
24
24
  private
25
25
 
26
26
  def find_hokusai_sha
27
- images_output = with_aws_env { `hokusai registry images --limit 1000` } # list as many items as possible
27
+ images_output = in_path { with_aws_env { `hokusai registry images --limit 1000` } } # list as many items as possible
28
28
  tags = images_output.lines.grep(/\d{4}.* \| .*/).map do |l| # lines listing images
29
29
  l.split(' | ').last.gsub(/\e\[(\d+)(\;\d+)*m/, '').split(',').map(&:strip) # tags
30
30
  end
31
31
  tags.detect{|t| t.include?(@options['hokusai']) }.detect{|t| t[/^[0-9a-f]{40}$/]} # first SHA-seeming tag matching environment
32
32
  end
33
33
 
34
+ # Runs the block in the configured subdirectory of the repo (where the project's hokusai/ config lives), if any.
35
+ def in_path(&block)
36
+ path = @options['path'].to_s
37
+ return yield if path.empty? || path == '.'
38
+
39
+ if Pathname.new(path).absolute? || Pathname.new(path).cleanpath.each_filename.include?('..')
40
+ raise ArgumentError, "path must be relative to the repo root: #{path}"
41
+ end
42
+ raise ArgumentError, "path not found in #{@repo_name} repo: #{path}" unless File.directory?(path)
43
+
44
+ Dir.chdir(path, &block)
45
+ end
46
+
34
47
  def find_tag_pattern_sha
35
48
  `git for-each-ref --format='%(objectname)' --count=1 --sort=-authordate --sort=-committerdate --sort=-creatordate 'refs/tags/#{@options['tag_pattern']}'`.strip
36
49
  end
@@ -1,3 +1,3 @@
1
1
  module Releasecop
2
- VERSION = "0.0.15"
2
+ VERSION = "0.0.17"
3
3
  end
data/lib/releasecop.rb CHANGED
@@ -1,11 +1,14 @@
1
+
1
2
  require "releasecop/version"
2
3
  require 'thor'
3
4
  require 'shellwords'
4
5
  require 'json'
6
+ require 'pathname'
5
7
  require 'releasecop/manifest_item'
6
8
  require "releasecop/comparison"
7
9
  require "releasecop/result"
8
10
  require "releasecop/checker"
11
+ require 'fileutils'
9
12
  require "releasecop/cli"
10
13
 
11
14
  module Releasecop
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: releasecop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joey Aghion
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-05 00:00:00.000000000 Z
11
+ date: 2026-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -66,7 +66,7 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- description:
69
+ description:
70
70
  email:
71
71
  - joey@aghion.com
72
72
  executables:
@@ -93,7 +93,7 @@ homepage: https://github.com/joeyAghion/releasecop
93
93
  licenses:
94
94
  - MIT
95
95
  metadata: {}
96
- post_install_message:
96
+ post_install_message:
97
97
  rdoc_options: []
98
98
  require_paths:
99
99
  - lib
@@ -108,9 +108,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0'
110
110
  requirements: []
111
- rubyforge_project:
112
- rubygems_version: 2.7.6
113
- signing_key:
111
+ rubygems_version: 3.4.19
112
+ signing_key:
114
113
  specification_version: 4
115
114
  summary: Given a list of projects and environments pipelines, report which environments
116
115
  are "behind" and by which commits.