A handy toolkit tailored for CI workflows.
| Language/語言 | ID |
|---|---|
| English | en-Latn-US |
| 简体中文 | zh-Hans-CN |
| 繁體中文 | zh-Hant-TW |
Q: Why is it named Cinnabar?
A:
- Cinnabar was an ingredient used by ancient Daoist alchemists in their elixirs, much like this project serves as an "ingredient" within CI workflows.
- Cinnabar is toxic. This project was developed for Dirty and Quick purposes and may produce unexpected side effects—in a sense, it is not entirely harmless.
- Cinnabar, a mineral form of mercury sulfide (HgS), is a deep red-colored stone. And ruby is also a deep red stone. Naming a Ruby project "Cinnabar" is particularly fitting.
- Github Pages: https://2moe.github.io/cinnabar
- ChangeLog
Github Actions for cinnabar
env:
# optional values: debug, info, warn, error, fatal, unknown
RUBY_LOG: debug
defaults:
run:
# Speeds up script startup by disabling RubyGems
shell: ruby --disable=gems cinnabar/ci.rb {0}
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: clone cinnabar
uses: actions/checkout@v6
with:
repository: 2moe/cinnabar
path: cinnabar
ref: v0.0.8
- name: (example) run cargo command
run: |
{
cargo: (),
build: (),
profile: 'release',
verbose: true,
target: 'x86_64-unknown-linux-musl'
}
.to_argv
.run_cmd- run: |
opts = { stdin_data: "Hello", allow_failure: true }
stdout = %w[wc -m].run(opts:)
stdout.to_i == 5 #=> true- run: |
'building wasi file...'.log_dbg
task = {
cargo: (),
b: (),
r: true,
target: 'wasm32-wasip2'
} .to_argv
.async_run
# log_dbg, log_info, log_warn, log_err, log_fatal, log_unk
"You can now do other things without waiting for
the process to complete.".log_dbg
stdout, status = task.wait_with_output
stdout.log_info
raise "wasi" unless status.success?- run: |
stdin_data = <<~'QMP_JSON'
{ "execute":"qmp_capabilities" }
{ "execute":"query-cpu-model-expansion",
"arguments":{"type":"full","model":{"name":"host"}} }
{ "execute":"quit" }
QMP_JSON
# opts = { stdin_data:, stdin_binmode: false }
opts = { stdin_data: }
accel = %w[kvm hvf whpx].join ':'
task = {
'qemu-system-x86_64': (),
machine: "accel=#{accel}",
cpu: 'host',
display: 'none',
nodefaults: true,
no_user_config: true,
qmp: 'stdio',
} .to_argv_bsd
.async_run(opts:)
stdout, status = task.wait_with_output
stdout.log_info if status.success?- run: |
url = 'https://docs.ruby-lang.org/en/master'
url.download
# OR: url.download({out_dir: "/tmp", file_name: "index.html"})- run: |
upper = ->s { s.upcase }
'Foo'
.▷(upper)
.▷ :puts #=> "FOO"- run: |
__dir__.to_path # Same as Pathname(__dir__)
.join('tmp')GemPath is used mainly with Ruby started via the --disable=gems flag; the code below is equivalent to %w[ irb rdoc reline ].each { require it }.
def require_gems = ->(gems) {
{
# cache_dir: File.expand_path('~/.cache/ruby'),
gems:,
}
.then(&Cinnabar.new_gem_path_proc)
.append_load_path!
gems.each { require _1 }
}
%w[
irb rdoc reline
].then(&require_gems)Because GemPath automatically caches gem require_paths, combining it with ruby --disable=gems can significantly reduce IRB startup time.
OR:
gem install cinnabar- Enter the directory:
ruby -r cinnabar -e "p Cinnabar.firb_path"- OR:
${XDG_CACHE_HOME:-~/.cache}/ruby/firb/bin/(POSIX sh) - OR:
~/.cache/ruby/firb/bin/ - OR:
%UserProfile%\.cache\ruby\firb\bin(Windows CMD)
- run
./firb0- OR
.\firb0.bat(Windows) - OR
./firb - OR
.\firb.bat(Windows)