diff options
author | Dave Lockwood <1261876+deamos@users.noreply.github.com> | 2019-09-30 00:29:40 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-30 00:29:40 +0000 |
commit | 2518c3f1116d425c9eea2062656f130499d514cf (patch) | |
tree | a07aa1c63371b33d09a516305176a814c084a7a1 /tests | |
parent | Add Open Streaming Platform (diff) | |
parent | Merge pull request #1808 from nodiscc/feed-readers-cleanup (diff) | |
download | awesome-selfhosted-2518c3f1116d425c9eea2062656f130499d514cf.tar.gz awesome-selfhosted-2518c3f1116d425c9eea2062656f130499d514cf.zip |
Merge pull request #1 from Kickball/master
merge
Diffstat (limited to '')
-rw-r--r-- | tests/Dangerfile (renamed from Dangerfile) | 0 | ||||
-rwxr-xr-x | tests/check-github-commit-dates.py | 60 | ||||
-rw-r--r-- | tests/test.js (renamed from test.js) | 10 |
3 files changed, 68 insertions, 2 deletions
diff --git a/Dangerfile b/tests/Dangerfile index 115931df..115931df 100644 --- a/Dangerfile +++ b/tests/Dangerfile diff --git a/tests/check-github-commit-dates.py b/tests/check-github-commit-dates.py new file mode 100755 index 00000000..f148bac2 --- /dev/null +++ b/tests/check-github-commit-dates.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python3 + +""" A script to find github repo links and last commit dates in a markdown file + +Requirements: + - python3 github module (sudo apt install python3-github on Debian) + - A personal access token (https://github.com/settings/tokens) + +Usage: + - Run awesome_bot --allow-redirect -f README.md beforehand to detect any error(4xx, 5xx) that would + cause the script to abort + - Github API calls are limited to 5000 requests/hour https://developer.github.com/v3/#rate-limiting + - Put the token in your environment variables: + export GITHUB_TOKEN=18c45f8d8d556492d1d877998a5b311b368a76e4 + - The output is unsorted, just pipe it through 'sort' or paste it in your editor and sort from there + - Put the script in your crontab or run it from time to time. It doesn't make sense to add this + script to the CI job that runs every time something is pushed. + - To detect no-commit related activity (repo metadata changes, wiki edits, ...), replace pushed_at + with updated_at + +""" + +from github import Github +import sys +import time +import re +import os + +__author__ = "nodiscc" +__copyright__ = "Copyright 2019, nodiscc" +__credits__ = ["https://github.com/kickball/awesome-selfhosted"] +__license__ = "MIT" +__version__ = "1.0" +__maintainer__ = "nodiscc" +__email__ = "nodiscc@gmail.com" +__status__ = "Production" + +############################################################################### + +access_token = os.environ['GITHUB_TOKEN'] + +""" find all URLs of the form https://github.com/owner/repo """ +with open('README.md', 'r') as readme: + data = readme.read() + project_urls = re.findall('https://github.com/[A-z]*/[A-z|0-9|\-|_|\.]+', data) + +urls = sorted(set(project_urls)) + +""" Uncomment this to debug the list of matched URLs """ +# print(str(urls)) +# exit(0) + +""" login to github API """ +g = Github(access_token) + +""" load project metadata, output last commit date and URL """ +for url in urls: + project = re.sub('https://github.com/', '', url) + repo = g.get_repo(project) + print(str(repo.pushed_at) + ' https://github.com/' + project) @@ -4,7 +4,7 @@ const fs = require('fs'); let log = '{\n'; let issuelog = ' "message": "#### Syntax Issues\\n\\n Name | Entry\\n----|----------------------\\n'; - +let fails = '' const file = fs.readFileSync(process.argv[2], 'utf8'); // Reads argv into var file function entryFilter(md) { // Function to find lines with entries @@ -52,6 +52,10 @@ function entryErrorCheck(md) { let totalPass = 0; let total = 0; const entryArray = []; + if (entries[0] === "") { + console.log("0 Entries") + process.exit(0) + } for (let i = 0, len = entries.length; i < len; i += 1) { // Loop to create array of objects entryArray[i] = new Object; entryArray[i].raw = entries[i]; @@ -66,11 +70,13 @@ function entryErrorCheck(md) { // entryArray[i].error = findError(entries[i]) //WIP totalFail += 1; issuelog += `${entryArray[i].name} | ${entries[i]} \\n`; + fails += `${entries[i]} \n\n`; } } } if (totalFail > 0) { // Logs # passed & failed to console, and failures to syntaxcheck.json - console.log(`${totalFail} Failed, ${totalPass} Passed, of ${total}`); + console.log(`${totalFail} Failed, ${totalPass} Passed, of ${total}\n-----------------------------`); + console.log(fails) log += ` "error": true,\n "title": "Found ${totalFail} entries with syntax error(s).",\n`; fs.writeFileSync('syntaxcheck.json', `${log} ${issuelog} "\n}`); process.exit(1); |