Project

cinnabar

0.0
No release in over 3 years
A handy toolkit tailored for CI workflows (e.g., GitHub Actions)
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

~> 0.0.6
 Project Readme

Cinnabar

Gem Version

A handy toolkit tailored for CI workflows.


Language/語言 ID
English en-Latn-US
简体中文 zh-Hans-CN
繁體中文 zh-Hant-TW

Preface

Q: Why is it named Cinnabar?

A:

  1. Cinnabar was an ingredient used by ancient Daoist alchemists in their elixirs, much like this project serves as an "ingredient" within CI workflows.
  2. 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.
  3. 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.

API DOC

ClassDiagram

Quick Start

Github Actions for cinnabar

env:
  # Speeds up script startup by disabling RubyGems
  RUBYOPT: "--disable=gems"
  default_ci_shell: ruby cinnabar/ci.rb {0}
  # optional values: debug, info, warn, error, fatal, unknown
  RUBY_LOG: debug

jobs:
  build:
    runs-on: ubuntu-latest
    defaults:
      run:
        shell: ${{env.default_ci_shell}}
    steps:
      - uses: actions/checkout@v6

      - name: clone cinnabar
        uses: actions/checkout@v6
        with:
          repository: 2moe/cinnabar
          path: cinnabar
          ref: v0.0.1

      - name: (example) run cargo command
        run: |
          {
            cargo: (),
            build: (),
            profile: 'release',
            verbose: true,
            target: 'x86_64-unknown-linux-musl'
          }
            .to_argv
            .run_cmd

Examples

Command Runner

.run + pass stdin data

- run: |
    opts = { stdin_data: "Hello", allow_failure: true }
    stdout = %w[wc -m].run(opts:)

    stdout.to_i == 5 #=> true

.async_run + log

- 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?

.async_run + pass stdin data

- 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?

Downloader

- run: |
    url = 'https://docs.ruby-lang.org/en/master'
    url.download
    # OR: url.download({out_dir: "/tmp", file_name: "index.html"})

Function Pipe

- run: |
    upper = ->s { s.upcase }

    'Foo'
      .(upper)
      . :puts #=> "FOO"