From 0134e1d1e3bd6d2bab92753a3aad585798fea337 Mon Sep 17 00:00:00 2001 From: Freezed <2160318-free_zed@users.noreply.gitlab.com> Date: Sun, 20 Mar 2022 01:27:46 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Integrate=20`strava-cli`=20&=20add?= =?UTF-8?q?=20devel=20tools?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A copy of CLI launcher from `strava-cli` is made to permit commands addition on top of `strava-cli` All Python tooling is added too. Squashed commit, fix jobs: - https://lab.frogg.it/fcode/geostrapy/-/jobs/30004 - https://lab.frogg.it/fcode/geostrapy/-/jobs/30005 --- .gitlab-ci.yml | 25 +++++++++++++++++++++++++ Makefile | 27 +++++++++++++++++++++++++++ README.md | 37 +++++++++++++++++++++++++++++++++++-- cli/run.py | 32 ++++++++++++++++++++++++++++++++ requirements-dev.txt | 3 +++ requirements.txt | 2 ++ setup.cfg | 6 ++++++ 7 files changed, 130 insertions(+), 2 deletions(-) create mode 100644 .gitlab-ci.yml create mode 100644 Makefile create mode 100644 cli/run.py create mode 100644 requirements-dev.txt create mode 100644 requirements.txt create mode 100644 setup.cfg diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..6369b83 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,25 @@ +stages: + - lint + +variables: + PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" + +cache: + paths: + - .cache/pip + - /var/venv/ + +lint: + image: python:3.9-slim + stage: lint + except: + - /^wip-.*$/ + - /^old-.*$/ + script: + - python -V + - apt-get update -qq && apt-get -qq -y install make python3-venv + - python3 -m venv /var/venv/ + - source /var/venv/bin/activate + - pip install -r requirements.txt + - pip install -r requirements-dev.txt + - make --no-print-directory lint diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7ee58e5 --- /dev/null +++ b/Makefile @@ -0,0 +1,27 @@ +EDITOR = geany + +help: # Print help on Makefile + @grep '^[^.#]\+:\s\+.*#' Makefile | \ + sed "s/\(.\+\):\s*\(.*\) #\s*\(.*\)/`printf "\033[93m"`\1`printf "\033[0m"` \3/" | \ + expand -t20 + +open_all: # Open all projects files + ${EDITOR} ${VIRTUAL_ENV}/bin/activate + ${EDITOR} .gitignore .gitlab-ci.yml Makefile README.md requirements.txt requirements-dev.txt setup.cfg + ${EDITOR} .git/hooks/p*-commit + ${EDITOR} cli/run.py + +pre_commit: # Run the pre-commit hook + .git/hooks/pre-commit + +clean: # Remove files not tracked in source control + rm -rf htmlcov .pytest_cache + find . -type f -name "*.orig" -delete + find . -type f -name "*.pyc" -delete + find . -type d -name "__pycache__" -delete + find . -type d -empty -delete + +lint: # Lint code + ${VIRTUAL_ENV}/bin/black --check --quiet cli/*.py + ${VIRTUAL_ENV}/bin/flake8 --config=setup.cfg + ${VIRTUAL_ENV}/bin/pylint --rcfile=setup.cfg cli/*.py diff --git a/README.md b/README.md index 3db48ad..bd2d6dc 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ A python CLI to share data related to physical activities over an API (geo-local 1. Use services like [Strava](https://www.strava.com) to follow my physical activities (any other service is welcome) 1. Keep control over the data I share: just what I need ([_proportionality & relevance_](https://www.cnil.fr/fr/cnil-direct/question/quels-sont-les-grands-principes-des-regles-de-protection-des-donnees)) -1. Respect python guidelines proposed by _Vincent Bernat_ ( [🇫🇷](https://vincent.bernat.ch/fr/blog/2019-script-python-durable) | [🇬🇧](https://vincent.bernat.ch/en/blog/2019-sustainable-python-script) ). +1. Respect python scripting guidelines proposed by _Vincent Bernat_ ( [🇫🇷](https://vincent.bernat.ch/fr/blog/2019-script-python-durable) | [🇬🇧](https://vincent.bernat.ch/en/blog/2019-sustainable-python-script) ). ✨ (planed) Features @@ -24,10 +24,43 @@ These are imagined with _[Strava](https://developers.strava.com/docs/reference/) * [crop start, end & stop points](https://lab.frogg.it/fcode/geostrapy/-/issues/4) * [change start-time](https://lab.frogg.it/fcode/geostrapy/-/issues/5) * [Post GPX file as activity](https://lab.frogg.it/fcode/geostrapy/-/issues/6) -* [Process GPX multi-track file](7) +* [Process GPX multi-track file](https://lab.frogg.it/fcode/geostrapy/-/issues/7) * and [maybe more](https://lab.frogg.it/fcode/geostrapy/-/boards)… +🚀 Quickstart +------------- + +```bash +git clone git@lab.frogg.it:fcode/geostrapy.git && cd geostrapy +/<path>/<to>/python3.9 -m venv ~/.venvs/geostrapy +source ~/.venvs/geostrapy/bin/activate +pip install -r requirements.txt +python cli/run.py --help +``` + + +🚧 Development +-------------- + +- [Topic branches](https://git-scm.com/book/en/v2/Git-Branching-Branching-Workflows#_topic_branch) are used and named after issue's slug +- Built with `Python 3.9` +- Code linting with [`flake8`](https://pypi.org/project/flake8/), [`pylint`](https://pypi.org/project/pylint) & [`black`](https://pypi.org/project/black) +- Install development tools: + * `pip install -r requirements-dev.txt` +- A `Makefile` with tools : run `make help` to have a look +- Use the `pre-commit` git hook, [CI will run it](.gitlab-ci.yaml) + * `echo "make --no-print-directory lint" > .git/hooks/pre-commit` + * `chmod u+x .git/hooks/pre-commit` + + +### 📌 Dependences + +Details in [`requirements.txt`](requirements.txt) & [`requirements-dev.txt`](requirements-dev.txt) + +- [`strava-cli`](https://github.com/bwilczynski/strava-cli) + + ### 🤠Contributing - Roadmap âž¡ï¸ [_project kanban_](https://lab.frogg.it/fcode/geostrapy/-/boards) diff --git a/cli/run.py b/cli/run.py new file mode 100644 index 0000000..60778ff --- /dev/null +++ b/cli/run.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 +# coding:utf-8 +""" +run.py: CLI launcher, just run it + +Add `geostrapy` commands to `strava-cli` +""" + + +import click + +from strava.commands import ( + login, + logout, + set_config, +) + + +@click.group() +def cli(): + """ + Share data related to physical activities over an API (geo-localized or not) + Add commands for `strava-cli` https://github.com/bwilczynski/strava-cli + """ + + +cli.add_command(login) +cli.add_command(logout) +cli.add_command(set_config) + +if __name__ == "__main__": + cli() diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..a6d00fa --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,3 @@ +black +flake8 +pylint diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..19d8a2a --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +click==8.0.4 +strava-cli==0.6.1 diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..6abd811 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,6 @@ +[flake8] +max-line-length = 90 + +[pylint] +output-format = colorized +score = n -- GitLab