metaractor 3.1.0 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 285b4aecd4d684716db6d574e443464ba4fecaca03f49417153d4eb2d49994e4
4
- data.tar.gz: bea5769c3cb76692d1f1a1218fae8937500ae2cdec53dfda5d17066170a723b8
3
+ metadata.gz: 8a67b3860db00780ce1c03f5c551fdb7bbace32bdd7e16d6adabadb541516cb0
4
+ data.tar.gz: 2c24a4a91199c196eae047b09830891ff5ea3c0fd2e2d734acfe57059775fc74
5
5
  SHA512:
6
- metadata.gz: 78226f45df08e38363d19cf03e3ec7867d0788700abf11daa08d5eca31ff62f3e9c43460d39be9d9422a686ee1a0da35de323df54d49ea06962876a809f3ad06
7
- data.tar.gz: 76dee36d5fd30560f4bb7ebee50cf1e59d984e70bc219107e2d439024523ed2992056baacb17227e294466f4cff75b58cd96c7bb8fc0b680438ee8bf367e057c
6
+ metadata.gz: 40fdf35588580edf4b57e719958bad16f6dece4e74fd7a4c202c03a3aab47c6c7647fe90c2152a84eb6e8fd20a1bafd84e137efea9676cbd75966b39f22cacff
7
+ data.tar.gz: 30fdcf53265820b0e510823730ed027e64171316f757b4047b304ba7f9a1bcc9e95b63016114ee4f2807c2a7a1cb94fc8779ecbb9adca47fd4ea8c0a17fa5245
@@ -5,22 +5,23 @@ env:
5
5
  # BUILDKITE_PLUGIN_DOCKER_COMPOSE_UPLOAD_CONTAINER_LOGS: "always"
6
6
  BUILDKITE_PLUGIN_DOCKER_COMPOSE_PULL_RETRIES: 5
7
7
  BUILDKITE_PLUGIN_DOCKER_COMPOSE_PUSH_RETRIES: 5
8
- PLUGIN_DOCKER_COMPOSE_VERSION: "17bac3aaee1360e39381b89bb45513b11838238e"
9
- PLUGIN_DOCKER_CACHE_VERSION: "f3d8feb52a25c69c75565e9f0b80375eae51850a"
8
+ PLUGIN_DOCKER_COMPOSE_VERSION: "03d746fbf5171b217b732ff7d8a3e417d664df1c"
9
+ PLUGIN_DOCKER_CACHE_VERSION: "50ecc80f736a4a3a0ab1f5990e58ae8e536c85e1"
10
+ WORKSPACE_DIR: "${BUILDKITE_BUILD_CHECKOUT_PATH}"
10
11
 
11
12
  steps:
12
13
  - label: ":docker: Build"
13
- command: ./docker/ci-prep.sh
14
14
  key: build
15
15
  plugins:
16
- - seek-oss/aws-sm#v2.2.1:
16
+ - seek-oss/aws-sm#v2.3.1:
17
17
  env:
18
18
  DOCKER_LOGIN_PASSWORD: "/buildkite/docker_password"
19
19
 
20
- - docker-login#v2.0.1:
20
+ - docker-login#v2.1.0:
21
21
  username: outstandci
22
+ retries: 2
22
23
 
23
- - ecr#v2.1.1:
24
+ - ecr#v2.5.0:
24
25
  login: true
25
26
  region: "us-east-1"
26
27
 
@@ -28,21 +29,22 @@ steps:
28
29
  build: metaractor
29
30
  image-repository: 786715713882.dkr.ecr.us-east-1.amazonaws.com/ci-images
30
31
  config:
31
- - docker-compose.yml
32
+ - compose.yml
32
33
 
33
34
  - label: ":bundler: :rubygems:"
34
35
  key: bundle_install
35
36
  command: bundle install
36
37
  depends_on: build
37
38
  plugins:
38
- - seek-oss/aws-sm#v2.2.1:
39
+ - seek-oss/aws-sm#v2.3.1:
39
40
  env:
40
41
  DOCKER_LOGIN_PASSWORD: "/buildkite/docker_password"
41
42
 
42
- - docker-login#v2.0.1:
43
+ - docker-login#v2.1.0:
43
44
  username: outstandci
45
+ retries: 2
44
46
 
45
- - ecr#v2.1.1:
47
+ - ecr#v2.5.0:
46
48
  login: true
47
49
  region: "us-east-1"
48
50
 
