improve usage documentation, travis output

This commit is contained in:
riscy 2020-02-22 17:18:00 -08:00
parent bc263924f3
commit 8f3c772845
3 changed files with 64 additions and 35 deletions

View file

@ -1,17 +1,19 @@
os: linux
language: python
python:
- "3.6"
# Test a recipe before you even open a MELPA pull request:
# env: >-
# CLONE_URL='https://github.com/riscy/shx-for-emacs'
# RECIPE='(shx :repo "riscy/shx-for-emacs" :fetcher github)'
# If you already have a pull request open, specify as below:
env: >-
CLONE_URL='https://github.com/riscy/shx-for-emacs'
RECIPE='(shx :repo "riscy/shx-for-emacs" :fetcher github)'
MELPA_PR_URL=https://github.com/melpa/melpa/pull/6713
install:
- pip install requests
- pytest --doctest-modules
script:
- pytest --doctest-modules
- python melpazoid.py

View file

@ -6,11 +6,51 @@
[[https://travis-ci.org/riscy/shx-for-emacs][https://travis-ci.org/riscy/melpazoid.svg?branch=master]]
/melpazoid/ is a bundle of scripts for testing Emacs packages, primarily
submissions to [[https://github.com/melpa/][MELPA]]. The ambition is to have checks that run in an "clean"
submissions to [[https://github.com/melpa/][MELPA]]. I've been using a variation of this script to help me
check MELPA [[https://github.com/melpa/melpa/pulls][pull requests]]. The ambition is CI checks that run in an "clean"
environment, either through CI or through a container on your local machine.
This is a work in progress -- feedback and pull requests are welcome (note my
current aim is to make this code simpler before I make it any more complicated).
The checks are a combination of:
1. byte-compile-file
2. [[https://www.emacswiki.org/emacs/CheckDoc][checkdoc]]
3. [[https://github.com/purcell/package-lint][package-lint]]
4. a license checker
5. some elisp checks
The first four are on the MELPA checklist, so you should try to get those right.
The license checker is currently very crude. The elisp checks are not foolproof,
sometimes opinionated, and may raise false positives.
* How to use melpazoid
** Locally
You can fork it and let CI do the work, or use it locally.
** Fork it and let CI do the work
If you don't want to install this software or its dependencies, you are
encouraged to fork this repository and let CI do the work. You will need a
bit of experience with GitHub.
Then enable [[https://travis-ci.org][Travis-CI]] on your fork, or just open a pull request against this
repository (I won't merge it). The eventual build information will report any
issues.
Your fork will need to point to the Emacs package you want to build, which
can be done by modifying the ~.travis.yml~ file in one of the following ways.
*** Test a recipe before you even open a pull request to MELPA
Modify the ~env~ field and specify your clone url and your recipe:
#+begin_src yaml
env: >-
CLONE_URL='https://github.com/me/my-package-repo
RECIPE='(my-package :repo "me/my-package-repo" :fetcher github)'
#+end_src
*** Test a MELPA pull request you've already opened
Modify the ~env~ field and specify your open MELPA PR:
#+begin_src yaml
env: >-
MELPA_PR_URL='https://github.com/melpa/melpa/pulls/6713
#+end_src
** Use it locally
You will need Python ≥ 3.6 (and the ~requests~ package) and Docker. A
container will be built with (hopefully) all of your requirements installed.
The output scroll will report any discovered issues.
@ -31,15 +71,3 @@ environment, either through CI or through a container on your local machine.
PKG_NAME='package-name' \
make
#+end_src
** Use Travis
You can still use this software if you don't want to install it or its
dependencies. Fork this repository and open a PR against it that modifies the
~.travis.yml~ file with your CLONE_URL and RECIPE, for example:
#+begin_src yaml
env: >-
CLONE_URL='https://github.com/me/my-package-repo
RECIPE='(my-package :repo "me/my-package-repo" :fetcher github)'
#+end_src
The build information on your pull request will report any discovered issues.

View file

@ -72,10 +72,9 @@ def run_checks(
)
print(output.decode().strip())
check_license(files, elisp_dir, clone_address)
check_maintainer(pr_data, clone_address)
check_packaging(files, recipe)
print_related_packages(recipe) # could throw ConnectionError
print_details(recipe, files)
print_details(recipe, files, pr_data, clone_address)
@functools.lru_cache()
@ -282,17 +281,6 @@ def _requirements(
return {req.split('"')[0].strip() for req in reqs}
def check_maintainer(pr_data: str = None, clone_address: str = None):
if pr_data and clone_address:
print('\nMaintainer:')
# Check the maintainer
print(f"- PR by {pr_data['user']['login']}: {clone_address}")
if pr_data['user']['login'].lower() not in clone_address.lower():
print(f" - {CLR_TIP}NOTE: Repo and recipe owner don't match{CLR_OFF}")
if int(pr_data['changed_files']) != 1:
print(f" - {CLR_WARN}PR changes {pr_data['changed_files']} files{CLR_OFF}")
def check_license(recipe_files: list, elisp_dir: str, clone_address: str = None):
print('\nLicense:')
repo_licensed = False
@ -403,9 +391,13 @@ def check_packaging(recipe_files: list, recipe: str):
print(f"- {CLR_WARN}Package-Requires mismatch in {el}!{CLR_OFF}")
def print_details(recipe: str, recipe_files: list):
print('\nSummary:')
print(f"- {CLR_TIP if ':files' in recipe else ''}{recipe}{CLR_OFF}")
def print_details(
recipe: str, recipe_files: list, pr_data: dict = None, clone_address: str = None
):
print('\nDetails:')
print(f"- `{recipe}`")
if ':files' in recipe:
print(' - Try to simply use the default recipe, if possible')
print('- Package-Requires: ', end='')
if _requirements(recipe_files):
print(', '.join(req for req in _requirements(recipe_files, with_versions=True)))
@ -426,6 +418,13 @@ def print_details(recipe: str, recipe_files: list):
f" ({_check_license_in_file(recipe_file) or 'unknown license'})"
+ (f": {header}" if header else "")
)
if pr_data and clone_address:
# Check the maintainer
print(f"- PR by {pr_data['user']['login']}: {clone_address}")
if pr_data['user']['login'].lower() not in clone_address.lower():
print(f" - {CLR_TIP}NOTE: Repo and recipe owner don't match{CLR_OFF}")
if int(pr_data['changed_files']) != 1:
print(f" - {CLR_WARN}PR changes {pr_data['changed_files']} files{CLR_OFF}")
def print_related_packages(recipe: str):