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)))
|
(let ((lexical-binding t)) (byte-compile-file filename)))
|
||||||
(with-current-buffer (get-buffer-create "*Compile-Log*")
|
(with-current-buffer (get-buffer-create "*Compile-Log*")
|
||||||
(if (melpazoid--buffer-almost-empty-p)
|
(if (melpazoid--buffer-almost-empty-p)
|
||||||
(melpazoid-insert "- No issues! 💯")
|
(melpazoid-insert "- No issues!")
|
||||||
(goto-char (point-min)) (forward-line 2)
|
(goto-char (point-min)) (forward-line 2)
|
||||||
(melpazoid-insert "```")
|
(melpazoid-insert "```")
|
||||||
(melpazoid-insert (buffer-substring (point) (point-max)))
|
(melpazoid-insert (buffer-substring (point) (point-max)))
|
||||||
|
@ -84,7 +84,7 @@
|
||||||
(cl-letf (((symbol-function 'message) #'ignore))
|
(cl-letf (((symbol-function 'message) #'ignore))
|
||||||
(ignore-errors (checkdoc-file filename))))
|
(ignore-errors (checkdoc-file filename))))
|
||||||
(if (not (get-buffer "*Warnings*"))
|
(if (not (get-buffer "*Warnings*"))
|
||||||
(melpazoid-insert "- No issues! 💯")
|
(melpazoid-insert "- No issues!")
|
||||||
(with-current-buffer "*Warnings*"
|
(with-current-buffer "*Warnings*"
|
||||||
(melpazoid-insert "```")
|
(melpazoid-insert "```")
|
||||||
(melpazoid-insert (buffer-substring (point-min) (point-max)))
|
(melpazoid-insert (buffer-substring (point-min) (point-max)))
|
||||||
|
@ -106,7 +106,7 @@
|
||||||
(with-current-buffer (get-buffer-create "*Package-Lint*")
|
(with-current-buffer (get-buffer-create "*Package-Lint*")
|
||||||
(let ((output (melpazoid--string-trim (buffer-substring (point-min) (point-max)))))
|
(let ((output (melpazoid--string-trim (buffer-substring (point-min) (point-max)))))
|
||||||
(if (string= "No issues found." output)
|
(if (string= "No issues found." output)
|
||||||
(melpazoid-insert "- No issues! 💯")
|
(melpazoid-insert "- No issues!")
|
||||||
(melpazoid-insert "```")
|
(melpazoid-insert "```")
|
||||||
(melpazoid-insert output)
|
(melpazoid-insert output)
|
||||||
(melpazoid-insert "```")
|
(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)))
|
(check-declare-file (buffer-file-name (current-buffer)))
|
||||||
(with-current-buffer (get-buffer-create "*Check Declarations Warnings*")
|
(with-current-buffer (get-buffer-create "*Check Declarations Warnings*")
|
||||||
(if (melpazoid--buffer-almost-empty-p)
|
(if (melpazoid--buffer-almost-empty-p)
|
||||||
(melpazoid-insert "- No issues! 💯")
|
(melpazoid-insert "- No issues!")
|
||||||
(melpazoid-insert "```")
|
(melpazoid-insert "```")
|
||||||
(melpazoid-insert (buffer-substring (point-min) (point-max)))
|
(melpazoid-insert (buffer-substring (point-min) (point-max)))
|
||||||
(melpazoid-insert "```")
|
(melpazoid-insert "```")
|
||||||
|
@ -245,7 +245,7 @@ OBJECTS are objects to interpolate into the string using `format'."
|
||||||
(interactive)
|
(interactive)
|
||||||
(melpazoid--reset-state)
|
(melpazoid--reset-state)
|
||||||
(let ((filename (or filename (buffer-file-name (current-buffer)))))
|
(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
|
(save-window-excursion
|
||||||
(set-buffer (find-file filename))
|
(set-buffer (find-file filename))
|
||||||
(melpazoid-byte-compile 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))
|
(setq filename (car filenames) filenames (cdr filenames))
|
||||||
(and (not (string= (file-name-base filename) "melpazoid"))
|
(and (not (string= (file-name-base filename) "melpazoid"))
|
||||||
(string= (file-name-extension filename) "el")
|
(string= (file-name-extension filename) "el")
|
||||||
(melpazoid filename))))
|
(melpazoid filename)))))
|
||||||
(kill-emacs (if melpazoid-error-p 1 0)))
|
|
||||||
|
|
||||||
(provide 'melpazoid)
|
(provide 'melpazoid)
|
||||||
;;; melpazoid.el ends here
|
;;; 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))
|
files[ii] = os.path.join('_elisp', os.path.basename(recipe_file))
|
||||||
_write_requirements(files, recipe)
|
_write_requirements(files, recipe)
|
||||||
print('Building container... 🐳')
|
print('Building container... 🐳')
|
||||||
returncode = (
|
output = subprocess.check_output(
|
||||||
subprocess.run(
|
['make', 'test', f"PACKAGE_NAME={_package_name(recipe)}"]
|
||||||
['make', 'test', f"PACKAGE_NAME={_package_name(recipe)}"],
|
).decode()
|
||||||
stderr=subprocess.PIPE,
|
output = _parse_test_output(output)
|
||||||
).returncode
|
print(output)
|
||||||
| check_license(files, elisp_dir, clone_address)
|
returncode = 1 if CLR_WARN in output else 0
|
||||||
| check_packaging(files, recipe)
|
returncode |= check_license(files, elisp_dir, clone_address)
|
||||||
)
|
returncode |= check_packaging(files, recipe)
|
||||||
print_related_packages(recipe) # could throw ConnectionError
|
print_related_packages(recipe) # could throw ConnectionError
|
||||||
print_details(recipe, files, pr_data, clone_address)
|
print_details(recipe, files, pr_data, clone_address)
|
||||||
return returncode
|
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()
|
@functools.lru_cache()
|
||||||
def _clone_address(pr_text: str) -> str:
|
def _clone_address(pr_text: str) -> str:
|
||||||
"""Figure out the clone address."""
|
"""Figure out the clone address."""
|
||||||
|
@ -103,6 +92,17 @@ def _clone_address(pr_text: str) -> str:
|
||||||
return url
|
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:
|
def _recipe(pr_data_diff_url: str) -> str:
|
||||||
"Download the user's recipe."
|
"Download the user's recipe."
|
||||||
# TODO: use https://developer.github.com/v3/repos/contents/ instead of 'patch'
|
# 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
|
['git', 'clone', '-b', branch, repo, into], stderr=subprocess.STDOUT
|
||||||
)
|
)
|
||||||
except subprocess.CalledProcessError as err:
|
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':
|
if branch == 'master':
|
||||||
subprocess.check_output(['git', 'clone', repo, into])
|
subprocess.check_output(['git', 'clone', repo, into])
|
||||||
return
|
return
|
||||||
|
@ -318,18 +318,18 @@ def _check_license_github_api(clone_address: str) -> bool:
|
||||||
repo_suffix = match.groups()[0].strip('/')
|
repo_suffix = match.groups()[0].strip('/')
|
||||||
license_ = requests.get(f"{GITHUB_API}/{repo_suffix}").json().get('license')
|
license_ = requests.get(f"{GITHUB_API}/{repo_suffix}").json().get('license')
|
||||||
if license_ and license_.get('name') in VALID_LICENSES_GITHUB:
|
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
|
return True
|
||||||
if license_:
|
if license_:
|
||||||
print(f"- {CLR_WARN}GitHub API found `{license_.get('name')}`{CLR_OFF}")
|
print(f"- {CLR_WARN}GitHub API found `{license_.get('name')}`{CLR_OFF}")
|
||||||
if license_.get('name') == 'Other':
|
if license_.get('name') == 'Other':
|
||||||
# TODO: this should probably be a failure
|
# TODO: this should probably be a failure
|
||||||
print(
|
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
|
return False
|
||||||
print(
|
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
|
return False
|
||||||
|
|
||||||
|
@ -353,10 +353,10 @@ def _check_license_in_files(elisp_files: list):
|
||||||
for elisp_file in elisp_files:
|
for elisp_file in elisp_files:
|
||||||
license_ = _check_license_in_file(elisp_file)
|
license_ = _check_license_in_file(elisp_file)
|
||||||
if not license_:
|
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
|
individual_files_licensed = False
|
||||||
else:
|
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
|
return individual_files_licensed
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue