Merge pull request #1698 from nodiscc/tools-detect-unmaintained

Tests: add a script to check last commit dates of github repositories listed in README.md
This commit is contained in:
nodiscc 2019-05-25 11:54:09 +00:00 committed by GitHub
commit 499e5d24bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 63 additions and 4 deletions

View File

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="148" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="a"><rect width="148" height="20" rx="3" fill="#fff"/></mask><g mask="url(#a)"><path fill="#555" d="M0 0h77v20H0z"/><path fill="#4c1" d="M77 0h71v20H77z"/><path fill="url(#b)" d="M0 0h148v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="38.5" y="15" fill="#010101" fill-opacity=".3">Rocket.Chat</text><text x="38.5" y="14">Rocket.Chat</text><text x="111.5" y="15" fill="#010101" fill-opacity=".3">JOIN CHAT</text><text x="111.5" y="14">JOIN CHAT</text></g></svg>

Before

Width:  |  Height:  |  Size: 757 B

View File

@ -12,9 +12,9 @@ before_script:
script: script:
- git diff master.. --unified=0 README.md | grep --perl-regexp --only-matching --silent "(?<=^\+).*" >> temp.md || (exit 0) - git diff master.. --unified=0 README.md | grep --perl-regexp --only-matching --silent "(?<=^\+).*" >> temp.md || (exit 0)
- node test.js temp.md - node tests/test.js temp.md
- awesome_bot temp.md --allow-redirect || (exit 0) - awesome_bot temp.md --allow-redirect || (exit 0)
- danger --verbose - danger --dangerfile=tests/Dangerfile --verbose
notifications: notifications:
email: false email: false

View File

@ -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)