diff --git a/_apps/commitlint.md b/_apps/commitlint.md index e4001ef..d230a27 100644 --- a/_apps/commitlint.md +++ b/_apps/commitlint.md @@ -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: diff --git a/_apps/first-timers.md b/_apps/first-timers.md index 271162e..480f1ae 100644 --- a/_apps/first-timers.md +++ b/_apps/first-timers.md @@ -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 diff --git a/_apps/invite-contributors.md b/_apps/invite-contributors.md index 9179959..d4aa430 100644 --- a/_apps/invite-contributors.md +++ b/_apps/invite-contributors.md @@ -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 diff --git a/_apps/polls.md b/_apps/polls.md index e2067f3..38c4d9b 100644 --- a/_apps/polls.md +++ b/_apps/polls.md @@ -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 diff --git a/_apps/reminders.md b/_apps/reminders.md index dae8d82..0ed0801 100644 --- a/_apps/reminders.md +++ b/_apps/reminders.md @@ -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 diff --git a/script/test b/script/test index 6a65159..e45905a 100755 --- a/script/test +++ b/script/test @@ -2,5 +2,6 @@ set -e +ruby test/*_test.rb script/build script/html-proofer diff --git a/test/frontmatter.yml b/test/frontmatter.yml new file mode 100644 index 0000000..0b20977 --- /dev/null +++ b/test/frontmatter.yml @@ -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 diff --git a/test/lint_test.rb b/test/lint_test.rb new file mode 100644 index 0000000..53c5c99 --- /dev/null +++ b/test/lint_test.rb @@ -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