itamae 1.12.0 → 1.12.1

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: e0be9dd39ba8a2f1e7bf014cab6c6de61ac8c310cfa2e9e95176f586148322a0
4
- data.tar.gz: d36a91d8b5c86c640a21e8759f12decf02cfb2c1ae96babf3121c35a69e6390d
3
+ metadata.gz: a87b38ab15d48a077ad91bb8b3ff7fe8a07df9068a19ec5fbec2b29f4294869f
4
+ data.tar.gz: 6ad7b7f90b63f5d4d44cba8a7335259b55c539f04775812ca1ee9906c91d677c
5
5
  SHA512:
6
- metadata.gz: 682cfc3e44a44b40b72403057613083f14445e62a8e472d6deddcd91bfa8a981a31de9ae1622b75986db1c7af6de03524f6b512036ae5e235cb92108364b37f5
7
- data.tar.gz: 55a70e71f38241a5809e0e857553475675102a3bc17deda94982ff25175f5537ac48e1902629705e79f0acd5642f7d54ecdb6fa727338f90de6cd5abf1ea4e8a
6
+ metadata.gz: bf4bfdb3a108826702395d81176b8b75282809868a6c6562e6e1301c7bdef7633c72358f658b62dee07795aa49d2867d706f4ee499cc2ab5c1d0a9f5ebf8edf6
7
+ data.tar.gz: cc6ec5583ad859f9c09f81aafb1e5a909f9ebbe26c0874a28ae177d5840e1c62cbbcd4f8e176d49fd892cdf166473f7f58243bd5abcfe17164040d743615f1a0
@@ -0,0 +1,200 @@
1
+ name: test
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+ types:
9
+ - opened
10
+ - synchronize
11
+ - reopened
12
+
13
+ jobs:
14
+ unit:
15
+ runs-on: ubuntu-latest
16
+
17
+ strategy:
18
+ fail-fast: false
19
+
20
+ matrix:
21
+ ruby:
22
+ - "2.3"
23
+ - "2.4"
24
+ - "2.5"
25
+ - "2.6"
26
+ - "2.7"
27
+ - "3.0"
28
+ rubyopt:
29
+ - ""
30
+ - "--jit"
31
+ exclude:
32
+ # --jit is available since MRI 2.6
33
+ - ruby: "2.3"
34
+ rubyopt: "--jit"
35
+ - ruby: "2.4"
36
+ rubyopt: "--jit"
37
+ - ruby: "2.5"
38
+ rubyopt: "--jit"
39
+
40
+ env:
41
+ RUBYOPT: ${{ matrix.rubyopt }}
42
+
43
+ steps:
44
+ - uses: actions/checkout@v2
45
+
46
+ - uses: ruby/setup-ruby@v1
47
+ with:
48
+ ruby-version: ${{ matrix.ruby }}
49
+ bundler-cache: true
50
+
51
+ - run: bundle update
52
+
53
+ - run: bundle exec rake spec:unit
54
+
55
+ - name: Slack Notification (not success)
56
+ uses: lazy-actions/slatify@master
57
+ if: "! success()"
58
+ continue-on-error: true
59
+ with:
60
+ job_name: ${{ format('*unit* ({0},{1})', matrix.ruby, matrix.rubyopt) }}
61
+ type: ${{ job.status }}
62
+ icon_emoji: ":octocat:"
63
+ url: ${{ secrets.SLACK_WEBHOOK }}
64
+ token: ${{ secrets.GITHUB_TOKEN }}
65
+
66
+ integration-docker:
67
+ runs-on: ubuntu-latest
68
+
69
+ strategy:
70
+ fail-fast: false
71
+
72
+ matrix:
73
+ ruby:
74
+ - "2.3"
75
+ - "2.4"
76
+ - "2.5"
77
+ - "2.6"
78
+ - "2.7"
79
+ - "3.0"
80
+ rubyopt:
81
+ - ""
82
+ - "--jit"
83
+ image:
84
+ - ubuntu:trusty
85
+ exclude:
86
+ # --jit is available since MRI 2.6
87
+ - ruby: "2.3"
88
+ rubyopt: "--jit"
89
+ - ruby: "2.4"
90
+ rubyopt: "--jit"
91
+ - ruby: "2.5"
92
+ rubyopt: "--jit"
93
+
94
+ env:
95
+ RUBYOPT: ${{ matrix.rubyopt }}
96
+ TEST_IMAGE: ${{ matrix.image }}
97
+
98
+ steps:
99
+ - uses: actions/checkout@v2
100
+
101
+ - uses: ruby/setup-ruby@v1
102
+ with:
103
+ ruby-version: ${{ matrix.ruby }}
104
+ bundler-cache: true
105
+
106
+ - run: bundle update
107
+
108
+ - run: bundle exec rake spec:integration:docker:boot
109
+
110
+ - run: bundle exec rake spec:integration:docker:provision
111
+ env:
112
+ # FIXME: avoid error for "Command `chmod 777 /tmp/itamae_tmp` failed. (exit status: 1)"
113
+ ITAMAE_TMP_DIR: /var/tmp/itamae_tmp
114
+
115
+ - run: bundle exec rake spec:integration:docker:serverspec
116
+ - run: bundle exec rake spec:integration:docker:clean_docker_container
117
+
118
+ - name: Slack Notification (not success)
119
+ uses: lazy-actions/slatify@master
120
+ if: "! success()"
121
+ continue-on-error: true
122
+ with:
123
+ job_name: ${{ format('*integration-docker* ({0},{1},{2})', matrix.ruby, matrix.rubyopt, matrix.image) }}
124
+ type: ${{ job.status }}
125
+ icon_emoji: ":octocat:"
126
+ url: ${{ secrets.SLACK_WEBHOOK }}
127
+ token: ${{ secrets.GITHUB_TOKEN }}
128
+
129
+ integration-local:
130
+ runs-on: ubuntu-latest
131
+
132
+ strategy:
133
+ fail-fast: false
134
+
135
+ matrix:
136
+ ruby:
137
+ - "2.3"
138
+ - "2.4"
139
+ - "2.5"
140
+ - "2.6"
141
+ - "2.7"
142
+ - "3.0"
143
+ rubyopt:
144
+ - ""
145
+ - "--jit"
146
+ exclude:
147
+ # --jit is available since MRI 2.6
148
+ - ruby: "2.3"
149
+ rubyopt: "--jit"
150
+ - ruby: "2.4"
151
+ rubyopt: "--jit"
152
+ - ruby: "2.5"
153
+ rubyopt: "--jit"
154
+
155
+ env:
156
+ RUBYOPT: ${{ matrix.rubyopt }}
157
+
158
+ steps:
159
+ - uses: actions/checkout@v2
160
+
161
+ - uses: ruby/setup-ruby@v1
162
+ with:
163
+ ruby-version: ${{ matrix.ruby }}
164
+ bundler-cache: true
165
+
166
+ - run: bundle update
167
+
168
+ - run: bundle exec rake spec:integration:local:main
169
+ - run: bundle exec rake spec:integration:local:ordinary_user
170
+
171
+ - name: Slack Notification (not success)
172
+ uses: lazy-actions/slatify@master
173
+ if: "! success()"
174
+ continue-on-error: true
175
+ with:
176
+ job_name: ${{ format('*integration-local* ({0},{1})', matrix.ruby, matrix.rubyopt) }}
177
+ type: ${{ job.status }}
178
+ icon_emoji: ":octocat:"
179
+ url: ${{ secrets.SLACK_WEBHOOK }}
180
+ token: ${{ secrets.GITHUB_TOKEN }}
181
+
182
+ notify:
183
+ needs:
184
+ - unit
185
+ - integration-docker
186
+ - integration-local
187
+
188
+ runs-on: ubuntu-latest
189
+
190
+ steps:
191
+ - name: Slack Notification (success)
192
+ uses: lazy-actions/slatify@master
193
+ if: always()
194
+ continue-on-error: true
195
+ with:
196
+ job_name: '*notify*'
197
+ type: ${{ job.status }}
198
+ icon_emoji: ":octocat:"
199
+ url: ${{ secrets.SLACK_WEBHOOK }}
200
+ token: ${{ secrets.GITHUB_TOKEN }}
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  ## Unreleased
2
- [full changelog](https://github.com/itamae-kitchen/itamae/compare/v1.12.0...master)
2
+ [full changelog](https://github.com/itamae-kitchen/itamae/compare/v1.12.1...master)
3
+
4
+ ## v1.12.1
5
+ [full changelog](https://github.com/itamae-kitchen/itamae/compare/v1.12.0...v1.12.1)
6
+
7
+ Improvements
8
+
9
+ - [Allow defining top-level modules without `::`](https://github.com/itamae-kitchen/itamae/pull/332)
3
10
 
4
11
  ## v1.12.0
5
12
  [full changelog](https://github.com/itamae-kitchen/itamae/compare/v1.11.2...v1.12.0)
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # [![](https://raw.githubusercontent.com/itamae-kitchen/itamae-logos/master/small/FA-Itamae-horizontal-01-180x72.png)](https://github.com/itamae-kitchen/itamae)
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/itamae.svg)](http://badge.fury.io/rb/itamae) [![Code Climate](https://codeclimate.com/github/ryotarai/itamae/badges/gpa.svg)](https://codeclimate.com/github/ryotarai/itamae) [![Build Status](https://travis-ci.com/itamae-kitchen/itamae.svg?branch=master)](https://travis-ci.com/itamae-kitchen/itamae) [![Slack](https://img.shields.io/badge/slack-join-blue.svg)](https://join.slack.com/t/itamae/shared_invite/enQtNTExNTI3ODM1NTY5LTM5MWJlZTgwODE0YTUwMThiNzZjN2I1MGNlZjE2NjlmNzg5NTNlOTliMDhkNDNmNTQ2ZTgwMzZjNjI5NDJiZGI)
3
+ [![Gem Version](https://badge.fury.io/rb/itamae.svg)](http://badge.fury.io/rb/itamae) [![Code Climate](https://codeclimate.com/github/ryotarai/itamae/badges/gpa.svg)](https://codeclimate.com/github/ryotarai/itamae) [![Build Status](https://github.com/itamae-kitchen/itamae/workflows/test/badge.svg?branch=master)](https://github.com/itamae-kitchen/itamae/actions?query=workflow%3Atest) [![Slack](https://img.shields.io/badge/slack-join-blue.svg)](https://join.slack.com/t/itamae/shared_invite/enQtNTExNTI3ODM1NTY5LTM5MWJlZTgwODE0YTUwMThiNzZjN2I1MGNlZjE2NjlmNzg5NTNlOTliMDhkNDNmNTQ2ZTgwMzZjNjI5NDJiZGI)
4
4
 
5
5
  Simple and lightweight configuration management tool inspired by Chef.
6
6
 
data/Rakefile CHANGED
@@ -10,6 +10,8 @@ end
10
10
  desc 'Run unit and integration specs.'
11
11
  task :spec => ['spec:unit', 'spec:integration:all']
12
12
 
13
+ TEST_IMAGE = ENV["TEST_IMAGE"] || "ubuntu:trusty"
14
+
13
15
  namespace :spec do
14
16
  RSpec::Core::RakeTask.new("unit") do |task|
15
17
  task.ruby_opts = '-I ./spec/unit'
@@ -17,60 +19,54 @@ namespace :spec do
17
19
  end
18
20
 
19
21
  namespace :integration do
20
- targets = ["ubuntu:trusty"]
21
22
  container_name = 'itamae'
22
23
 
23
- task :all => targets + ['spec:integration:local']
24
+ task :all => ['spec:integration:docker' 'spec:integration:local']
24
25
 
25
- targets.each do |target|
26
- desc "Run provision and specs to #{target}"
27
- task target => ["docker:#{target}", "provision:#{target}", "serverspec:#{target}", 'clean_docker_container']
26
+ desc "Run provision and specs"
27
+ task :docker => ["docker:boot", "docker:provision", "docker:serverspec", 'docker:clean_docker_container']
28
28
 
29
- namespace :docker do
30
- desc "Run docker for #{target}"
31
- task target do
32
- sh "docker run --privileged -d --name #{container_name} #{target} /sbin/init"
33
- end
29
+ namespace :docker do
30
+ desc "Run docker"
31
+ task :boot do
32
+ sh "docker run --privileged -d --name #{container_name} #{TEST_IMAGE} /sbin/init"
34
33
  end
35
34
 
36
- namespace :provision do
37
- desc "Run itamae to #{target}"
38
- task target do
39
- suites = [
40
- [
41
- "spec/integration/recipes/default.rb",
42
- "spec/integration/recipes/default2.rb",
43
- "spec/integration/recipes/redefine.rb",
44
- "spec/integration/recipes/docker.rb",
45
- ],
46
- [
47
- "--dry-run",
48
- "spec/integration/recipes/dry_run.rb",
49
- ],
50
- ]
51
- suites.each do |suite|
52
- cmd = %w!bundle exec ruby -w bin/itamae docker!
53
- cmd << "-l" << (ENV['LOG_LEVEL'] || 'debug')
54
- cmd << "-j" << "spec/integration/recipes/node.json"
55
- cmd << "--container" << container_name
56
- cmd << "--tag" << "itamae:latest"
57
- cmd += suite
35
+ desc "Run itamae"
36
+ task :provision do
37
+ suites = [
38
+ [
39
+ "spec/integration/recipes/default.rb",
40
+ "spec/integration/recipes/default2.rb",
41
+ "spec/integration/recipes/redefine.rb",
42
+ "spec/integration/recipes/docker.rb",
43
+ ],
44
+ [
45
+ "--dry-run",
46
+ "spec/integration/recipes/dry_run.rb",
47
+ ],
48
+ ]
49
+ suites.each do |suite|
50
+ cmd = %w!bundle exec ruby -w bin/itamae docker!
51
+ cmd << "-l" << (ENV['LOG_LEVEL'] || 'debug')
52
+ cmd << "-j" << "spec/integration/recipes/node.json"
53
+ cmd << "--container" << container_name
54
+ cmd << "--tag" << "itamae:latest"
55
+ cmd << "--tmp-dir" << (ENV['ITAMAE_TMP_DIR'] || '/tmp/itamae_tmp')
56
+ cmd += suite
58
57
 
59
- p cmd
60
- unless system(*cmd)
61
- raise "#{cmd} failed"
62
- end
58
+ p cmd
59
+ unless system(*cmd)
60
+ raise "#{cmd} failed"
63
61
  end
64
62
  end
65
63
  end
66
64
 
67
- namespace :serverspec do
68
- desc "Run serverspec tests to #{target}"
69
- RSpec::Core::RakeTask.new(target.to_sym) do |t|
70
- ENV['DOCKER_CONTAINER'] = container_name
71
- t.ruby_opts = '-I ./spec/integration'
72
- t.pattern = "spec/integration/{default,docker}_spec.rb"
73
- end
65
+ desc "Run serverspec tests"
66
+ RSpec::Core::RakeTask.new(:serverspec) do |t|
67
+ ENV['DOCKER_CONTAINER'] = container_name
68
+ t.ruby_opts = '-I ./spec/integration'
69
+ t.pattern = "spec/integration/{default,docker}_spec.rb"
74
70
  end
75
71
 
76
72
  desc 'Clean a docker container for test'
data/lib/itamae/recipe.rb CHANGED
@@ -53,7 +53,7 @@ module Itamae
53
53
 
54
54
  def load(vars = {})
55
55
  context = EvalContext.new(self, vars)
56
- context.instance_eval(File.read(path), path, 1)
56
+ InstanceEval.new(File.read(path), path, 1, context: context).call
57
57
  end
58
58
 
59
59
  def run
@@ -151,6 +151,25 @@ module Itamae
151
151
  end
152
152
  end
153
153
 
154
+ class InstanceEval
155
+ def initialize(src, path, lineno, context:)
156
+ # Using instance_eval + eval to allow top-level class/module definition without `::`.
157
+ # To pass args without introducing any local/instance variables, this code is also eval-ed.
158
+ @code = <<-RUBY
159
+ @context.instance_eval do
160
+ eval(#{src.dump}, nil, #{path.dump}, #{lineno})
161
+ end
162
+ RUBY
163
+ @context = context
164
+ end
165
+
166
+ # This method has no local variables to avoid spilling them to recipes.
167
+ def call
168
+ eval(@code)
169
+ end
170
+ end
171
+ private_constant :InstanceEval
172
+
154
173
  class RecipeFromDefinition < Recipe
155
174
  attr_accessor :definition
156
175
 
@@ -1,3 +1,3 @@
1
1
  module Itamae
2
- VERSION = "1.12.0"
2
+ VERSION = "1.12.1"
3
3
  end
@@ -333,3 +333,21 @@ describe file('/tmp/empty_file3') do
333
333
  it { should be_file }
334
334
  its(:content) { should eq "" }
335
335
  end
336
+
337
+ describe file('/tmp/toplevel_module') do
338
+ it { should exist }
339
+ it { should be_file }
340
+ its(:content) { should eq "helper" }
341
+ end
342
+
343
+ describe file('/tmp/local_variables') do
344
+ it { should exist }
345
+ it { should be_file }
346
+ its(:content) { should eq "[]" }
347
+ end
348
+
349
+ describe file('/tmp/instance_variables') do
350
+ it { should exist }
351
+ it { should be_file }
352
+ its(:content) { should eq "[:@recipe]" } # backward compatibility
353
+ end
@@ -556,3 +556,9 @@ unless v1 == v2 && v2 == v3 && v1 =~ /\A\d+kB\z/
556
556
  raise "failed to fetch host inventory value (#{v1}, #{v2}, #{v3})"
557
557
  end
558
558
 
559
+ include_recipe "toplevel_module"
560
+ file "/tmp/toplevel_module" do
561
+ content ToplevelModule.helper
562
+ end
563
+
564
+ include_recipe "variables"
@@ -0,0 +1,6 @@
1
+ # Testing you don't need to write `module ::ToplevelModule`
2
+ module ToplevelModule
3
+ def self.helper
4
+ "helper"
5
+ end
6
+ end
@@ -0,0 +1,14 @@
1
+ node.reverse_merge!(
2
+ variables: {
3
+ lvars: binding.local_variables,
4
+ ivars: instance_variables,
5
+ }
6
+ )
7
+
8
+ file "/tmp/local_variables" do
9
+ content node[:variables][:lvars].to_s
10
+ end
11
+
12
+ file "/tmp/instance_variables" do
13
+ content node[:variables][:ivars].to_s
14
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itamae
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.0
4
+ version: 1.12.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryota Arai
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-02-06 00:00:00.000000000 Z
13
+ date: 2021-02-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: thor
@@ -210,9 +210,9 @@ executables:
210
210
  extensions: []
211
211
  extra_rdoc_files: []
212
212
  files:
213
+ - ".github/workflows/test.yml"
213
214
  - ".gitignore"
214
215
  - ".rspec"
215
- - ".travis.yml"
216
216
  - CHANGELOG.md
217
217
  - Gemfile
218
218
  - LICENSE.txt
@@ -293,6 +293,8 @@ files:
293
293
  - spec/integration/recipes/redefine.rb
294
294
  - spec/integration/recipes/templates/empty_file.erb
295
295
  - spec/integration/recipes/templates/template_auto.erb
296
+ - spec/integration/recipes/toplevel_module.rb
297
+ - spec/integration/recipes/variables.rb
296
298
  - spec/integration/spec_helper.rb
297
299
  - spec/unit/lib/itamae/backend_spec.rb
298
300
  - spec/unit/lib/itamae/handler/base_spec.rb
@@ -357,6 +359,8 @@ test_files:
357
359
  - spec/integration/recipes/redefine.rb
358
360
  - spec/integration/recipes/templates/empty_file.erb
359
361
  - spec/integration/recipes/templates/template_auto.erb
362
+ - spec/integration/recipes/toplevel_module.rb
363
+ - spec/integration/recipes/variables.rb
360
364
  - spec/integration/spec_helper.rb
361
365
  - spec/unit/lib/itamae/backend_spec.rb
362
366
  - spec/unit/lib/itamae/handler/base_spec.rb
data/.travis.yml DELETED
@@ -1,41 +0,0 @@
1
- language: ruby
2
- sudo: required
3
- dist: xenial
4
- services:
5
- - docker
6
- rvm:
7
- - 2.3
8
- - 2.4
9
- - 2.5
10
- - 2.6
11
- - 2.7
12
- - 3.0
13
- - ruby-head
14
- bundler_args: "--jobs=4 --retry=3"
15
- cache:
16
- bundler: true
17
-
18
- before_install:
19
- - travis_retry gem install bundler --no-document || travis_retry gem install bundler --no-document -v 1.17.3
20
-
21
- script:
22
- - RUBYOPT=$SPEC_RUBYOPT bundle exec rake spec
23
- notifications:
24
- email: false
25
- slack:
26
- secure: PcecHsVS6lw89K5PllW8xFlzu0d04p6lYfxlUZL0/yp9flAczElJME4RshSMSkbnu5e2Iw8KUA2xB1jkAzDo9qYoXveaKyjkFUOb1ZxYIVxzzfoDDwUNTMmSoyjZjvbeBUcpxxmxy6nXa3zS+gA2ohqWhS9WTTlTqyM5RriDjZ8=
27
- matrix:
28
- allow_failures:
29
- - rvm: ruby-head
30
- include:
31
- - rvm: 2.6
32
- env: SPEC_RUBYOPT="--jit"
33
- - rvm: 2.7
34
- env: SPEC_RUBYOPT="--jit"
35
- - rvm: 3.0
36
- env: SPEC_RUBYOPT="--jit"
37
- - rvm: ruby-head
38
- env: SPEC_RUBYOPT="--jit"
39
- branches:
40
- only:
41
- - master