# Parses each YAML file given on the command line and fails on the first syntax error (Gitea rejects a workflow that # does not parse, Docker Compose a compose file). Workflows must also declare "on" and "jobs". require "yaml" failed = false ARGV.each do |path| begin document = YAML.safe_load(File.read(path), aliases: true) if path.include?(".gitea/workflows/") # YAML 1.1 reads the bare key "on" as true. missing = [] missing << "on" unless document.key?("on") || document.key?(true) missing << "jobs" unless document.key?("jobs") raise "missing #{missing.join(', ')}" unless missing.empty? end puts "ok #{path}" rescue StandardError => e failed = true puts "ERROR #{path}: #{e.message}" end end exit(failed ? 1 : 0)