ci: add missing libreadline-dev
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Glenn Y. Rolland 2023-04-24 18:43:04 +02:00
parent adc96653e5
commit a921acc3f9
8 changed files with 67 additions and 11 deletions

View file

@ -11,7 +11,7 @@ steps:
path: /_cache
commands:
- pwd
- apt-get update && apt-get install -y cmake g++
- apt-get update && apt-get install -y cmake g++ libreadline-dev
- shards install
- shards build --production --static
- strip bin/docmachine

View file

@ -1,8 +1,13 @@
require "path"
require "file_utils"
require "./config"
module DocMachine::Build
class Run
Log = DB::Log.for("docmachine.build") # Log for db.pool source
def initialize(@config : DocMachine::Build::Config)
@basehash = Digest::SHA256.hexdigest(@config.data_dir)[0..6]
@docker_name = "docmachine-#{@basehash}"
@ -20,6 +25,11 @@ module DocMachine::Build
puts "docker_image = #{@docker_image}"
puts "action = #{@config.action}"
self._avoid_duplicates()
self._pull_image()
end
private def _avoid_duplicates
docker_cid = %x{docker ps -f "name=#{@docker_name}" -q}.strip
puts "docker_name: #{@docker_name}"
@ -30,6 +40,29 @@ module DocMachine::Build
end
end
def _pull_image
data_cache_dir = (
if ENV["XDG_CACHE_HOME"]?
Path[ENV["XDG_CACHE_HOME"], "docmachine"]
else
Path[ENV["HOME"], ".cache", "docmachine"]
end
)
data_cache_file = data_cache_dir / "image.tar"
puts "Checking cache #{data_cache_file}..."
if ! File.exists? data_cache_file.to_s
puts "Downloading #{@docker_image} image..."
Process.run("docker", ["pull", @docker_image], output: STDOUT)
puts "Building cache for image (#{data_cache_dir})"
FileUtils.mkdir_p(data_cache_dir)
Process.run("docker", ["save", @docker_image, "-o", data_cache_file.to_s], output: STDOUT)
puts "done"
else
puts "Cache already exist. Skipping."
end
end
def start()
uid = %x{id -u}.strip
gid = %x{id -g}.strip

View file

@ -47,18 +47,17 @@ module DocMachine
end
parser.parse(args)
puts commands
Log.info { "commands = #{commands}" }
if commands.size < 1
puts parser.to_s
Log.error { "ERROR: no command defined" }
end
if commands.size > 0
commands.each do |command|
# puts "== Running #{command}"
command.call()
end
else
puts parser.to_s
STDOUT.puts ""
STDERR.puts "ERROR: no command defined"
end
end
end
end

14
src/common/docker.cr Normal file
View file

@ -0,0 +1,14 @@
class Docker
property image : String
def initialize(@image)
end
def store_image
end
def image_load
end
end

View file

@ -1,5 +1,8 @@
module DocMachine
Log = ::Log.for("doc_machine")
class Config
property verbose : Bool = false

View file

@ -1,6 +1,7 @@
require "./cli"
Log.setup(:debug)
app = DocMachine::Cli.new
app.start(ARGV)

View file

@ -2,7 +2,11 @@ require "./config"
require "./run"
module DocMachine::Write
Log = DocMachine::Log.for("write")
class Cli
Log = DocMachine::Write::Log.for("cli")
def self.add_options(opts, args, parent_config, commands)
config = Config.new(parent_config)
@ -15,7 +19,7 @@ module DocMachine::Write
commands << ->() : Nil do
if args.size < 1
STDERR.puts "ERROR: No target given!"
Log.error { "ERROR: No target given!" }
exit 1
end
config.target_directory = args[0]

View file

@ -2,6 +2,8 @@
module DocMachine::Write
class Config
Log = DocMachine::Write.for("config")
property target_directory : String = "."
property force : Bool = false