-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Squashed commit of the following: commit 4ff0e66 Author: Travis CI <ci@travis-ci.org> Date: Tue Jan 8 23:36:25 2019 +0800 Unicode, take II commit 505d868 Author: Travis CI <ci@travis-ci.org> Date: Tue Jan 8 23:27:04 2019 +0800 Unicode commit de5e895 Author: Travis CI <ci@travis-ci.org> Date: Tue Jan 8 23:22:45 2019 +0800 Fix commit 0ef5eeb Author: Liu Xiaoyi <circuitcoder0@gmail.com> Date: Tue Jan 8 23:13:13 2019 +0800 (Trying) to fix the push script commit 33b7971 Author: Liu Xiaoyi <circuitcoder0@gmail.com> Date: Tue Jan 8 23:04:12 2019 +0800 Added the validator and only run the CI push tag on tuna/blogroll:master
- Loading branch information
1 parent
d8ffcbf
commit 416c9c1
Showing
5 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
Submodule feedvalidator
added at
849deb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
#!/usr/bin/env python2 | ||
|
||
from os import sys,path,environ | ||
|
||
environ['LANGUAGE'] = 'en' | ||
|
||
import urllib2 | ||
# OK I know I cannot write python | ||
sys.path.append(path.join(path.dirname(__file__), 'feedvalidator', 'src')) | ||
|
||
from bs4 import BeautifulSoup | ||
import feedvalidator | ||
|
||
with open(sys.argv[1], 'r') as opmlFile: | ||
|
||
opml = opmlFile.read().decode('utf-8') | ||
opml = BeautifulSoup(opml, 'xml') | ||
|
||
entries = opml.find_all('outline') | ||
|
||
total = len(entries) | ||
|
||
# Ones that failed the connectivity test | ||
siteFailed = [] | ||
|
||
# Ones that failed the feed validator test | ||
feedCritical = [] | ||
|
||
# Ones that triggered feed validator warnings | ||
feedWarning = [] | ||
|
||
for entry in entries: | ||
title = entry.get('title').encode('utf-8') | ||
print '=== Validating %s ===' % title | ||
|
||
site = entry.get('htmlUrl') | ||
code = -1 | ||
print "Testing HTTP connectivity...: %s" % site | ||
try: | ||
resp = urllib2.urlopen(site) | ||
code = resp.getcode() | ||
except Exception as e: | ||
print "Cannot connect to site: %s" % str(e) | ||
siteFailed.append([title, entry]) | ||
|
||
if code >= 200 and code < 400: | ||
# Is a valid response | ||
print "Site successfully responded with code %s" % code | ||
elif code >= 0: | ||
print "Site responded with unexpected response code %s" % code | ||
siteFailed.append([title, entry]) | ||
|
||
print "Fetching feeds..." | ||
feed = entry.get('xmlUrl') | ||
|
||
events = None | ||
try: | ||
events = feedvalidator.validateURL(feed, firstOccurrenceOnly=0)['loggedEvents'] | ||
except feedvalidator.logging.ValidationFailure as vf: | ||
events = [vf.event] | ||
except Exception as e: | ||
print "Unable to fetch feed: %s" % str(e) | ||
feedCritical.append(e) | ||
|
||
if events is not None: | ||
from feedvalidator import compatibility | ||
from feedvalidator.formatter.text_plain import Formatter | ||
|
||
criticals = compatibility.A(events) | ||
if len(criticals) > 0: | ||
print "Feed failed validation with critical errors:" | ||
output = Formatter(criticals) | ||
print "\n".join(output) | ||
feedCritical.append([title, entry]) | ||
else: | ||
warnings = compatibility.AAA(events) | ||
if len(warnings) > 0: | ||
print "Feed passed validation with warnings:" | ||
output = Formatter(warnings) | ||
print "\n".join(output) | ||
feedWarning.append([title, entry]) | ||
else: | ||
print "Feed passed validation with no error or warning" | ||
|
||
print "" | ||
|
||
print "### SUMMARY ###" | ||
print "In total of %s entries:" % len(entries) | ||
print "%s entries failed the connectivity test:" % len(siteFailed) | ||
for [title, entry] in siteFailed: | ||
print "\t%s: %s" % (title, entry) | ||
print "" | ||
|
||
print "%s entries failed the feed validation:" % len(feedCritical) | ||
for [title, entry] in feedCritical: | ||
print "\t%s: %s" % (title, entry) | ||
print "" | ||
|
||
print "%s entries passed the feed validation with warnings:" % len(feedWarning) | ||
for [title, entry] in feedWarning: | ||
print "\t%s: %s" % (title, entry) | ||
print "" | ||
|
||
if len(feedCritical) > 0: | ||
sys.exit(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[submodule ".build/feedvalidator"] | ||
path = .build/feedvalidator | ||
url = https://github.com/rubys/feedvalidator | ||
branch = master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
language: generic | ||
dist: xenial | ||
|
||
branches: | ||
only: | ||
- master | ||
|
||
before_install: | ||
- sudo apt-get install git | ||
- sudo apt-get install python python-lxml python-bs4 | ||
|
||
script: | ||
- .build/buildOpml.sh > opml.xml | ||
# For now, half the tests fail, so I'm muting the error | ||
- .build/validator.py opml.xml || true | ||
|
||
after_success: | ||
- .build/push.sh |