Commit 3fba557d authored by Sean McGivern's avatar Sean McGivern

Add static analysis job to find invalid YAML in changelogs

When a changelog has invalid YAML (typically, there is an unquoted @ at the
start of the author field), then the entry will be discarded. This script checks
all unreleased changelogs for validity, and runs as part of the static-analysis
step, so the pipeline will fail if this happens in future.
parent 05d8e87d
---
title: Detect when changelog entries are invalid
merge_request:
author:
type: other
#!/usr/bin/env ruby
require 'yaml'
invalid_changelogs = Dir['changelogs/**/*.yml'].reject do |changelog|
begin
YAML.load_file(changelog)
rescue
end
end
if invalid_changelogs.any?
puts "Changelogs with invalid YAML found!\n"
puts invalid_changelogs.sort
exit 1
else
puts "All changelogs are valid YAML.\n"
exit 0
end
......@@ -13,7 +13,8 @@ tasks = [
%w[yarn run eslint],
%w[bundle exec rubocop --require rubocop-rspec],
%w[scripts/lint-conflicts.sh],
%w[bundle exec rake gettext:lint]
%w[bundle exec rake gettext:lint],
%w[scripts/lint-changelog-yaml]
]
failed_tasks = tasks.reduce({}) do |failures, task|
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment