mirror of
https://github.com/vale981/melpazoid
synced 2025-03-06 01:41:38 -05:00
modify output to make errors easier to see
This commit is contained in:
parent
cc4145d26f
commit
8f41b7eb98
2 changed files with 31 additions and 32 deletions
13
melpazoid.el
13
melpazoid.el
|
@ -36,7 +36,7 @@
|
|||
(let ((lexical-binding t)) (byte-compile-file filename)))
|
||||
(with-current-buffer (get-buffer-create "*Compile-Log*")
|
||||
(if (melpazoid--buffer-almost-empty-p)
|
||||
(melpazoid-insert "- No issues! 💯")
|
||||
(melpazoid-insert "- No issues!")
|
||||
(goto-char (point-min)) (forward-line 2)
|
||||
(melpazoid-insert "```")
|
||||
(melpazoid-insert (buffer-substring (point) (point-max)))
|
||||
|
@ -84,7 +84,7 @@
|
|||
(cl-letf (((symbol-function 'message) #'ignore))
|
||||
(ignore-errors (checkdoc-file filename))))
|
||||
(if (not (get-buffer "*Warnings*"))
|
||||
(melpazoid-insert "- No issues! 💯")
|
||||
(melpazoid-insert "- No issues!")
|
||||
(with-current-buffer "*Warnings*"
|
||||
(melpazoid-insert "```")
|
||||
(melpazoid-insert (buffer-substring (point-min) (point-max)))
|
||||
|
@ -106,7 +106,7 @@
|
|||
(with-current-buffer (get-buffer-create "*Package-Lint*")
|
||||
(let ((output (melpazoid--string-trim (buffer-substring (point-min) (point-max)))))
|
||||
(if (string= "No issues found." output)
|
||||
(melpazoid-insert "- No issues! 💯")
|
||||
(melpazoid-insert "- No issues!")
|
||||
(melpazoid-insert "```")
|
||||
(melpazoid-insert output)
|
||||
(melpazoid-insert "```")
|
||||
|
@ -129,7 +129,7 @@ a Docker container, e.g. kellyk/emacs does not include the .el files."
|
|||
(check-declare-file (buffer-file-name (current-buffer)))
|
||||
(with-current-buffer (get-buffer-create "*Check Declarations Warnings*")
|
||||
(if (melpazoid--buffer-almost-empty-p)
|
||||
(melpazoid-insert "- No issues! 💯")
|
||||
(melpazoid-insert "- No issues!")
|
||||
(melpazoid-insert "```")
|
||||
(melpazoid-insert (buffer-substring (point-min) (point-max)))
|
||||
(melpazoid-insert "```")
|
||||
|
@ -245,7 +245,7 @@ OBJECTS are objects to interpolate into the string using `format'."
|
|||
(interactive)
|
||||
(melpazoid--reset-state)
|
||||
(let ((filename (or filename (buffer-file-name (current-buffer)))))
|
||||
(melpazoid-insert "\n### %s\n" (file-name-nondirectory filename))
|
||||
(melpazoid-insert "\n### %s ###\n" (file-name-nondirectory filename))
|
||||
(save-window-excursion
|
||||
(set-buffer (find-file filename))
|
||||
(melpazoid-byte-compile filename)
|
||||
|
@ -274,8 +274,7 @@ OBJECTS are objects to interpolate into the string using `format'."
|
|||
(setq filename (car filenames) filenames (cdr filenames))
|
||||
(and (not (string= (file-name-base filename) "melpazoid"))
|
||||
(string= (file-name-extension filename) "el")
|
||||
(melpazoid filename))))
|
||||
(kill-emacs (if melpazoid-error-p 1 0)))
|
||||
(melpazoid filename)))))
|
||||
|
||||
(provide 'melpazoid)
|
||||
;;; melpazoid.el ends here
|
||||
|
|
50
melpazoid.py
50
melpazoid.py
|
@ -68,30 +68,19 @@ def run_checks(
|
|||
files[ii] = os.path.join('_elisp', os.path.basename(recipe_file))
|
||||
_write_requirements(files, recipe)
|
||||
print('Building container... 🐳')
|
||||
returncode = (
|
||||
subprocess.run(
|
||||
['make', 'test', f"PACKAGE_NAME={_package_name(recipe)}"],
|
||||
stderr=subprocess.PIPE,
|
||||
).returncode
|
||||
| check_license(files, elisp_dir, clone_address)
|
||||
| check_packaging(files, recipe)
|
||||
)
|
||||
output = subprocess.check_output(
|
||||
['make', 'test', f"PACKAGE_NAME={_package_name(recipe)}"]
|
||||
).decode()
|
||||
output = _parse_test_output(output)
|
||||
print(output)
|
||||
returncode = 1 if CLR_WARN in output else 0
|
||||
returncode |= check_license(files, elisp_dir, clone_address)
|
||||
returncode |= check_packaging(files, recipe)
|
||||
print_related_packages(recipe) # could throw ConnectionError
|
||||
print_details(recipe, files, pr_data, clone_address)
|
||||
return returncode
|
||||
|
||||
|
||||
@functools.lru_cache()
|
||||
def _is_checkable_pr(pr_data_title: str) -> bool:
|
||||
"""
|
||||
>>> _is_checkable_pr('Add shx')
|
||||
True
|
||||
>>> _is_checkable_pr('delete shx')
|
||||
False
|
||||
"""
|
||||
return 'delete' not in pr_data_title.lower()
|
||||
|
||||
|
||||
@functools.lru_cache()
|
||||
def _clone_address(pr_text: str) -> str:
|
||||
"""Figure out the clone address."""
|
||||
|
@ -103,6 +92,17 @@ def _clone_address(pr_text: str) -> str:
|
|||
return url
|
||||
|
||||
|
||||
def _parse_test_output(output: str) -> str:
|
||||
# TODO: what does a checkdoc _error_ look like?
|
||||
pattern = r'(.*:[ ]?[Ee]rror: .*)'
|
||||
output_lines = output.split('\n')
|
||||
for ii, output_line in enumerate(output_lines):
|
||||
output_line = re.sub(r'(### .*)', f"{CLR_INFO}\\g<1>{CLR_OFF}", output_line)
|
||||
output_line = re.sub(pattern, f"{CLR_WARN}\\g<1>{CLR_OFF}", output_line)
|
||||
output_lines[ii] = output_line
|
||||
return '\n'.join(output_lines).strip()
|
||||
|
||||
|
||||
def _recipe(pr_data_diff_url: str) -> str:
|
||||
"Download the user's recipe."
|
||||
# TODO: use https://developer.github.com/v3/repos/contents/ instead of 'patch'
|
||||
|
@ -144,7 +144,7 @@ def _clone(repo: str, branch: str, into: str):
|
|||
['git', 'clone', '-b', branch, repo, into], stderr=subprocess.STDOUT
|
||||
)
|
||||
except subprocess.CalledProcessError as err:
|
||||
print(f"WARN: {CLR_WARN}the default branch is not 'master'{CLR_OFF}")
|
||||
print(f"{CLR_WARN}The default branch is not 'master'{CLR_OFF}")
|
||||
if branch == 'master':
|
||||
subprocess.check_output(['git', 'clone', repo, into])
|
||||
return
|
||||
|
@ -318,18 +318,18 @@ def _check_license_github_api(clone_address: str) -> bool:
|
|||
repo_suffix = match.groups()[0].strip('/')
|
||||
license_ = requests.get(f"{GITHUB_API}/{repo_suffix}").json().get('license')
|
||||
if license_ and license_.get('name') in VALID_LICENSES_GITHUB:
|
||||
print(f"- GitHub API found `{license_.get('name')}` 💯")
|
||||
print(f"- GitHub API found `{license_.get('name')}`")
|
||||
return True
|
||||
if license_:
|
||||
print(f"- {CLR_WARN}GitHub API found `{license_.get('name')}`{CLR_OFF}")
|
||||
if license_.get('name') == 'Other':
|
||||
# TODO: this should probably be a failure
|
||||
print(
|
||||
f" - Use a [GitHub-compatible](https://github.com/licensee/licensee) format for your license file{CLR_OFF}"
|
||||
f" - {CLR_WARN}Use a [GitHub-compatible](https://github.com/licensee/licensee) format for your license file{CLR_OFF}"
|
||||
)
|
||||
return False
|
||||
print(
|
||||
'- Add an [automatically detectable](https://github.com/licensee/licensee) LICENSE file to your repository (e.g. no markup)'
|
||||
f"- {CLR_WARN}Add an [automatically detectable](https://github.com/licensee/licensee) LICENSE file to your repository (e.g. no markup){CLR_OFF}"
|
||||
)
|
||||
return False
|
||||
|
||||
|
@ -353,10 +353,10 @@ def _check_license_in_files(elisp_files: list):
|
|||
for elisp_file in elisp_files:
|
||||
license_ = _check_license_in_file(elisp_file)
|
||||
if not license_:
|
||||
print(f"- {CLR_ULINE}{elisp_file}{CLR_OFF} has no detectable license text")
|
||||
print(f"- {CLR_WARN}{elisp_file} has no detectable license text{CLR_OFF}")
|
||||
individual_files_licensed = False
|
||||
else:
|
||||
print(f"- {os.path.basename(elisp_file)} has {license_} license text 💯")
|
||||
print(f"- {os.path.basename(elisp_file)} has {license_} license text")
|
||||
return individual_files_licensed
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue