summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPete Higgins <pete@peterhiggins.org>2020-07-10 13:15:19 -0700
committerPete Higgins <pete@peterhiggins.org>2020-07-10 13:27:07 -0700
commit39cb2e6f9bcfddbcbce179aa3161f7cafeb9b409 (patch)
tree829f72e9f2c9eb4821226991d452dcca57d72ff5
parent11fa34a18052c10434051b274c66dce713835a58 (diff)
downloadchef-39cb2e6f9bcfddbcbce179aa3161f7cafeb9b409.tar.gz
Refer to specific rake file to avoid needing bundler to use rake in CI.
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
-rw-r--r--.expeditor/verify.pipeline.yml3
-rw-r--r--tasks/spellcheck.rb20
2 files changed, 18 insertions, 5 deletions
diff --git a/.expeditor/verify.pipeline.yml b/.expeditor/verify.pipeline.yml
index 60142e9928..987980aa3a 100644
--- a/.expeditor/verify.pipeline.yml
+++ b/.expeditor/verify.pipeline.yml
@@ -573,9 +573,8 @@ steps:
- label: "Spellcheck"
commands:
- - ruby -rjson -e "JSON.parse(File.read('cspell.json'))" 2>/dev/null || (echo "Failed to parse config file 'cspell.json', skipping spellcheck" && exit 1)
- npm install -g cspell
- - cspell "**/*"
+ - rake -f tasks/spellcheck.rb spellcheck
soft_fail: true
expeditor:
executor:
diff --git a/tasks/spellcheck.rb b/tasks/spellcheck.rb
index 002518d9ee..5b185c1ed6 100644
--- a/tasks/spellcheck.rb
+++ b/tasks/spellcheck.rb
@@ -17,17 +17,31 @@
namespace :spellcheck do
task :fetch_common do
- sh "wget https://raw.githubusercontent.com/chef/chef_dictionary/master/chef.txt -O chef_dictionary.txt"
+ sh "wget -q https://raw.githubusercontent.com/chef/chef_dictionary/master/chef.txt -O chef_dictionary.txt"
end
- task run: :fetch_common do
+ task run: [:config_check, :fetch_common] do
sh 'cspell "**/*"'
end
desc "List the unique unrecognized words in the project."
- task unknown_words: :fetch_common do
+ task unknown_words: [:config_check, :fetch_common] do
sh 'cspell "**/*" --wordsOnly --no-summary | sort | uniq'
end
+
+ task :config_check do
+ require 'json'
+
+ config_file = 'cspell.json'
+
+ unless File.readable?(config_file)
+ abort "Spellcheck config file '#{config_file}' not found, skipping spellcheck"
+ end
+
+ unless (JSON.parse(File.read(config_file)) rescue false)
+ abort "Failed to parse config file '#{config_file}', skipping spellcheck"
+ end
+ end
end
desc "Run spellcheck on the project."