Add bin and edit workflow
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 9s

This commit is contained in:
2026-09-16 13:11:16 -06:00
parent c8ac4fcae5
commit 4cee170d66
17576 changed files with 895740 additions and 2 deletions
@@ -0,0 +1,57 @@
# frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2024, by Samuel Williams.
module Console
module Terminal
module Formatter
class Failure
KEY = :failure
def initialize(terminal)
@terminal = terminal
@terminal[:exception_title] ||= @terminal.style(:red, nil, :bold)
@terminal[:exception_detail] ||= @terminal.style(:yellow)
@terminal[:exception_backtrace] ||= @terminal.style(:red)
@terminal[:exception_backtrace_other] ||= @terminal.style(:red, nil, :faint)
@terminal[:exception_message] ||= @terminal.style(:default)
end
def format(event, output, prefix: nil, verbose: false, width: 80)
title = event[:class]
message = event[:message]
backtrace = event[:backtrace]
root = event[:root]
lines = message.lines.map(&:chomp)
output.puts " #{prefix}#{@terminal[:exception_title]}#{title}#{@terminal.reset}: #{lines.shift}"
lines.each do |line|
output.puts " #{@terminal[:exception_detail]}#{line}#{@terminal.reset}"
end
root_pattern = /^#{root}\// if root
backtrace&.each_with_index do |line, index|
path, offset, message = line.split(":", 3)
style = :exception_backtrace
# Make the path a bit more readable:
if root_pattern and path.sub!(root_pattern, "").nil?
style = :exception_backtrace_other
end
output.puts " #{index == 0 ? "→" : " "} #{@terminal[style]}#{path}:#{offset}#{@terminal[:exception_message]} #{message}#{@terminal.reset}"
end
if cause = event[:cause]
format(cause, output, prefix: "Caused by ", verbose: verbose, width: width)
end
end
end
end
end
end
@@ -0,0 +1,58 @@
# frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2020-2024, by Samuel Williams.
module Console
module Terminal
module Formatter
class Progress
KEY = :progress
BLOCK = [
" ",
"▏",
"▎",
"▍",
"▌",
"▋",
"▊",
"▉",
"█",
]
def initialize(terminal)
@terminal = terminal
@terminal[:progress_bar] ||= terminal.style(:blue, :white)
end
def format(event, output, verbose: false, width: 80)
current = event[:current].to_f
total = event[:total].to_f
value = current / total
# Clamp value to 1.0 to avoid rendering issues:
if value > 1.0
value = 1.0
end
output.puts "#{@terminal[:progress_bar]}#{self.bar(value, width-10)}#{@terminal.reset} #{sprintf('%6.2f', value * 100)}%"
end
private
def bar(value, width)
blocks = width * value
full_blocks = blocks.floor
partial_block = ((blocks - full_blocks) * BLOCK.size).floor
if partial_block.zero?
BLOCK.last * full_blocks
else
"#{BLOCK.last * full_blocks}#{BLOCK[partial_block]}"
end.ljust(width)
end
end
end
end
end
@@ -0,0 +1,42 @@
# frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2019-2024, by Samuel Williams.
module Console
module Terminal
module Formatter
# Format spawn events.
class Spawn
KEY = :spawn
def initialize(terminal)
@terminal = terminal
@terminal[:spawn_command] ||= @terminal.style(:blue, nil, :bold)
end
def format(event, output, verbose: false, width: 80)
environment, arguments, options = event.values_at(:environment, :arguments, :options)
arguments = arguments.flatten.collect(&:to_s)
output.puts "#{@terminal[:spawn_command]}#{arguments.join(' ')}#{@terminal.reset}#{chdir_string(options)}"
if verbose and environment
environment.each do |key, value|
output.puts "export #{key}=#{value}"
end
end
end
private
def chdir_string(options)
if options and chdir = options[:chdir]
" in #{chdir}"
end
end
end
end
end
end
@@ -0,0 +1,83 @@
# frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2019-2024, by Samuel Williams.
require "io/console"
module Console
# Styled terminal output.
module Terminal
class Text
def initialize(output)
@output = output
@styles = {reset: self.reset}
end
def [] key
@styles[key]
end
def []= key, value
@styles[key] = value
end
def colors?
false
end
def width
80
end
def style(foreground, background = nil, *attributes)
end
def reset
end
def write(*arguments, style: nil)
if style and prefix = self[style]
@output.write(prefix)
@output.write(*arguments)
@output.write(self.reset)
else
@output.write(*arguments)
end
end
def puts(*arguments, style: nil)
if style and prefix = self[style]
@output.write(prefix)
@output.puts(*arguments)
@output.write(self.reset)
else
@output.puts(*arguments)
end
end
# Print out the given arguments.
# When the argument is a symbol, look up the style and inject it into the output stream.
# When the argument is a proc/lambda, call it with self as the argument.
# When the argument is anything else, write it directly to the output.
def print(*arguments)
arguments.each do |argument|
case argument
when Symbol
@output.write(self[argument])
when Proc
argument.call(self)
else
@output.write(argument)
end
end
end
# Print out the arguments as per {#print}, followed by the reset sequence and a newline.
def print_line(*arguments)
print(*arguments)
@output.puts(self.reset)
end
end
end
end
@@ -0,0 +1,76 @@
# frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2019-2024, by Samuel Williams.
require "io/console"
require_relative "text"
module Console
# Styled terminal output.
module Terminal
class XTerm < Text
COLORS = {
black: 0,
red: 1,
green: 2,
yellow: 3,
blue: 4,
magenta: 5,
cyan: 6,
white: 7,
default: 9,
}.freeze
ATTRIBUTES = {
normal: 0,
bold: 1,
bright: 1,
faint: 2,
italic: 3,
underline: 4,
blink: 5,
reverse: 7,
hidden: 8,
}.freeze
def colors?
true
end
def size
@output.winsize
rescue Errno::ENOTTY
# Fake it...
[24, 80]
end
def width
size.last
end
def style(foreground, background = nil, *attributes)
tokens = []
if foreground
tokens << 30 + COLORS.fetch(foreground)
end
if background
tokens << 40 + COLORS.fetch(background)
end
attributes.each do |attribute|
tokens << ATTRIBUTES.fetch(attribute){attribute.to_i}
end
return "\e[#{tokens.join(';')}m"
end
def reset
"\e[0m"
end
end
end
end