mirror of
https://github.com/zhigang1992/probot.github.io.git
synced 2026-03-26 06:55:03 +08:00
Add lint tests
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: commitlint
|
||||
description: A GitHub App that lints all commits of new or edited pull requests and
|
||||
description: Lints all commits of new or edited pull requests and
|
||||
sets an appropriate status check.
|
||||
slug: commitlint
|
||||
screenshots:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: First Timers Bot
|
||||
description: A friendly bot that helps with onboarding new Open Source Contributors
|
||||
description: Create starter issues to help onboard new open source contributors
|
||||
slug: first-timers
|
||||
screenshots:
|
||||
- https://raw.githubusercontent.com/hoodiehq/first-timers-bot/master/assets/Issue-Done.png
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: invite-contributors
|
||||
description: Automatically invite authors of merged pull requests to your organization
|
||||
description: Invite authors of merged pull requests to your organization
|
||||
slug: invite-contributors
|
||||
screenshots:
|
||||
- https://i.imgur.com/USwS3CF.png
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Polls
|
||||
description: Automatically create polls in GitHub issues.
|
||||
description: Create polls in GitHub issues.
|
||||
slug: polls
|
||||
screenshots:
|
||||
- https://raw.githubusercontent.com/evenchange4/gh-polls-bot/master/docs/screenshot.png
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Reminders
|
||||
description: reminders for Issues and Pull Requests
|
||||
description: Set reminders on Issues and Pull Requests
|
||||
slug: reminders
|
||||
screenshots:
|
||||
- https://user-images.githubusercontent.com/173/30673997-505a993a-9e77-11e7-8f0f-d5a606816e8e.png
|
||||
|
||||
@@ -2,5 +2,6 @@
|
||||
|
||||
set -e
|
||||
|
||||
ruby test/*_test.rb
|
||||
script/build
|
||||
script/html-proofer
|
||||
|
||||
41
test/frontmatter.yml
Normal file
41
test/frontmatter.yml
Normal file
@@ -0,0 +1,41 @@
|
||||
# Each piece of content has YAML front matter with these properties:
|
||||
title:
|
||||
type: String
|
||||
required: true
|
||||
|
||||
description:
|
||||
type: String
|
||||
required: true
|
||||
|
||||
slug:
|
||||
type: String
|
||||
required: true
|
||||
|
||||
screenshots:
|
||||
type: Array
|
||||
required: true
|
||||
|
||||
authors:
|
||||
type: Array
|
||||
required: true
|
||||
|
||||
repository:
|
||||
type: String
|
||||
required: true
|
||||
|
||||
host:
|
||||
type: String
|
||||
required: true
|
||||
|
||||
# All these fields are generated by `scripts/sync-data`
|
||||
stars:
|
||||
type: Numeric
|
||||
|
||||
installations:
|
||||
type: Numeric
|
||||
|
||||
organizations:
|
||||
type: Array
|
||||
|
||||
updated:
|
||||
type: String
|
||||
52
test/lint_test.rb
Normal file
52
test/lint_test.rb
Normal file
@@ -0,0 +1,52 @@
|
||||
require "bundler/setup"
|
||||
require "safe_yaml"
|
||||
require "minitest/autorun"
|
||||
|
||||
describe "lint test" do
|
||||
BANNED_WORDS = Regexp.new('\b(' + [
|
||||
"GitHub App", # They're all GitHub Apps
|
||||
"bot", # TODO: link to docs about why bot is not preferred
|
||||
"automatically" # They're all automatic
|
||||
].join('|') + ')\b', Regexp::IGNORECASE | Regexp::MULTILINE)
|
||||
|
||||
Dir.glob("_apps/*.md").each do |path|
|
||||
describe path do
|
||||
# Load frontmatter
|
||||
data = SafeYAML.load_file(path)
|
||||
fields = SafeYAML.load_file("test/frontmatter.yml")
|
||||
|
||||
it "does not have extraneous fields" do
|
||||
extra_fields = data.keys - fields.keys
|
||||
assert extra_fields.empty?, "Unexpected metadata: #{extra_fields.inspect}"
|
||||
end
|
||||
|
||||
fields.each do |name, attrs|
|
||||
if attrs["required"]
|
||||
it "${name} is required" do
|
||||
assert data.key?(name), "#{name} is required"
|
||||
end
|
||||
end
|
||||
|
||||
if attrs["type"] && data[name]
|
||||
it "${name} must be a #{attrs["type"]}" do
|
||||
assert_kind_of Kernel.const_get(attrs["type"]), data[name]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it "description should be sentence case" do
|
||||
first_letter = data["description"][0]
|
||||
assert_equal first_letter.upcase, first_letter, "Description should be in sentence case"
|
||||
end
|
||||
|
||||
it "does not use banned words" do
|
||||
%w(title description slug).each do |field|
|
||||
match = data[field].match(BANNED_WORDS)
|
||||
if match
|
||||
assert !match, "`#{match[1]}` should not be used in #{field}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user