metaractor 3.1.1 → 3.2.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: 70a949834d71b20665b6acc4e7e820de727a333226e26af6fa4f0c5cfa7c431d
4
- data.tar.gz: 9e4fa64a34d534f2725a24bb7d3c4e9c963d61a36530a9d4b5543c29193c29fa
3
+ metadata.gz: 3a84ca8402879e172bd7dfb5cd494b41de2639e85080b3052c503a68d4406234
4
+ data.tar.gz: 6db8d581e34cb71fcbf27bcb590978d31301b7ad232fc478e31d7d9fae213eff
5
5
  SHA512:
6
- metadata.gz: b23927d92d66bd17b109e5519cba3e9a25439e04866d9d5159be09d3bcd2802da5a5c31e01c3c8124bae1f7128fff6d46c0f82f9d3faefe4ddac0955a015a1e3
7
- data.tar.gz: 9a157b4b2d932b3c8b730ee6ffd11dca110395fb8cf859ea30a13073fb60c89373ab38515d571120ce7814661f00aa24fcdfbbfc4eadffde177387288ee7dc2d
6
+ metadata.gz: 364eb4ae9ddcf5a836ea876ecece48013c16b20b4a82a354c4e277d954df3cb828ba8252d48b3302dbd597f908f6c52a73909124cb3101a2e6a6b69e2f97afc6
7
+ data.tar.gz: dd45bf611c8edfafadc6fce753f682f429803082157a66f5c9c92e3a2daa7981d98483a65fd88bd73a5bf55c8cfd83edc92692e48e58186631fdf2a38397bf67
@@ -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,7 +52,7 @@ 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
@@ -65,23 +67,22 @@ 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
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:2.7.6-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.20
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/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: .
@@ -15,6 +14,7 @@ services:
15
14
  volumes:
16
15
  - bundler-data:/usr/local/bundle
17
16
  - .:/metaractor
17
+
18
18
  release:
19
19
  image: outstand/metaractor:dev
20
20
  stdin_open: true
@@ -27,8 +27,9 @@ services:
27
27
  - bundler-data:/usr/local/bundle
28
28
  - ~/.gitconfig:/home/metaractor/.gitconfig
29
29
  - ~/.gitconfig.user:/home/metaractor/.gitconfig.user
30
- - ~/.ssh/id_rsa:/home/metaractor/.ssh/id_rsa
31
- - ~/.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
32
33
 
33
34
  volumes:
34
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
@@ -27,7 +29,7 @@ if [ "$1" = 'bundle' ]; then
27
29
  elif ls /usr/local/bundle/bin | grep -q "\b$1\b"; then
28
30
  set -- su-exec metaractor bundle exec "$@"
29
31
 
30
- su-exec metaractor ash -c 'bundle check || bundle install'
32
+ su-exec metaractor bash -c 'bundle check || bundle install'
31
33
  fi
32
34
 
33
35
  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
@@ -1,3 +1,3 @@
1
1
  module Metaractor
2
- VERSION = "3.1.1"
2
+ VERSION = "3.2.0"
3
3
  end
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.1
4
+ version: 3.2.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-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: interactor
@@ -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
@@ -190,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
192
  version: '0'
191
193
  requirements: []
192
194
  rubygems_version: 3.1.6
193
- signing_key:
195
+ signing_key:
194
196
  specification_version: 4
195
197
  summary: Adds parameter validation and error control to interactor
196
198
  test_files: []