@@ -50,13 +52,13 @@ steps:
50
52
  run: metaractor
51
53
  dependencies: false
52
54
  config:
53
- - docker-compose.yml
55
+ - compose.yml
54
56
 
55
57
  - https://github.com/outstand/docker-cache-buildkite-plugin.git#${PLUGIN_DOCKER_CACHE_VERSION}:
56
58
  name: bundler-cache
57
59
  keys:
58
- - v1-bundler-cache-{{ arch }}-{{ checksum "metaractor.gemspec" }}-{{ checksum "Gemfile" }}
59
- - v1-bundler-cache-{{ arch }}-
60
+ - v2-bundler-cache-{{ arch }}-{{ checksum "metaractor.gemspec" }}-{{ checksum "Gemfile" }}
61
+ - v2-bundler-cache-{{ arch }}-
60
62
  save: true
61
63
  volumes:
62
64
  - bundler-data
@@ -65,28 +67,27 @@ steps:
65
67
  command: rspec spec
66
68
  depends_on: bundle_install
67
69
  plugins:
68
- - seek-oss/aws-sm#v2.2.1:
70
+ - seek-oss/aws-sm#v2.3.1:
69
71
  env:
70
72
  DOCKER_LOGIN_PASSWORD: "/buildkite/docker_password"
71
- json-to-env:
72
- - secret-id: "/buildkite/rails/env_vars"
73
73
 
74
- - docker-login#v2.0.1:
74
+ - docker-login#v2.1.0:
75
75
  username: outstandci
76
+ retries: 2
76
77
 
77
- - ecr#v2.1.1:
78
+ - ecr#v2.5.0:
78
79
  login: true
79
80
  region: "us-east-1"
80
81
 
81
82
  - https://github.com/outstand/docker-compose-buildkite-plugin.git#${PLUGIN_DOCKER_COMPOSE_VERSION}:
82
83
  run: metaractor
83
84
  config:
84
- - docker-compose.yml
85
+ - compose.yml
85
86
 
86
87
  - https://github.com/outstand/docker-cache-buildkite-plugin.git#${PLUGIN_DOCKER_CACHE_VERSION}:
87
88
  name: bundler-cache
88
89
  keys:
89
- - v1-bundler-cache-{{ arch }}-{{ checksum "metaractor.gemspec" }}-{{ checksum "Gemfile" }}
90
- - v1-bundler-cache-{{ arch }}-
90
+ - v2-bundler-cache-{{ arch }}-{{ checksum "metaractor.gemspec" }}-{{ checksum "Gemfile" }}
91
+ - v2-bundler-cache-{{ arch }}-
91
92
  volumes:
92
93
  - bundler-data
data/.gitignore CHANGED
@@ -7,4 +7,3 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
- /Deskfile
data/Deskfile ADDED
@@ -0,0 +1,3 @@
1
+ rspec() {
2
+ docker compose run --rm metaractor rspec "$@"
3
+ }
data/Dockerfile CHANGED
@@ -1,39 +1,78 @@
1
+ FROM outstand/su-exec:latest as su-exec
1
2
  FROM outstand/fixuid as fixuid
2
3
 
3
- FROM ruby:2.7.3-alpine
4
+ FROM ruby:3.1.2-bullseye
4
5
  LABEL maintainer="Ryan Schlesinger <ryan@outstand.com>"
5
6
 
6
- RUN addgroup -g 1000 -S metaractor && \
7
- adduser -u 1000 -S -s /bin/ash -G metaractor metaractor && \
8
- apk add --no-cache \
9
- ca-certificates \
10
- tini \
11
- su-exec \
12
- build-base \
13
- git \
14
- openssh
7
+ SHELL ["/bin/bash", "-o", "pipefail", "-c"]
8
+ ENV DEBIAN_FRONTEND=noninteractive
15
9
 
