rascal 0.5.1 → 0.5.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 +4 -4
- data/.github/workflows/test.yml +6 -3
- data/CHANGELOG.md +14 -0
- data/CONTRIBUTING.md +2 -1
- data/Gemfile.lock +2 -2
- data/README.md +3 -2
- data/lib/rascal/cli/main.rb +148 -45
- data/lib/rascal/version.rb +1 -1
- data/rascal.gemspec +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: af789d1af2978f26ba0c43948b8440f5022d1dd670581d70f2a002589e06fb1c
|
|
4
|
+
data.tar.gz: c18d2ff9440b6bfb8405382b9f9dace462d1d6cd3f1a4471d184335099907547
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c172604ea4ffa357af940364892307b58ff9f549806ca86a887516d7bcb28b68f03a040bf697fa63ef77eea2fa2976b0c986e64da24507eafbd68153e4ef8b97
|
|
7
|
+
data.tar.gz: 74e1bb9b37c5648f07e5826a6f5ca7b5c7ce291c9d5ef2e048a51213cc4b220ccf15aa77b5cd62e6eff77e3e1781d31280cc966d555b6d201316b67bc15e4374
|
data/.github/workflows/test.yml
CHANGED
|
@@ -13,6 +13,10 @@ jobs:
|
|
|
13
13
|
fail-fast: false
|
|
14
14
|
matrix:
|
|
15
15
|
include:
|
|
16
|
+
- ruby: '3.0'
|
|
17
|
+
gemfile: Gemfile
|
|
18
|
+
# The Bundler in Gemfile.lock needs Ruby 3.1, so use the one Ruby 3.0 comes with.
|
|
19
|
+
bundler: none
|
|
16
20
|
- ruby: '3.3'
|
|
17
21
|
gemfile: Gemfile
|
|
18
22
|
- ruby: '3.4'
|
|
@@ -27,9 +31,8 @@ jobs:
|
|
|
27
31
|
uses: ruby/setup-ruby@v1
|
|
28
32
|
with:
|
|
29
33
|
ruby-version: "${{ matrix.ruby }}"
|
|
34
|
+
bundler: "${{ matrix.bundler || 'Gemfile.lock' }}"
|
|
30
35
|
- name: Bundle
|
|
31
|
-
run:
|
|
32
|
-
gem install bundler:2.1.4
|
|
33
|
-
bundle install --no-deployment
|
|
36
|
+
run: bundle install
|
|
34
37
|
- name: Run tests
|
|
35
38
|
run: bundle exec rake
|
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,20 @@ 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.5.3 (2026-11-20)
|
|
8
|
+
|
|
9
|
+
- `rascal help` teaches basic usage on its own: what rascal does, a typical session from setting
|
|
10
|
+
up to tearing down, things to know, and the path of the README that comes with the gem. The help
|
|
11
|
+
of each command has examples, which no longer break across lines. `rascal COMMAND --help` shows
|
|
12
|
+
the command's help. Requires Thor 1.3 or newer.
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## 0.5.2 (2026-11-20)
|
|
16
|
+
|
|
17
|
+
- Run on Ruby 3.0 or newer again. 0.5.0 and 0.5.1 required Ruby 3.3, which locked out projects that
|
|
18
|
+
pin an older Ruby, like Rails LTS checkouts with Ruby 3.1.
|
|
19
|
+
|
|
20
|
+
|
|
7
21
|
## 0.5.1 (2026-11-20)
|
|
8
22
|
|
|
9
23
|
- Fix services that were unreachable by their alias after rascal restarted their stopped container
|
data/CONTRIBUTING.md
CHANGED
|
@@ -6,7 +6,8 @@ This guide is for people and AI agents who change rascal. For using rascal, see
|
|
|
6
6
|
|
|
7
7
|
## Setup
|
|
8
8
|
|
|
9
|
-
You need Ruby 3.
|
|
9
|
+
You need Ruby 3.0 or newer and a running Docker daemon. We develop with the Ruby from
|
|
10
|
+
`.ruby-version`, and CI also tests the oldest supported Ruby. Install the dependencies with
|
|
10
11
|
`bundle install`.
|
|
11
12
|
|
|
12
13
|
To try your working copy on a project, run its executable from the project directory, with the Ruby
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -56,7 +56,7 @@ when something is missing.
|
|
|
56
56
|
|
|
57
57
|
Install rascal with a Ruby of your own, not into the project's bundle. rascal needs neither the
|
|
58
58
|
project's Ruby nor its gems, so one installation works for all projects, old and new. It needs
|
|
59
|
-
Ruby 3.
|
|
59
|
+
Ruby 3.0 or newer.
|
|
60
60
|
|
|
61
61
|
Ruby version managers like mise or rbenv switch to the project's Ruby inside a project directory
|
|
62
62
|
(from `.ruby-version`), and that Ruby usually does not have rascal. So pick one Ruby for rascal, and
|
|
@@ -78,7 +78,8 @@ rascal run rspec -- bundle install
|
|
|
78
78
|
|
|
79
79
|
The examples below just say `rascal`. If rascal is already installed, mise and rbenv name the Ruby
|
|
80
80
|
that has it when you run `rascal` in a project whose Ruby does not. Check the version with
|
|
81
|
-
`rascal --version`.
|
|
81
|
+
`rascal --version`. Each installed version comes with its own copy of this README, which
|
|
82
|
+
`rascal help` names.
|
|
82
83
|
|
|
83
84
|
You also need:
|
|
84
85
|
|
data/lib/rascal/cli/main.rb
CHANGED
|
@@ -3,31 +3,80 @@ require 'rascal'
|
|
|
3
3
|
module Rascal
|
|
4
4
|
module CLI
|
|
5
5
|
class Main < Thor
|
|
6
|
+
# A command's description, indented like the other parts of `rascal help COMMAND`. It is
|
|
7
|
+
# not wrapped, so examples stay on one line.
|
|
8
|
+
def self.indented(text)
|
|
9
|
+
text.gsub(/^(?=.)/, ' ')
|
|
10
|
+
end
|
|
11
|
+
|
|
6
12
|
# Options that change a single `run` or `shell`, like for updating dependencies.
|
|
7
13
|
def self.command_environment_options
|
|
8
14
|
method_option :env, type: :string, repeatable: true, banner: 'NAME=VALUE',
|
|
9
|
-
desc: 'Set a variable
|
|
15
|
+
desc: 'Set a variable for this command only. Repeatable.'
|
|
10
16
|
method_option :unset_env, type: :string, repeatable: true, banner: 'NAME',
|
|
11
|
-
desc: 'Remove a variable
|
|
17
|
+
desc: 'Remove a variable, like CI, for this command only. Repeatable.'
|
|
12
18
|
method_option :ssh_agent, type: :boolean,
|
|
13
|
-
desc: 'Give
|
|
19
|
+
desc: 'Give this command your SSH agent. --no-ssh-agent keeps it away.'
|
|
14
20
|
end
|
|
21
|
+
|
|
22
|
+
# The README that comes with this version of rascal, packaged into the gem.
|
|
23
|
+
README_PATH = File.expand_path('../../../README.md', __dir__)
|
|
24
|
+
|
|
25
|
+
desc 'help [COMMAND]', 'Show this help, or the help of a command'
|
|
15
26
|
def help(subcommand = false)
|
|
16
|
-
if subcommand
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
return super if subcommand
|
|
28
|
+
|
|
29
|
+
say <<~TEXT
|
|
30
|
+
|
|
31
|
+
rascal runs the environment of a GitLab CI job locally in Docker: the job's
|
|
32
|
+
image with your project mounted at /repo, and the job's services, like a
|
|
33
|
+
database. Run it in the project's root directory, where .gitlab-ci.yml is.
|
|
34
|
+
|
|
35
|
+
Typical use, with a job called rspec:
|
|
36
|
+
rascal environments # list the jobs
|
|
37
|
+
rascal status rspec # what rascal made of the job, starts nothing
|
|
38
|
+
rascal run rspec -- true # first run: downloads images, takes minutes
|
|
39
|
+
rascal run rspec -- bundle install
|
|
40
|
+
rascal run rspec -- bin/rails db:create db:schema:load
|
|
41
|
+
rascal run rspec -- bundle exec rspec spec/models/user_spec.rb
|
|
42
|
+
rascal shell rspec # interactive bash, needs a terminal
|
|
43
|
+
rascal clean --all --volumes # tear down: services, their data, volumes
|
|
44
|
+
|
|
45
|
+
TEXT
|
|
46
|
+
super
|
|
47
|
+
say <<~TEXT
|
|
48
|
+
Good to know:
|
|
49
|
+
- rascal does not run the job's before_script or script. Set the project
|
|
50
|
+
up yourself following them, but skip steps that only work on CI, and do
|
|
51
|
+
not overwrite local files like config/database.yml.
|
|
52
|
+
- Each command runs in a new container. Only files in the project and in
|
|
53
|
+
volumes stay, and services keep running with their data. Gems stay if
|
|
54
|
+
BUNDLE_PATH points into the project (see Variables in rascal status).
|
|
55
|
+
- Commands reach the services under the host names rascal status shows,
|
|
56
|
+
like db. rascal publishes no ports, so you cannot open a server in the
|
|
57
|
+
container from your browser.
|
|
58
|
+
- The container gets the job's variables and CI=true, not your shell's
|
|
59
|
+
variables. Setup may change files like Gemfile.lock: check git status.
|
|
60
|
+
If the Gemfile checks CI, read "Changing dependencies" in the README
|
|
61
|
+
before you update gems.
|
|
62
|
+
- Options go before --, like rascal run rspec --env NAME=VALUE -- ...
|
|
63
|
+
--env, --unset-env and --ssh-agent change only that one command.
|
|
64
|
+
- Lasting settings go into a .rascal.yml next to .gitlab-ci.yml, which you
|
|
65
|
+
keep out of Git, like "variables: { BUNDLE_PATH: tmp/bundle }" or
|
|
66
|
+
before_shell, commands to run before each command. The project may
|
|
67
|
+
already have some in a .rascal block in .gitlab-ci.yml.
|
|
68
|
+
- Docker resources are named after the project directory's name. Checkouts
|
|
69
|
+
with the same directory name share their services and databases. In a
|
|
70
|
+
Git worktree, Git does not work in the container, so prefer clones.
|
|
71
|
+
- If something does not work, rascal status JOB shows what rascal made of
|
|
72
|
+
the job, and how its services run.
|
|
73
|
+
|
|
74
|
+
For more about a command, run "rascal help COMMAND". rascal --version prints
|
|
75
|
+
the version. The README that came with this version of rascal explains
|
|
76
|
+
setup, configuration and troubleshooting:
|
|
77
|
+
TEXT
|
|
78
|
+
say " #{README_PATH}"
|
|
79
|
+
say
|
|
31
80
|
end
|
|
32
81
|
|
|
33
82
|
def self.exit_on_failure?
|
|
@@ -35,17 +84,42 @@ module Rascal
|
|
|
35
84
|
true
|
|
36
85
|
end
|
|
37
86
|
|
|
38
|
-
def self.start(
|
|
87
|
+
def self.start(given_args = ARGV, config = {})
|
|
39
88
|
IOHelper.setup
|
|
40
|
-
super
|
|
89
|
+
super(help_arguments(given_args), config)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Options that take a value as the next argument.
|
|
93
|
+
OPTIONS_WITH_VALUES = %w[-c --config-file --env --unset-env].freeze
|
|
94
|
+
|
|
95
|
+
# `rascal run --help` or `rascal shell rspec -h` show the command's help, like
|
|
96
|
+
# `rascal help run`. For `run`, only up to the argument after the job, since what
|
|
97
|
+
# follows is the command to run, which may have its own -h.
|
|
98
|
+
def self.help_arguments(args)
|
|
99
|
+
# The arguments that are neither options nor option values, like the command and the job.
|
|
100
|
+
positional = args.each_index.reject do |index|
|
|
101
|
+
args[index].start_with?('-') || (index > 0 && OPTIONS_WITH_VALUES.include?(args[index - 1]))
|
|
102
|
+
end
|
|
103
|
+
command = args[positional.first] if positional.any?
|
|
104
|
+
last_index = args.index('--') || args.size
|
|
105
|
+
last_index = [last_index, positional[1] + 2].min if command == 'run' && positional[1]
|
|
106
|
+
return args unless (args.take(last_index) & %w[-h --help]).any?
|
|
107
|
+
|
|
108
|
+
command && command != 'help' ? ['help', command] : ['help']
|
|
41
109
|
end
|
|
42
110
|
|
|
43
111
|
|
|
44
112
|
map "shell" => "_shell"
|
|
45
|
-
desc 'shell JOB', "Open
|
|
46
|
-
long_desc <<~TEXT
|
|
47
|
-
Opens bash in the environment of a CI job, like for a Rails console or a
|
|
48
|
-
|
|
113
|
+
desc 'shell JOB', "Open bash in a job's environment"
|
|
114
|
+
long_desc indented(<<~TEXT), wrap: false
|
|
115
|
+
Opens bash in the environment of a CI job, like for a Rails console or a
|
|
116
|
+
debugger, with before_shell and after_shell around it. Needs a terminal.
|
|
117
|
+
|
|
118
|
+
rascal shell rspec
|
|
119
|
+
|
|
120
|
+
Without a terminal, like as an AI agent, debug with rascal run: run single
|
|
121
|
+
examples, add output to the code, or inspect state with bin/rails runner. A
|
|
122
|
+
forgotten debugger call gets no input there instead of hanging.
|
|
49
123
|
TEXT
|
|
50
124
|
command_environment_options
|
|
51
125
|
def _shell(environment_name = nil)
|
|
@@ -54,12 +128,16 @@ module Rascal
|
|
|
54
128
|
end
|
|
55
129
|
end
|
|
56
130
|
|
|
57
|
-
desc 'status [JOB]', "Show a job's environment
|
|
58
|
-
long_desc <<~TEXT
|
|
59
|
-
Shows what rascal made of the CI config: the image, services, variables,
|
|
60
|
-
after_shell, and any problems. Also shows what exists in
|
|
61
|
-
downloaded, the state of each service with the
|
|
62
|
-
|
|
131
|
+
desc 'status [JOB]', "Show a job's environment, starts nothing"
|
|
132
|
+
long_desc indented(<<~TEXT), wrap: false
|
|
133
|
+
Shows what rascal made of the CI config: the image, services, variables,
|
|
134
|
+
before_shell and after_shell, and any problems. Also shows what exists in
|
|
135
|
+
Docker: whether images are downloaded, the state of each service with the
|
|
136
|
+
command to see its logs, the network, volumes and running commands. Starts and
|
|
137
|
+
downloads nothing. Without a job, shows all.
|
|
138
|
+
|
|
139
|
+
rascal status rspec
|
|
140
|
+
rascal status --json
|
|
63
141
|
TEXT
|
|
64
142
|
method_option :json, type: :boolean, desc: 'Print JSON, for scripts and agents'
|
|
65
143
|
def status(environment_name = nil)
|
|
@@ -68,7 +146,12 @@ module Rascal
|
|
|
68
146
|
end
|
|
69
147
|
end
|
|
70
148
|
|
|
71
|
-
desc 'environments', 'List the jobs
|
|
149
|
+
desc 'environments', 'List the jobs of .gitlab-ci.yml'
|
|
150
|
+
long_desc indented(<<~TEXT), wrap: false
|
|
151
|
+
Lists the jobs of .gitlab-ci.yml, one per line, including ones rascal cannot
|
|
152
|
+
start, like deploy jobs. A job's environment has the job's name. Pick the job
|
|
153
|
+
that runs the tests, usually rspec or test.
|
|
154
|
+
TEXT
|
|
72
155
|
def environments
|
|
73
156
|
handle_error do
|
|
74
157
|
Environments.new(options).run
|
|
@@ -79,15 +162,28 @@ module Rascal
|
|
|
79
162
|
map 'run' => '_run'
|
|
80
163
|
stop_on_unknown_option! :_run
|
|
81
164
|
desc 'run JOB -- COMMAND', "Run a command in a job's environment"
|
|
82
|
-
long_desc <<~TEXT
|
|
83
|
-
Runs a command in the environment of a CI job, without a terminal, and exits
|
|
165
|
+
long_desc indented(<<~TEXT), wrap: false
|
|
166
|
+
Runs a command in the environment of a CI job, without a terminal, and exits
|
|
167
|
+
with the command's status. If rascal itself fails, it exits with 1 and says
|
|
168
|
+
why on stderr. Before the command, rascal starts the job's services, waits
|
|
169
|
+
until they accept connections, and runs before_shell. after_shell runs after
|
|
170
|
+
the command. Their output goes to stdout, rascal's own messages to stderr.
|
|
171
|
+
A failing before_shell does not stop the command or change its status.
|
|
172
|
+
|
|
84
173
|
Everything after -- is passed on as arguments. For shell syntax, use bash -c:
|
|
85
174
|
|
|
86
|
-
|
|
175
|
+
rascal run rspec -- bundle exec rspec spec/models/user_spec.rb:42
|
|
176
|
+
rascal run rspec -- bash -c 'bin/rails db:migrate && bundle exec rspec'
|
|
87
177
|
|
|
88
|
-
Options go before --.
|
|
178
|
+
Options go before --. They change the container for this one command:
|
|
89
179
|
|
|
90
|
-
|
|
180
|
+
rascal run rspec --env RAILS_ENV=test -- bin/rails runner 'p User.count'
|
|
181
|
+
rascal run rspec --ssh-agent -- bundle install
|
|
182
|
+
|
|
183
|
+
With --ssh-agent, all code in the container can use your SSH keys, so only
|
|
184
|
+
pass it to commands that need it, like fetching private gems. As an AI agent,
|
|
185
|
+
ask your user first. If the Gemfile checks CI, read "Changing dependencies" in
|
|
186
|
+
the README before you update gems.
|
|
91
187
|
TEXT
|
|
92
188
|
command_environment_options
|
|
93
189
|
def _run(environment_name = nil, *command)
|
|
@@ -97,11 +193,15 @@ module Rascal
|
|
|
97
193
|
end
|
|
98
194
|
end
|
|
99
195
|
|
|
100
|
-
desc 'clean JOB | --all', "Remove a job's
|
|
101
|
-
long_desc <<~TEXT
|
|
102
|
-
Stops and removes the environment's services with their data, like databases,
|
|
103
|
-
and leftover command containers. Named volumes, like caches, stay
|
|
104
|
-
Files in the project
|
|
196
|
+
desc 'clean JOB | --all', "Remove a job's services and network"
|
|
197
|
+
long_desc indented(<<~TEXT), wrap: false
|
|
198
|
+
Stops and removes the environment's services with their data, like databases,
|
|
199
|
+
its network and leftover command containers. Named volumes, like caches, stay
|
|
200
|
+
unless you pass --volumes. Files in the project and downloaded images stay.
|
|
201
|
+
The next command starts the services fresh.
|
|
202
|
+
|
|
203
|
+
rascal clean rspec
|
|
204
|
+
rascal clean --all --volumes # all jobs, and their volumes
|
|
105
205
|
TEXT
|
|
106
206
|
method_option :volumes, type: :boolean, desc: 'Also remove volumes, like caches'
|
|
107
207
|
method_option :all, type: :boolean, desc: 'Clean the environments of all jobs'
|
|
@@ -111,10 +211,13 @@ module Rascal
|
|
|
111
211
|
end
|
|
112
212
|
end
|
|
113
213
|
|
|
114
|
-
desc 'update JOB | --all', "Pull
|
|
115
|
-
long_desc <<~TEXT
|
|
116
|
-
Pulls the latest images of the job and its services. Services that
|
|
117
|
-
old image until you run rascal clean.
|
|
214
|
+
desc 'update JOB | --all', "Pull a job's latest images"
|
|
215
|
+
long_desc indented(<<~TEXT), wrap: false
|
|
216
|
+
Pulls the latest Docker images of the job and its services. Services that
|
|
217
|
+
already run keep their old image until you run rascal clean. To update gems,
|
|
218
|
+
see "Changing dependencies" in the README.
|
|
219
|
+
|
|
220
|
+
rascal update rspec
|
|
118
221
|
TEXT
|
|
119
222
|
method_option :all, type: :boolean, desc: 'Update the environments of all jobs'
|
|
120
223
|
def update(environment_name = nil)
|
data/lib/rascal/version.rb
CHANGED
data/rascal.gemspec
CHANGED
|
@@ -33,7 +33,7 @@ Gem::Specification.new do |spec|
|
|
|
33
33
|
spec.bindir = "exe"
|
|
34
34
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
35
35
|
spec.require_paths = ["lib"]
|
|
36
|
-
spec.required_ruby_version = ">= 3.
|
|
36
|
+
spec.required_ruby_version = ">= 3.0"
|
|
37
37
|
|
|
38
|
-
spec.add_dependency "thor", ">= 1.
|
|
38
|
+
spec.add_dependency "thor", ">= 1.3.0"
|
|
39
39
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rascal
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.5.
|
|
4
|
+
version: 0.5.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tobias Kraze
|
|
@@ -15,14 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - ">="
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 1.
|
|
18
|
+
version: 1.3.0
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - ">="
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: 1.
|
|
25
|
+
version: 1.3.0
|
|
26
26
|
email:
|
|
27
27
|
- tobias.kraze@makandra.de
|
|
28
28
|
executables:
|
|
@@ -99,7 +99,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
99
99
|
requirements:
|
|
100
100
|
- - ">="
|
|
101
101
|
- !ruby/object:Gem::Version
|
|
102
|
-
version: '3.
|
|
102
|
+
version: '3.0'
|
|
103
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
104
|
requirements:
|
|
105
105
|
- - ">="
|