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.
This commit is contained in:
parent
05d8e87dba
commit
3fba557d5c
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Detect when changelog entries are invalid
|
||||
merge_request:
|
||||
author:
|
||||
type: other
|
|
@ -0,0 +1,19 @@
|
|||
#!/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|
|
||||
|
|
Loading…
Reference in New Issue