rascal 0.2.1 → 0.3.3

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: 4b74557df826ff38144441618c033febef78f16c3ed94f0e6cb83b0fd118b88a
4
- data.tar.gz: c444bc107f91a0c09ec3129d408d30d64c0ec6b4900157e55f20e55002f0955b
3
+ metadata.gz: 3547e2d61b8a7dd5d5b90fa802c9c5345dfa0991765455f4c50750cf477d7ae9
4
+ data.tar.gz: cb4d2c0458ea759bab8607d6ec4a5320ffa63723701481f784482f2bbc912405
5
5
  SHA512:
6
- metadata.gz: 74561bcdaae8dc49c4655717fde4c85c4203a917ce599301a50ae35fd06f7d15ded38ac6707d48471bb2a82312831600a11c67c00dc3adf639bb46d331178499
7
- data.tar.gz: 83bd4ea1b2cbd7d19382cb068772d0cc08117763ea06f34d471c7765259d6de62088f23744fcb639ba599de36491e260070945a3208fa9d0ce2502d98049d8e1
6
+ metadata.gz: 51d36be1d236eed7397cc8b454e599e27812b8821f28ce591a1b11d8a08b1a720ccf6a51fa39b1dd32d40a85442342498f91c0323e01d5522bd838aa3f50ee60
7
+ data.tar.gz: ef6fc4a2ab0f26c660151dd83878b9ccce5a3a5504b6626e0b53718be01e03b4369491f11271ed14b6d470d5fb76efc7a01c359fe2d0c102b5e8f2b55b86e40a
@@ -0,0 +1,31 @@
1
+ name: Tests
2
+ on:
3
+ push:
4
+ branches:
5
+ - master
6
+ pull_request:
7
+ branches:
8
+ - master
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-20.04
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ include:
16
+ - ruby: 2.5.8
17
+ gemfile: Gemfile
18
+ env:
19
+ BUNDLE_GEMFILE: "${{ matrix.gemfile }}"
20
+ steps:
21
+ - uses: actions/checkout@v2
22
+ - name: Install ruby
23
+ uses: ruby/setup-ruby@v1
24
+ with:
25
+ ruby-version: "${{ matrix.ruby }}"
26
+ - name: Bundle
27
+ run: |
28
+ gem install bundler:2.1.4
29
+ bundle install --no-deployment
30
+ - name: Run tests
31
+ run: bundle exec rake
data/CHANGELOG.md CHANGED
@@ -4,6 +4,25 @@ All notable changes to this project will be documented here.
4
4
 
5
5
  Rascal follows semantic versioning. This has little consequence pre 1.0, so expect breaking changes.
6
6
 
7
+ ## 0.3.3 (2021-12-08)
8
+
9
+ - Support `command` key in services.
10
+
11
+
12
+ ## 0.3.2 (2020-10-23)
13
+
14
+ - Fix broken `rascal shell` command.
15
+
16
+
17
+ ## 0.3.1 (2020-10-01)
18
+
19
+ - Pass env variables to service containers.
20
+
21
+
22
+ ## 0.3.0 (2020-09-23)
23
+
24
+ - Mount /repo into all service volumes
25
+
7
26
 
8
27
  ## 0.2.1 (2019-04-10)
9
28
 
data/Gemfile CHANGED
@@ -5,7 +5,7 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
5
5
  # Specify your gem's dependencies in rascal.gemspec
6
6
  gemspec
7
7
 
8
- gem 'rake', '~> 10.0'
8
+ gem 'rake', '~> 13.0'
9
9
  gem 'rspec'
10
10
  gem 'cucumber'
11
11
  gem 'aruba'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rascal (0.2.1)
4
+ rascal (0.3.3)
5
5
  thor (~> 0.20.3)
6
6
 
7
7
  GEM
@@ -16,8 +16,7 @@ GEM
16
16
  thor (~> 0.19)
17
17
  backports (3.12.0)
18
18
  builder (3.2.3)
19
- childprocess (1.0.1)
20
- rake (< 13.0)
19
+ childprocess (1.0.0)
21
20
  coderay (1.1.2)
22
21
  contracts (0.16.0)
23
22
  cucumber (3.1.2)
@@ -73,7 +72,7 @@ GEM
73
72
  pry (0.12.2)
74
73
  coderay (~> 1.1.0)
