diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..6369b832eed1dc40ea6f25a43a0ad482ea3b7b64 --- /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 0000000000000000000000000000000000000000..7ee58e582b68323035707fa6c46fd61118ce71d2 --- /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 3db48adc361d0c354ee5e2ad1738fc41a7df96df..bd2d6dc4f9574f0dda5ebc57e240f479091a85af 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 0000000000000000000000000000000000000000..60778ff3500aa5c7aae40fca36c6419d52339c8b --- /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 0000000000000000000000000000000000000000..a6d00faae063ae2e7bff4ad6903540aa844bb791 --- /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 0000000000000000000000000000000000000000..19d8a2af3fc9092fb02c98691192ba55638d15b5 --- /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 0000000000000000000000000000000000000000..6abd81160309f014cedac2ea7a2cd9a36906ddcc --- /dev/null +++ b/setup.cfg @@ -0,0 +1,6 @@ +[flake8] +max-line-length = 90 + +[pylint] +output-format = colorized +score = n