10
+ RUN set -eux; \
11
+ \
12
+ groupadd -g 1000 metaractor && \
13
+ useradd -u 1000 -g metaractor -ms /bin/bash metaractor && \
14
+ \
15
+ apt-get update -y; \
16
+ apt-get install -y \
17
+ ca-certificates \
18
+ curl \
19
+ git \
20
+ build-essential \
21
+ tini \
22
+ ; \
23
+ apt-get clean; \
24
+ rm -f /var/lib/apt/lists/*_*
25
+
26
+ # install su-exec
27
+ COPY --from=su-exec /sbin/su-exec /sbin/su-exec
28
+
29
+ # install fixuid
16
30
  COPY --from=fixuid /usr/local/bin/fixuid /usr/local/bin/fixuid
17
- RUN chmod 4755 /usr/local/bin/fixuid && \
18
- USER=metaractor && \
19
- GROUP=metaractor && \
20
- mkdir -p /etc/fixuid && \
31
+ RUN set -eux; \
32
+ \
33
+ chmod 4755 /usr/local/bin/fixuid; \
34
+ USER=metaractor; \
35
+ GROUP=metaractor; \
36
+ mkdir -p /etc/fixuid; \
21
37
  printf "user: $USER\ngroup: $GROUP\n" > /etc/fixuid/config.yml
22
38
 
23
- ENV BUNDLER_VERSION 2.2.16
24
- RUN gem install bundler -v ${BUNDLER_VERSION} -i /usr/local/lib/ruby/gems/$(ls /usr/local/lib/ruby/gems) --force
39
+ ENV BUNDLER_VERSION 2.3.21
40
+ ENV GITHUB_CLI_VERSION 2.14.4
41
+ ENV GITHUB_CLI_CHECKSUM b0073fdcc07d1de5a19a1a782c7ad9f593f991da06a809ea39f0b6148869aa96
42
+ RUN set -eux; \
43
+ \
44
+ mkdir -p /tmp/build; \
45
+ cd /tmp/build; \
46
+ \
47
+ gem install bundler -v ${BUNDLER_VERSION} -i /usr/local/lib/ruby/gems/$(ls /usr/local/lib/ruby/gems) --force; \
48
+ curl -fsSL https://github.com/cli/cli/releases/download/v${GITHUB_CLI_VERSION}/gh_${GITHUB_CLI_VERSION}_linux_amd64.deb -o gh_${GITHUB_CLI_VERSION}_linux_amd64.deb; \
49
+ echo "${GITHUB_CLI_CHECKSUM} gh_${GITHUB_CLI_VERSION}_linux_amd64.deb" | sha256sum --check; \
50
+ apt-get update -y; \
51
+ apt-get install -y --no-install-recommends \
52
+ ./gh_${GITHUB_CLI_VERSION}_linux_amd64.deb \
53
+ ; \
54
+ apt-get clean; \
55
+ rm -f /var/lib/apt/lists/*_*; \
56
+ rm -rf /tmp/build
57
+
58
+ COPY brew-shim /usr/bin/brew
25
59
 
26
60
  WORKDIR /metaractor
27
- RUN chown -R metaractor:metaractor /metaractor
61
+ RUN set -eux; \
62
+ \
63
+ chown -R metaractor:metaractor /metaractor
64
+
28
65
  USER metaractor
29
66
 
30
67
  COPY --chown=metaractor:metaractor Gemfile metaractor.gemspec /metaractor/
31
68
  COPY --chown=metaractor:metaractor lib/metaractor/version.rb /metaractor/lib/metaractor/
32
- RUN git config --global push.default simple
69
+ RUN set -eux; \
70
+ \
71
+ git config --global push.default simple
33
72
  COPY --chown=metaractor:metaractor . /metaractor/
34
73
 
35
74
  USER root
36
75
  COPY docker-entrypoint.sh /docker-entrypoint.sh
37
76
 
38
- ENTRYPOINT ["/sbin/tini", "-g", "--", "/docker-entrypoint.sh"]
77
+ ENTRYPOINT ["/usr/bin/tini", "-g", "--", "/docker-entrypoint.sh"]
39
78
  CMD ["rspec", "spec"]
data/README.md CHANGED
@@ -345,13 +345,16 @@ For more examples of all of the above approaches, please see the specs.
345
345
 
346
346
  ## Development
347
347
 
348
- - `docker-compose build --pull`
349
- - `docker-compose run --rm metaractor` to run specs
348
+ - `docker compose build --pull`
349
+ - `docker compose run --rm metaractor` to run specs
350
+
351
+ or with the Deskfile loaded:
352
+ - `rspec spec`
350
353
 
351
354
  To release a new version:
352
355
  - Update the version number in `version.rb` and commit the result.
353
- - `docker-compose build --pull`
354
- - `docker-compose run --rm release`
356
+ - `docker compose build --pull`
357
+ - `docker compose run --rm release`
355
358
 
356
359
  ## Contributing
357
360
 
data/brew-shim ADDED
@@ -0,0 +1,10 @@
1
+ #!/bin/bash
2
+
3
+ set -euo pipefail
4
+
5
+ # Docker host has the following git config:
6
+ # helper = !$(brew --prefix)/bin/gh auth git-credential
7
+ #
8
+ # We're going to lie inside the container so we can find the local gh
9
+
10
+ echo "/usr"
@@ -1,4 +1,3 @@
1
- version: '3.6'
2
1
  services:
3
2
  metaractor:
4
3
  build: .
@@ -8,9 +7,14 @@ services:
8
7
  environment:
9
8
  FIXUID:
10
9
  FIXGID:
10
+ BUILDKITE:
11
+ BUILDKITE_BUILD_URL:
12
+ BUILDKITE_JOB_ID:
13
+ BUILDKITE_AGENT_ACCESS_TOKEN:
11
14
  volumes:
12
15
  - bundler-data:/usr/local/bundle
13
16
  - .:/metaractor
17
+
14
18
  release:
15
19
  image: outstand/metaractor:dev
16
20
  stdin_open: true
@@ -23,8 +27,9 @@ services:
23
27
  - bundler-data:/usr/local/bundle
24
28
  - ~/.gitconfig:/home/metaractor/.gitconfig
25
29
  - ~/.gitconfig.user:/home/metaractor/.gitconfig.user
26
- - ~/.ssh/id_rsa:/home/metaractor/.ssh/id_rsa
27
- - ~/.gem:/home/metaractor/.gem
30
+ - ~/.config/gh/hosts.yml:/home/metaractor/.config/gh/hosts.yml
31
+ - ~/.local/share/gem/credentials:/home/metaractor/.local/share/gem/credentials
32
+ - ~/.local/share/gem/credentials:/home/metaractor/.gem/credentials
28
33
 
29
34
  volumes:
30
35
  bundler-data:
data/docker-entrypoint.sh CHANGED
@@ -1,6 +1,6 @@
1
- #!/bin/sh
1
+ #!/bin/bash
2
2
 
3
- set -e
3
+ set -euo pipefail
4
4
 
5
5
  su-exec ${FIXUID:?Missing FIXUID var}:${FIXGID:?Missing FIXGID var} fixuid
6
6
 
@@ -13,6 +13,8 @@ chown_dir() {
13
13
  }
14
14
 
15
15
  chown_dir /usr/local/bundle
16
+ chown_dir /home/metaractor/.local/share/gem
17
+ chown_dir /home/metaractor/.gem
16
18
 
17
19
  if [ "$(which "$1")" = '' ]; then
18
20
  if [ "$(ls -A /usr/local/bundle/bin)" = '' ]; then
@@ -24,10 +26,14 @@ fi
24
26
 
25
27
  if [ "$1" = 'bundle' ]; then
26
28
  set -- su-exec metaractor "$@"
29
+ elif [ "$1" = 'rake' ]; then
30
+ set -- su-exec metaractor bundle exec "$@"
31
+
32
+ su-exec metaractor bash -c 'bundle check || bundle install'
27
33
  elif ls /usr/local/bundle/bin | grep -q "\b$1\b"; then
28
34
  set -- su-exec metaractor bundle exec "$@"
29
35
 
30
- su-exec metaractor ash -c 'bundle check || bundle install'
36
+ su-exec metaractor bash -c 'bundle check || bundle install'
31
37
  fi
32
38
 
33
39
  exec "$@"
@@ -71,18 +71,19 @@ module Metaractor
71
71
 
72
72
  def add(error: {}, errors: {}, object: nil)
73
73
  trees = []
74
- [error, errors].each do |h|
74
+ [error, errors].each do |h|
75
75
  tree = nil
76
76
  if h.is_a? Metaractor::Errors
77
77
  tree = Sycamore::Tree.from(h.instance_variable_get(:@tree))
78
78
  else
79
- tree = Sycamore::Tree.from(h)
79
+ tree = Sycamore::Tree.from(normalize_error_hash(h))
80
80
  end
81
81
 
82
82
  unless tree.empty?
83
- if tree.nodes.any? {|node| tree.strict_leaf?(node) }
83
+ if tree.nodes.any? { |node| tree.strict_leaf?(node) }
84
84
  raise ArgumentError, "Invalid hash!"
85
85
  end
86
+
86
87
  trees << tree
87
88
  end
88
89
  end
@@ -220,5 +221,34 @@ module Metaractor
220
221
  end
221
222
  end
222
223
 
224
+ def normalize_error_hash(hash)
225
+ deep_transform_values_in_object(hash, &method(:transform_delegator))
226
+ end
227
+
228
+ def transform_delegator(value)
229
+ if value.is_a?(Delegator)
230
+ if value.respond_to?(:to_hash)
231
+ deep_transform_values_in_object(value.to_hash, &method(:transform_delegator))
232
+ elsif value.respond_to?(:to_a)
233
+ deep_transform_values_in_object(value.to_a, &method(:transform_delegator))
234
+ else
235
+ value
236
+ end
237
+ else
238
+ value
239
+ end
240
+ end
241
+
242
+ # Lifted from Rails
243
+ def deep_transform_values_in_object(object, &block)
244
+ case object
245
+ when Hash
246
+ object.transform_values { |value| deep_transform_values_in_object(value, &block) }
247
+ when Array
248
+ object.map { |e| deep_transform_values_in_object(e, &block) }
249
+ else
250
+ yield(object)
251
+ end
252
+ end
223
253
  end
224
254
  end
@@ -38,6 +38,10 @@ module Metaractor
38
38
  @options[key]
39
39
  end
40
40
 
41
+ def has_key?(key)
42
+ @options.has_key?(key)
43
+ end
44
+
41
45
  def dig(name, *names)
42
46
  @options.dig(name, *names)
43
47
  end
@@ -143,7 +147,7 @@ module Metaractor
143
147
 
144
148
  def apply_defaults
145
149
  parameters.each do |name, parameter|
146
- next unless parameter[:default]
150
+ next unless parameter.has_key?(:default)
147
151
 
148
152
  unless context.has_key?(name)
149
153
  context[name] = _parameter_default(name)
@@ -1,3 +1,3 @@
1
1
  module Metaractor
2
- VERSION = "3.1.0"
2
+ VERSION = "3.3.0"
3
3
  end
data/metaractor.gemspec CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.require_paths = ['lib']
23
23
 
24
24
  spec.add_runtime_dependency 'interactor', '~> 3.1'
25
- spec.add_runtime_dependency 'sycamore', '~> 0.3'
25
+ spec.add_runtime_dependency 'outstand-sycamore', '0.4.0'
26
26
  spec.add_runtime_dependency 'i18n', '~> 1.8'
27
27
 
28
28
  spec.add_development_dependency 'bundler', '~> 2'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metaractor
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Schlesinger
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-04-29 00:00:00.000000000 Z
11
+ date: 2022-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: interactor
@@ -25,19 +25,19 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.1'
27
27
  - !ruby/object:Gem::Dependency
28
- name: sycamore
28
+ name: outstand-sycamore
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: '0.3'
33
+ version: 0.4.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: '0.3'
40
+ version: 0.4.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: i18n
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -136,7 +136,7 @@ dependencies:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: '6.1'
139
- description:
139
+ description:
140
140
  email:
141
141
  - ryan@outstand.com
142
142
  executables: []
@@ -146,12 +146,14 @@ files:
146
146
  - ".buildkite/pipeline.yml"
147
147
  - ".gitignore"
148
148
  - ".rspec"
149
+ - Deskfile
149
150
  - Dockerfile
150
151
  - Gemfile
151
152
  - LICENSE
152
153
  - README.md
153
154
  - Rakefile
154
- - docker-compose.yml
155
+ - brew-shim
156
+ - compose.yml
155
157
  - docker-entrypoint.sh
156
158
  - lib/metaractor.rb
157
159
  - lib/metaractor/chain_failures.rb
@@ -168,13 +170,13 @@ files:
168
170
  - lib/metaractor/spec.rb
169
171
  - lib/metaractor/version.rb
170
172
  - metaractor.gemspec
171
- homepage:
173
+ homepage:
172
174
  licenses:
173
175
  - Apache-2.0
174
176
  metadata:
175
177
  homepage_uri: https://github.com/outstand/metaractor
176
178
  source_code_uri: https://github.com/outstand/metaractor
177
- post_install_message:
179
+ post_install_message:
178
180
  rdoc_options: []
179
181
  require_paths:
180
182
  - lib
@@ -189,8 +191,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
191
  - !ruby/object:Gem::Version
190
192
  version: '0'
191
193
  requirements: []
192
- rubygems_version: 3.1.6
193
- signing_key:
194
+ rubygems_version: 3.3.7
195
+ signing_key:
194
196
  specification_version: 4
195
197
  summary: Adds parameter validation and error control to interactor
196
198
  test_files: []