Skip to content

Commit 49eadcd

Browse files
authored
Merge pull request #157 from sommersoft/prune_travis
Spring Cleaning (TravisCI & Patchfiles)
2 parents 38ff411 + 12c1a39 commit 49eadcd

6 files changed

+6
-183
lines changed

adabot/circuitpython_libraries.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import requests
3333

3434
from adabot import github_requests as github
35-
from adabot import travis_requests as travis
3635
from adabot import pypi_requests as pypi
3736
from adabot.lib import circuitpython_library_validators as cirpy_lib_vals
3837
from adabot.lib import common_funcs
@@ -68,12 +67,6 @@
6867
default=5,
6968
metavar="n"
7069
)
71-
cmd_line_parser.add_argument(
72-
"-t", "--travis-github-token",
73-
help="Prompt for the GitHub user's password in order to make a GitHub token to use on Travis.",
74-
dest="gh_token",
75-
action="store_true"
76-
)
7770
cmd_line_parser.add_argument(
7871
"-v", "--validator",
7972
help="Run validators with 'all', or only the validator(s) supplied in a string.",
@@ -504,10 +497,6 @@ def print_issue_overview(*insights):
504497
error_depth = cmd_line_args.error_depth
505498
startup_message.append(" - Depth for listing libraries with errors: {}".format(error_depth))
506499

507-
github_token = cmd_line_args.gh_token
508-
validator_kwarg_list["github_token"] = github_token
509-
startup_message.append(" - Prompts for the GitHub Token are {}.".format(("enabled" if github_token else "disabled")))
510-
511500
if cmd_line_args.validator != "all":
512501
validators = []
513502
for func in cmd_line_args.validator.split(","):

adabot/github_requests.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,11 @@ def get(url, **kwargs):
8282
print("GitHub API Rate Limit reached. Pausing until Rate Limit reset.")
8383
while datetime.datetime.now() < rate_limit_reset:
8484
print("Rate Limit will reset at: {}".format(rate_limit_reset))
85-
if "TRAVIS" in os.environ:
86-
# only pause for 5 minutes so that Travis doesn't timeout
87-
# due to idle console output.
88-
time.sleep(300)
89-
else:
90-
reset_diff = rate_limit_reset - datetime.datetime.now()
91-
92-
print("Sleeping {} seconds".format(reset_diff.seconds))
93-
time.sleep(reset_diff.seconds + 1)
85+
reset_diff = rate_limit_reset - datetime.datetime.now()
86+
87+
print("Sleeping {} seconds".format(reset_diff.seconds))
88+
time.sleep(reset_diff.seconds + 1)
89+
9490
if remaining % 100 == 0:
9591
print(remaining, "requests remaining this hour")
9692
return response

adabot/lib/circuitpython_library_validators.py

Lines changed: 1 addition & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import requests
2626

2727
from adabot import github_requests as github
28-
from adabot import travis_requests as travis
2928
from adabot import pypi_requests as pypi
3029
from adabot.lib import common_funcs
3130
from adabot.lib import assign_hacktober_label as hacktober
@@ -35,7 +34,6 @@
3534

3635

3736
# Define constants for error strings to make checking against them more robust:
38-
ERROR_ENABLE_TRAVIS = "Unable to enable Travis build"
3937
ERROR_README_DOWNLOAD_FAILED = "Failed to download README"
4038
ERROR_README_IMAGE_MISSING_ALT = "README image missing alt text"
4139
ERROR_README_DUPLICATE_ALT_TEXT = "README has duplicate alt text"
@@ -69,16 +67,10 @@
6967
ERROR_MISSING_CODE_OF_CONDUCT = "Missing CODE_OF_CONDUCT.md"
7068
ERROR_MISSING_README_RST = "Missing README.rst"
7169
ERROR_MISSING_READTHEDOCS = "Missing readthedocs.yml"
72-
ERROR_MISSING_TRAVIS_CONFIG = "Missing .travis.yml"
73-
ERROR_MISSING_PYPIPROVIDER = "For pypi compatibility, missing pypi provider in .travis.yml"
7470
ERROR_MISSING_SETUP_PY = "For pypi compatibility, missing setup.py"
7571
ERROR_MISSING_REQUIREMENTS_TXT = "For pypi compatibility, missing requirements.txt"
7672
ERROR_MISSING_BLINKA = "For pypi compatibility, missing Adafruit-Blinka in requirements.txt"
7773
ERROR_NOT_IN_BUNDLE = "Not in bundle."
78-
ERROR_TRAVIS_DOESNT_KNOW_REPO = "Travis doesn't know of repo"
79-
ERROR_TRAVIS_ENV = "Unable to read Travis env variables"
80-
ERROR_TRAVIS_GITHUB_TOKEN = "Unable to find or create (no auth) GITHUB_TOKEN env variable"
81-
ERROR_TRAVIS_TOKEN_CREATE = "Token creation failed"
8274
ERROR_UNABLE_PULL_REPO_CONTENTS = "Unable to pull repo contents"
8375
ERROR_UNABLE_PULL_REPO_DETAILS = "Unable to pull repo details"
8476
ERRRO_UNABLE_PULL_REPO_EXAMPLES = "Unable to retrieve examples folder contents"
@@ -172,9 +164,7 @@ def __init__(self, validators, bundle_submodules, latest_pylint, **kw_args):
172164
self.validators = validators
173165
self.bundle_submodules = bundle_submodules
174166
self.latest_pylint = pkg_version_parse(latest_pylint)
175-
self.full_auth = None
176167
self.output_file_data = []
177-
self.github_token = kw_args.get("github_token", False)
178168
self.validate_contents_quiet = kw_args.get("validate_contents_quiet", False)
179169

180170
def run_repo_validation(self, repo):
@@ -490,7 +480,7 @@ def validate_contents(self, repo):
490480
files = [x["name"] for x in content_list]
491481

492482
# ignore new/in-work repos, which should have less than 8 files:
493-
# ___.py or folder, CoC, .travis.yml, .readthedocs.yml, docs/,
483+
# ___.py or folder, CoC, .github/, .readthedocs.yml, docs/,
494484
# examples/, README, LICENSE
495485
if len(files) < 8:
496486
BUNDLE_IGNORE_LIST.append(repo["name"])
@@ -638,77 +628,6 @@ def validate_contents(self, repo):
638628

639629
return errors
640630

641-
def _validate_travis(self, repo):
642-
""" DISABLED: Validate and configure a repository has the expected state in Travis
643-
CI. This will both check Travis state and attempt to enable Travis CI
644-
and setup the expected state in Travis if not enabled. Expects a
645-
dictionary with a GitHub API repository state (like from the list_repos
646-
function). Returns a list of string error messages for the repository.
647-
"""
648-
return []
649-
650-
if not (repo["owner"]["login"] == "adafruit" and
651-
repo["name"].startswith("Adafruit_CircuitPython")):
652-
return []
653-
repo_url = "/repo/" + repo["owner"]["login"] + "%2F" + repo["name"]
654-
result = travis.get(repo_url)
655-
if not result.ok:
656-
#print(result, result.request.url, result.request.headers)
657-
#print(result.text)
658-
return [ERROR_TRAVIS_DOESNT_KNOW_REPO]
659-
result = result.json()
660-
if not result["active"]:
661-
activate = travis.post(repo_url + "/activate")
662-
if not activate.ok:
663-
#print(activate.request.url)
664-
#print("{} {}".format(activate, activate.text))
665-
return [ERROR_ENABLE_TRAVIS]
666-
667-
env_variables = travis.get(repo_url + "/env_vars")
668-
if not env_variables.ok:
669-
#print(env_variables, env_variables.text)
670-
#print(env_variables.request.headers)
671-
return [ERROR_TRAVIS_ENV]
672-
env_variables = env_variables.json()
673-
found_token = False
674-
for var in env_variables["env_vars"]:
675-
found_token = found_token or var["name"] == "GITHUB_TOKEN"
676-
ok = True
677-
if not found_token:
678-
if not self.github_token:
679-
return [ERROR_TRAVIS_GITHUB_TOKEN]
680-
else:
681-
if not self.full_auth:
682-
#github_user = github_token
683-
github_user = github.get("/user").json()
684-
password = input("Password for " + github_user["login"] + ": ")
685-
self.full_auth = (github_user["login"], password.strip())
686-
if not self.full_auth:
687-
return [ERROR_TRAVIS_GITHUB_TOKEN]
688-
689-
new_access_token = {"scopes": ["public_repo"],
690-
"note": "TravisCI release token for " + repo["full_name"],
691-
"note_url": "https://travis-ci.com/" + repo["full_name"]}
692-
token = github.post("/authorizations", json=new_access_token, auth=self.full_auth)
693-
if not token.ok:
694-
print(token.text)
695-
return [ERROR_TRAVIS_TOKEN_CREATE]
696-
697-
token = token.json()
698-
grant_id = token["id"]
699-
token = token["token"]
700-
701-
new_var = {"env_var.name": "GITHUB_TOKEN",
702-
"env_var.value": token,
703-
"env_var.public": False}
704-
new_var_result = travis.post(repo_url + "/env_vars", json=new_var)
705-
if not new_var_result.ok:
706-
#print(new_var_result.headers, new_var_result.text)
707-
github.delete("/authorizations/{}".format(grant_id), auth=self.full_auth)
708-
return [ERROR_TRAVIS_GITHUB_TOKEN]
709-
710-
return []
711-
712631
def validate_readthedocs(self, repo):
713632
if not (repo["owner"]["login"] == "adafruit" and
714633
repo["name"].startswith("Adafruit_CircuitPython")):

patches/0001-update-pylintrc-for-black.patch

Lines changed: 0 additions & 25 deletions
This file was deleted.

patches/0002-update-example-file-pylint.patch

Lines changed: 0 additions & 25 deletions
This file was deleted.

patches/0003-update-build.yml-to-pip-install-pylint-black-sphinx.patch

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)