mirror of
https://gitlab.com/ansol/web-ansol.org.git
synced 2024-11-25 15:43:17 +00:00
Tenta meter checks às datas no CI
This commit is contained in:
parent
8a23c8f0f1
commit
ea4ed078ed
@ -2,6 +2,7 @@ image: klakegg/hugo:0.88.0-ext-ci # recommended image by Hugo: https://gohugo.io
|
||||
|
||||
test:
|
||||
script:
|
||||
- ./checkdates.rb
|
||||
- hugo
|
||||
except:
|
||||
- master
|
||||
|
36
checkdates.rb
Executable file
36
checkdates.rb
Executable file
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require 'yaml'
|
||||
require 'date'
|
||||
|
||||
class YAMLFrontMatter
|
||||
PATTERN = /\A(---\r?\n(.*?)\n?^---\s*$\n?)/m.freeze
|
||||
|
||||
class << self
|
||||
def extract(content)
|
||||
if content =~ PATTERN
|
||||
[YAML.load(Regexp.last_match(2), permitted_classes: [Symbol, Date, Time]), content.sub(Regexp.last_match(1), "")]
|
||||
else
|
||||
[{}, content]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Dir["content/eventos/*/index.md"].each do |filename|
|
||||
metadata, _ = YAMLFrontMatter.extract(File.read(filename))
|
||||
|
||||
raise "#{filename}: wrong layout: #{metadata["layout"]}" unless metadata["layout"] == "evento"
|
||||
raise "#{filename}: no title" unless metadata.keys.include?("title")
|
||||
raise "#{filename}: no metadata" unless metadata.keys.include?("metadata")
|
||||
|
||||
raise "#{filename}: no event location" unless metadata.dig("metadata", "event", "location")
|
||||
|
||||
start = metadata.dig("metadata", "event", "date", "start")
|
||||
finish = metadata.dig("metadata", "event", "date", "finish")
|
||||
|
||||
raise "#{filename}: no event start date" unless start
|
||||
raise "#{filename}: no event finish date" unless finish
|
||||
|
||||
raise "#{filename}: time paradox: #{start} - #{finish}" unless start.to_time <= finish.to_time
|
||||
end
|
@ -1,5 +1,5 @@
|
||||
---
|
||||
categories: []
|
||||
layout: evento
|
||||
metadata:
|
||||
event:
|
||||
location: Online
|
||||
|
@ -3,7 +3,7 @@ layout: evento
|
||||
title: Devops na Praia #2
|
||||
metadata:
|
||||
event:
|
||||
location:
|
||||
location: Wunderman Thompson Commerce - Edifício Transparente, Porto
|
||||
site:
|
||||
url: https://www.eventbrite.pt/e/bilhetes-devops-na-praia-2-720753933417?aff=oddtdtcreator
|
||||
date:
|
||||
|
Loading…
Reference in New Issue
Block a user