75
74
  method_source (~> 0.9.0)
76
- rake (10.5.0)
75
+ rake (13.0.1)
77
76
  rb-fsevent (0.10.3)
78
77
  rb-inotify (0.10.0)
79
78
  ffi (~> 1.0)
@@ -102,9 +101,9 @@ DEPENDENCIES
102
101
  cucumber
103
102
  guard-cucumber
104
103
  guard-rspec
105
- rake (~> 10.0)
104
+ rake (~> 13.0)
106
105
  rascal!
107
106
  rspec
108
107
 
109
108
  BUNDLED WITH
110
- 2.0.1
109
+ 2.1.4
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Rascal [![Build Status](https://travis-ci.org/makandra/rascal.svg?branch=master)](https://travis-ci.org/makandra/rascal)
1
+ # Rascal [![Tests](https://github.com/makandra/rascal/workflows/Tests/badge.svg)](https://github.com/makandra/rascal/actions)
2
2
 
3
3
  ### Use CI environments locally. Not quite a vagrant.
4
4
 
@@ -40,9 +40,9 @@ module Rascal
40
40
  !!id
41
41
  end
42
42
 
43
- def start(network: nil, network_alias: nil)
43
+ def start(network: nil, network_alias: nil, volumes: [], env: {}, command: [])
44
44
  say "Starting container for #{@name}"
45
- create(network: network, network_alias: network_alias) unless exists?
45
+ create(network: network, network_alias: network_alias, volumes: volumes, env: env, command: command) unless exists?
46
46
  Docker.interface.run(
47
47
  'container',
48
48
  'start',
@@ -50,14 +50,17 @@ module Rascal
50
50
  )
51
51
  end
52
52
 
53
- def create(network: nil, network_alias: nil)
53
+ def create(network: nil, network_alias: nil, volumes: [], env: {}, command: [])
54
54
  @id = Docker.interface.run(
55
55
  'container',
56
56
  'create',
57
57
  '--name', @prefixed_name,
58
+ *(volumes.flat_map { |v| ['-v', v.to_param] }),
59
+ *env_args(env),
58
60
  *(['--network', network.id] if network),
59
61
  *(['--network-alias', network_alias] if network_alias),
60
62
  @image,
63
+ *command,
61
64
  output: :id,
62
65
  )
63
66
  end
@@ -74,7 +77,7 @@ module Rascal
74
77
  '--tty',
75
78
  *(['-w', working_dir] if working_dir),
76
79
  *(volumes.flat_map { |v| ['-v', v.to_param] }),
77
- *(env.flat_map { |key, value| ['-e', "#{key}=#{value}"] }),
80
+ *env_args(env),
78
81
  *(['--network', network.id] if network),
79
82
  @image,
80
83
  *command,
@@ -147,6 +150,10 @@ module Rascal
147
150
  id,
148
151
  )
149
152
  end
153
+
154
+ def env_args(env)
155
+ env.flat_map { |key, value| ['-e', "#{key}=#{value}"] }
156
+ end
150
157
  end
151
158
  end
152
159
  end
@@ -2,7 +2,7 @@ module Rascal
2
2
  class Environment
3
3
  attr_reader :name, :network, :container, :env_variables, :services, :volumes, :working_dir, :before_shell
4
4
 
5
- def initialize(full_name, name:, image:, env_variables: {}, services: [], volumes: [], before_shell: [], working_dir: nil)
5
+ def initialize(full_name, name:, image:, env_variables: {}, services: [], volumes: [], before_shell: [], after_shell: [], working_dir: nil)
6
6
  @name = name
7
7
  @network = Docker::Network.new(full_name)
8
8
  @container = Docker::Container.new(full_name, image)
@@ -11,12 +11,13 @@ module Rascal
11
11
  @volumes = volumes
12
12
  @working_dir = working_dir
13
13
  @before_shell = before_shell
14
+ @after_shell = after_shell
14
15
  end
15
16
 
16
17
  def run_shell
17
18
  download_missing
18
19
  start_services
19
- command = [*@before_shell, 'bash'].join(';')
20
+ command = [*@before_shell, 'bash', *@after_shell].join(';')
20
21
  @container.run_and_attach('bash', '-c', command,
21
22
  env: @env_variables,
22
23
  network: @network,
@@ -68,17 +68,19 @@ module Rascal
68
68
  unless key.start_with?('.') || config.get('hide', false)
69
69
  name = config.get('name', key)
70
70
  full_name = "#{@base_name}-#{name}"
71
+ shared_volumes = [build_repo_volume(docker_repo_dir), build_builds_volume(full_name)]
72
+ env_variables = (config.get('variables', {}))
71
73
  Environment.new(full_name,
72
74
  name: name,
73
75
  image: config.get('image'),
74
- env_variables: (config.get('variables', {})),
75
- services: build_services(full_name, config.get('services', [])),
76
76
  volumes: [
77
- build_repo_volume(docker_repo_dir),
78
- build_builds_volume(full_name),
77
+ *shared_volumes,
79
78
  *build_volumes(full_name, config.get('volumes', {}))
80
79
  ],
80
+ env_variables: env_variables,
81
+ services: build_services(full_name, config.get('services', []), volumes: shared_volumes, env_variables: env_variables),
81
82
  before_shell: config.get('before_shell', []),
83
+ after_shell: config.get('after_shell', []),
82
84
  working_dir: docker_repo_dir,
83
85
  )
84
86
  end
@@ -109,12 +111,15 @@ module Rascal
109
111
  end
110
112
  end
111
113
 
112
- def build_services(name, services)
114
+ def build_services(name, services, volumes: [], env_variables: {})
113
115
  services.collect do |service_config|
114
116
  service_alias = service_config['alias']
115
117
  Service.new("#{name}_#{service_alias}",
116
118
  alias_name: service_config['alias'],
117
119
  image: service_config['name'],
120
+ volumes: volumes,
121
+ env_variables: env_variables,
122
+ command: service_config['command'],
118
123
  )
119
124
  end
120
125
  end
@@ -1,11 +1,14 @@
1
1
  module Rascal
2
2
  class Service
3
- attr_reader :name, :container, :alias
3
+ attr_reader :name, :container, :alias, :env_variables, :command
4
4
 
5
- def initialize(name, image:, alias_name:)
5
+ def initialize(name, env_variables: {}, image:, alias_name:, volumes: [], command: nil)
6
6
  @name = name
7
7
  @container = Docker::Container.new(name, image)
8
8
  @alias = alias_name
9
+ @volumes = volumes
10
+ @env_variables = env_variables
11
+ @command = [*command]
9
12
  end
10
13
 
11
14
  def download_missing
@@ -14,7 +17,7 @@ module Rascal
14
17
 
15
18
  def start_if_stopped(network: nil)
16
19
  unless @container.running?
17
- @container.start(network: network, network_alias: @alias)
20
+ @container.start(network: network, network_alias: @alias, volumes: @volumes, env: @env_variables, command: @command)
18
21
  end
19
22
  end
20
23
 
@@ -1,3 +1,3 @@
1
1
  module Rascal
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rascal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Kraze
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-04-10 00:00:00.000000000 Z
11
+ date: 2021-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -32,10 +32,10 @@ executables:
32
32
  extensions: []
33
33
  extra_rdoc_files: []
34
34
  files:
35
+ - ".github/workflows/test.yml"
35
36
  - ".gitignore"
36
37
  - ".rspec"
37
38
  - ".ruby-version"
38
- - ".travis.yml"
39
39
  - CHANGELOG.md
40
40
  - Gemfile
41
41
  - Gemfile.lock
@@ -91,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
91
  - !ruby/object:Gem::Version
92
92
  version: '0'
93
93
  requirements: []
94
- rubygems_version: 3.0.3
94
+ rubygems_version: 3.2.33
95
95
  signing_key:
96
96
  specification_version: 4
97
97
  summary: Spin up CI environments locally.
data/.travis.yml DELETED
@@ -1,16 +0,0 @@
1
- # yes, we use travis for open source gems
2
-
3
- language: ruby
4
- rvm:
5
- - '2.5.4'
6
- gemfile:
7
- - Gemfile
8
- script: bundle exec rake
9
- sudo: false
10
- cache: vendor/bundler
11
- notifications:
12
- email:
13
- - fail@makandra.de
14
- install:
15
- - gem install bundler:2.0.1
16
- - bundle install --no-deployment --jobs=3 --retry=3 --path=${BUNDLE_PATH:-vendor/bundle}