From 5f2be9ac970bd195c502dde285a9ab43ddc5954b Mon Sep 17 00:00:00 2001 From: Dave Machado Date: Thu, 29 Jun 2017 12:25:56 -0400 Subject: [PATCH 01/16] test that env tokens cannot be echo'ed --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 8e87b7ea..482aab74 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,8 @@ before_install: - rvm install 2.4.0 install: - gem install awesome_bot +before_script: + - echo $GH_TOKEN script: - awesome_bot README.md --allow-ssl --allow 403 after_success: From 952e93ff6abe67728b3909ad1e335034fff2185f Mon Sep 17 00:00:00 2001 From: Dave Machado Date: Thu, 29 Jun 2017 12:25:56 -0400 Subject: [PATCH 02/16] test that env tokens cannot be echo'ed --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 5d5c5e8e..3d6b8395 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,8 @@ before_install: - rvm install 2.4.0 install: - gem install awesome_bot +before_script: + - echo $GH_TOKEN script: - awesome_bot README.md --allow-ssl --allow 403,302 after_success: From 0cfca8b5ce9321a04ade0700f7a1e419c593a19e Mon Sep 17 00:00:00 2001 From: Dave Machado Date: Mon, 3 Jul 2017 00:18:20 -0400 Subject: [PATCH 03/16] force travis fail --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3d6b8395..989a523a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ install: before_script: - echo $GH_TOKEN script: - - awesome_bot README.md --allow-ssl --allow 403,302 + - this-wont-run after_success: - cd build - sh build.sh From 6e1da9a1a33da905bc8af344ec30fe3d6cdace8a Mon Sep 17 00:00:00 2001 From: Dave Machado Date: Mon, 10 Jul 2017 00:09:52 -0400 Subject: [PATCH 04/16] Initial skeleton of parsing text file --- build/validate.rb | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100755 build/validate.rb diff --git a/build/validate.rb b/build/validate.rb new file mode 100755 index 00000000..d44cefb3 --- /dev/null +++ b/build/validate.rb @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +args = ARGV +filename = args[0] + +File.foreach(filename).with_index do |line, line_num| + line_num += 1 + puts "#{line_num}: #{line}" + +end From 0fec96164406c290954a47493b35778a155c65ef Mon Sep 17 00:00:00 2001 From: Dave Machado Date: Mon, 10 Jul 2017 00:12:19 -0400 Subject: [PATCH 05/16] Skip schema lines and split lines by pipe-char --- build/validate.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/build/validate.rb b/build/validate.rb index d44cefb3..633aeac2 100755 --- a/build/validate.rb +++ b/build/validate.rb @@ -1,9 +1,20 @@ #!/usr/bin/env ruby + args = ARGV filename = args[0] File.foreach(filename).with_index do |line, line_num| line_num += 1 - puts "#{line_num}: #{line}" +# puts "#{line_num}: #{line}" + if line.start_with?('|') + # Skip table schema lines + if line.eql? "|---|---|---|---|---|\n" + next + end + values = line.split("|") + values.each.with_index do |v, vn| + puts "#{vn}: #{v}" + end + end end From e859668bfd943159df4919e4064aadcda9a1cdae Mon Sep 17 00:00:00 2001 From: Dave Machado Date: Mon, 10 Jul 2017 00:15:01 -0400 Subject: [PATCH 06/16] Validate Auth values to match allowed values --- build/validate.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/build/validate.rb b/build/validate.rb index 633aeac2..3d13b803 100755 --- a/build/validate.rb +++ b/build/validate.rb @@ -1,8 +1,11 @@ #!/usr/bin/env ruby +auth_keys = ['apiKey', 'OAuth', 'X-Mashape-Key', 'No'] args = ARGV filename = args[0] +fail_flag = false +fail_count = 0 File.foreach(filename).with_index do |line, line_num| line_num += 1 # puts "#{line_num}: #{line}" @@ -13,8 +16,12 @@ File.foreach(filename).with_index do |line, line_num| end values = line.split("|") - values.each.with_index do |v, vn| - puts "#{vn}: #{v}" + # Check Auth Values to conform to valid options only + auth_val = values[3].lstrip.chop.tr('``', '') + if !auth_keys.include? auth_val + puts "(#{line_num}) Invalid Auth (#{auth_val}): #{line}" + fail_flag = false + fail_count += 1 end end end From 34b8ba3164d77a3c793b15928eaeb7f6a398c7e1 Mon Sep 17 00:00:00 2001 From: Dave Machado Date: Mon, 10 Jul 2017 00:42:14 -0400 Subject: [PATCH 07/16] Add HTTPS Support check for Yes or No --- build/validate.rb | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/build/validate.rb b/build/validate.rb index 3d13b803..9191db6a 100755 --- a/build/validate.rb +++ b/build/validate.rb @@ -1,11 +1,11 @@ #!/usr/bin/env ruby auth_keys = ['apiKey', 'OAuth', 'X-Mashape-Key', 'No'] +https_keys = ['Yes', 'No'] args = ARGV filename = args[0] fail_flag = false -fail_count = 0 File.foreach(filename).with_index do |line, line_num| line_num += 1 # puts "#{line_num}: #{line}" @@ -14,14 +14,20 @@ File.foreach(filename).with_index do |line, line_num| if line.eql? "|---|---|---|---|---|\n" next end - values = line.split("|") - # Check Auth Values to conform to valid options only + + # Check Auth values to conform to valid options only auth_val = values[3].lstrip.chop.tr('``', '') - if !auth_keys.include? auth_val - puts "(#{line_num}) Invalid Auth (#{auth_val}): #{line}" - fail_flag = false - fail_count += 1 + if !auth_keys.include?(auth_val) + puts "(#{line_num}) Invalid Auth (not a valid option): #{auth_val}" + fail_flag = true + end + + # Check HTTPS Support values to be either "Yes" or "No" + https_val = values[4].lstrip.chop + if !https_keys.include?(https_val) + puts "(#{line_num}) Invalid HTTPS: (must use \"Yes\" or \"No\"): #{https_val}" + fail_flag = true end end end From 4206f34cf3864c19e09eaa53062ea72f1249de22 Mon Sep 17 00:00:00 2001 From: Dave Machado Date: Mon, 10 Jul 2017 00:44:39 -0400 Subject: [PATCH 08/16] Check Links for [Go] wrapper --- build/validate.rb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/build/validate.rb b/build/validate.rb index 9191db6a..80a746c3 100755 --- a/build/validate.rb +++ b/build/validate.rb @@ -19,15 +19,22 @@ File.foreach(filename).with_index do |line, line_num| # Check Auth values to conform to valid options only auth_val = values[3].lstrip.chop.tr('``', '') if !auth_keys.include?(auth_val) - puts "(#{line_num}) Invalid Auth (not a valid option): #{auth_val}" - fail_flag = true + puts "(#{line_num}) Invalid Auth (not a valid option): #{auth_val}" + fail_flag = true end # Check HTTPS Support values to be either "Yes" or "No" https_val = values[4].lstrip.chop if !https_keys.include?(https_val) - puts "(#{line_num}) Invalid HTTPS: (must use \"Yes\" or \"No\"): #{https_val}" - fail_flag = true + puts "(#{line_num}) Invalid HTTPS: (must use \"Yes\" or \"No\"): #{https_val}" + fail_flag = true + end + + # Check Link to ensure url is wrapped in "[Go!]" view + link_val = values[5].lstrip.chop + if !link_val.start_with?("[Go!](") || !link_val.end_with?(')') + puts "(#{line_num}) Invalid Link: (format should be \"[Go!]()\"): #{link_val}" + fail_flag = true end end end From 2e6d999b487b7f61c380b4c4a904291ebb0adff2 Mon Sep 17 00:00:00 2001 From: Dave Machado Date: Mon, 10 Jul 2017 00:46:47 -0400 Subject: [PATCH 09/16] Add exit condition --- build/validate.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build/validate.rb b/build/validate.rb index 80a746c3..b8b43755 100755 --- a/build/validate.rb +++ b/build/validate.rb @@ -38,3 +38,9 @@ File.foreach(filename).with_index do |line, line_num| end end end + +if fail_flag + exit(1) +else + exit(0) +end From 375487cd8f68e515a0fabeeed5be177ee219f425 Mon Sep 17 00:00:00 2001 From: Dave Machado Date: Mon, 10 Jul 2017 00:53:15 -0400 Subject: [PATCH 10/16] Check Description for capitalization --- build/validate.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/build/validate.rb b/build/validate.rb index b8b43755..fd1b4617 100755 --- a/build/validate.rb +++ b/build/validate.rb @@ -16,6 +16,13 @@ File.foreach(filename).with_index do |line, line_num| end values = line.split("|") + # Check Description to make sure first character is capitalized + desc_val = values[2].lstrip.chop + if !/[[:upper:]]/.match(desc_val[0]) + puts "(#{line_num}) Invalid Description (first char not uppercase): #{desc_val}" + fail_flag = true + end + # Check Auth values to conform to valid options only auth_val = values[3].lstrip.chop.tr('``', '') if !auth_keys.include?(auth_val) From 5902def838f159555be3439b5ea6f6ecb3548225 Mon Sep 17 00:00:00 2001 From: Dave Machado Date: Mon, 10 Jul 2017 00:54:35 -0400 Subject: [PATCH 11/16] Update formatting --- build/validate.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build/validate.rb b/build/validate.rb index fd1b4617..eecfa514 100755 --- a/build/validate.rb +++ b/build/validate.rb @@ -4,11 +4,10 @@ https_keys = ['Yes', 'No'] args = ARGV filename = args[0] - fail_flag = false + File.foreach(filename).with_index do |line, line_num| line_num += 1 -# puts "#{line_num}: #{line}" if line.start_with?('|') # Skip table schema lines if line.eql? "|---|---|---|---|---|\n" From eb4b1dfa058f6cf1a38dc537bf9ed48c218b43a9 Mon Sep 17 00:00:00 2001 From: Dave Machado Date: Mon, 10 Jul 2017 01:01:47 -0400 Subject: [PATCH 12/16] Add main CI driver script --- build/main.sh | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 build/main.sh diff --git a/build/main.sh b/build/main.sh new file mode 100644 index 00000000..2e074ca9 --- /dev/null +++ b/build/main.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +if [ "$TRAVIS_BRANCH" == "master" ] +then + awesome_bot README.md --allow-ssl --allow 403,302 +fi + +./validate.rb ../README.md From 3448c6cb0d915b73a61238dc287699627d54640c Mon Sep 17 00:00:00 2001 From: Dave Machado Date: Mon, 10 Jul 2017 01:05:15 -0400 Subject: [PATCH 13/16] Update CI steps to use main script --- .travis.yml | 10 +++++----- build/deploy.sh | 0 build/main.sh | 0 3 files changed, 5 insertions(+), 5 deletions(-) mode change 100644 => 100755 build/deploy.sh mode change 100644 => 100755 build/main.sh diff --git a/.travis.yml b/.travis.yml index 989a523a..75b2a301 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,10 +6,10 @@ before_install: install: - gem install awesome_bot before_script: - - echo $GH_TOKEN + - cd build script: - - this-wont-run + - main.sh after_success: - - cd build - - sh build.sh - - sh deploy.sh + - build.sh + - deploy.sh + diff --git a/build/deploy.sh b/build/deploy.sh old mode 100644 new mode 100755 diff --git a/build/main.sh b/build/main.sh old mode 100644 new mode 100755 From ab045f33f391f6a16363856f96cd1ab3ddaf5d0b Mon Sep 17 00:00:00 2001 From: Dave Machado Date: Mon, 10 Jul 2017 01:41:50 -0400 Subject: [PATCH 14/16] Update main script and Travis config --- .travis.yml | 8 ++++---- build/main.sh | 12 ++++++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 75b2a301..b129b10d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -language: node_js +nguage: node_js notifications: email: false before_install: @@ -8,8 +8,8 @@ install: before_script: - cd build script: - - main.sh + - ./main.sh after_success: - - build.sh - - deploy.sh + - ./build.sh + - ./deploy.sh diff --git a/build/main.sh b/build/main.sh index 2e074ca9..619c1776 100755 --- a/build/main.sh +++ b/build/main.sh @@ -1,8 +1,16 @@ #!/bin/bash +echo "running format validation..." +./validate.rb ../README.md + +if ["$?" == 0]; then + echo "format validation PASSED" +else + echo "format validation FAILED" +fi + if [ "$TRAVIS_BRANCH" == "master" ] then + echo "running link validation..." awesome_bot README.md --allow-ssl --allow 403,302 fi - -./validate.rb ../README.md From e28bfd95423808afb5e7330a731ea8f29265bd2b Mon Sep 17 00:00:00 2001 From: Dave Machado Date: Mon, 10 Jul 2017 01:42:55 -0400 Subject: [PATCH 15/16] fix formatting bug --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b129b10d..e702877d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -nguage: node_js +language: node_js notifications: email: false before_install: From d2b84f31598f5e57d4e69adf80cec526206e8282 Mon Sep 17 00:00:00 2001 From: Dave Machado Date: Mon, 10 Jul 2017 09:24:10 -0400 Subject: [PATCH 16/16] Fix line formatting for master branch conditional --- build/main.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build/main.sh b/build/main.sh index 619c1776..4e4dc52e 100755 --- a/build/main.sh +++ b/build/main.sh @@ -9,8 +9,7 @@ else echo "format validation FAILED" fi -if [ "$TRAVIS_BRANCH" == "master" ] -then +if [ "$TRAVIS_BRANCH" == "master" ]; then echo "running link validation..." awesome_bot README.md --allow-ssl --allow 403,302 fi