From ce891478dbb34c01f9e56abdc136b8bce87cb217 Mon Sep 17 00:00:00 2001 From: J-E Castagnede Date: Wed, 25 Jan 2023 15:24:01 +0100 Subject: [PATCH 01/20] add separate dev tools in specific dependency file --- .github/workflows/lint.yml | 12 ++++++------ Dockerfile | 4 +++- requirements-dev.in | 2 ++ requirements-dev.txt | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 7 deletions(-) create mode 100644 requirements-dev.in create mode 100644 requirements-dev.txt diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 3bb77c4751..cfa74fcb3e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -12,6 +12,10 @@ jobs: runs-on: ubuntu-18.04 steps: + - name: Not evaluated values in migration files + run: | + test $(ls geotrek/*/migrations/*.py | xargs grep -l srid | xargs grep -L SRID | wc -l) -eq 0 + - uses: actions/checkout@v2 - name: Set up Python 3.8 uses: actions/setup-python@v4 @@ -20,13 +24,9 @@ jobs: - name: Install dependencies run: | - pip3 install --upgrade pip - pip3 install flake8 + pip3 install --upgrade pip wheel setuptools + pip3 install -r requirements-dev.txt -U - name: Flake8 run: | flake8 geotrek - - - name: Not evaluated values in migration files - run: | - test $(ls geotrek/*/migrations/*.py | xargs grep -l srid | xargs grep -L SRID | wc -l) -eq 0 diff --git a/Dockerfile b/Dockerfile index 66c371f176..e436464075 100644 --- a/Dockerfile +++ b/Dockerfile @@ -42,10 +42,12 @@ RUN apt-get update -qq && apt-get install -y -qq \ apt-get install -y --no-install-recommends postgis && \ apt-get clean all && rm -rf /var/lib/apt/lists/* && rm -rf /var/cache/apt/* -COPY requirements.txt requirements.txt RUN python3 -m venv /opt/venv RUN /opt/venv/bin/pip install -U pip setuptools wheel +COPY requirements.txt requirements.txt RUN /opt/venv/bin/pip install --no-cache-dir -r requirements.txt -U +COPY requirements-dev.txt requirements-dev.txt +RUN /opt/venv/bin/pip install --no-cache-dir -r requirements-dev.txt -U COPY geotrek/ geotrek/ COPY manage.py manage.py diff --git a/requirements-dev.in b/requirements-dev.in new file mode 100644 index 0000000000..29685ec870 --- /dev/null +++ b/requirements-dev.in @@ -0,0 +1,2 @@ +pip-tools +flake8 \ No newline at end of file diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000000..5b74600078 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,32 @@ +# +# This file is autogenerated by pip-compile with Python 3.8 +# by the following command: +# +# pip-compile requirements-dev.in +# +build==0.10.0 + # via pip-tools +click==8.1.3 + # via pip-tools +flake8==6.0.0 + # via -r requirements-dev.in +mccabe==0.7.0 + # via flake8 +packaging==23.0 + # via build +pip-tools==6.12.1 + # via -r requirements-dev.in +pycodestyle==2.10.0 + # via flake8 +pyflakes==3.0.1 + # via flake8 +pyproject-hooks==1.0.0 + # via build +tomli==2.0.1 + # via build +wheel==0.38.4 + # via pip-tools + +# The following packages are considered to be unsafe in a requirements file: +# pip +# setuptools From 0bc87cee1597961435e5ed10f5bbe25737f0cff9 Mon Sep 17 00:00:00 2001 From: J-E Castagnede Date: Wed, 25 Jan 2023 15:24:24 +0100 Subject: [PATCH 02/20] add pre-commit hook and improve doc --- .githooks/pre-commit | 17 ++++++++++++++ docs/contribute/development.rst | 39 ++++++++++++++++++++++++--------- 2 files changed, 46 insertions(+), 10 deletions(-) create mode 100755 .githooks/pre-commit diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 0000000000..9779c2a9c6 --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,17 @@ +#!/bin/bash + +if ! command -v docker-compose &> /dev/null +then + echo "toto"; + alias docker-compose="docker compose" +fi + +echo "run Flake8" + +docker-compose run -T --rm web flake8 geotrek +status=$? + +if test $status -eq 1 +then + exit $status +fi diff --git a/docs/contribute/development.rst b/docs/contribute/development.rst index 5df9df6d1b..b523940744 100644 --- a/docs/contribute/development.rst +++ b/docs/contribute/development.rst @@ -36,20 +36,26 @@ Conventions * Use flake8 * KISS & DRY as much as possible * Elegant and generic is good, simple is better +* Before contributing, open an issue and discuss about it with community (is it a bug or a feature ? What is the best way to achieve my goal ?) +* Separate bug fixes and new features in several pull requests. +* Open a new Pull Request in "Draft" status until tests passed. Use at least 'bug', 'improvement' or 'feature' label. * Commits messages are explicit and mention issue number (``(ref #12)`` or ``(fixes #23)``) -* Features are developed in a branch and merged from Github pull-requests. A git hook to is available to prevent pushing to master, to enable it, developpers should run the following command from root directory (`Geotrek-admin/`) : `ln -s -f ../../.githooks/pre-push .git/hooks/pre-push` +* Features are developed in a branch and merged from Github pull-requests. +* Several git hooks are available. Install them with following commands: + * pre-push: `ln -s -f ../../.githooks/pre-push .git/hooks/pre-push` + * pre-commit: `ln -s -f ../../.githooks/pre-commit .git/hooks/pre-commit` Definition of done ------------------ * ``docs/changelog.rst`` is up-to-date -* A unit-test covers the bugfix or the new feature +* An explicit unit-test covers the bugfix or the new feature. * A frontend test (:path:jstests/nav-\*.js) covers the navigation bug fix or feature * A JS *Mocha* test (:path:jstests/tests.\*.js) covers the JavaScript bug fix or feature -* Unit-tests coverage is above or at least equal with previous commits -* Settings have default value in ``settings/base.py`` or ``conf/settings-default.ini`` -* Installation instructions are up-to-date +* Unit-tests total coverage is above or at least equal with previous commits. Patch coverage is 100% on new lines. +* Settings have default value in ``settings/base.py`` +* Installation instructions and documentation are up-to-date Check TODO in the source tree: @@ -76,16 +82,29 @@ On master branch: * When creating a new release 'x.y.z' on github, Github actions will generate the .deb package file, and publish it on https://packages.geotrek.fr (see ``.circleci/config.yml`` file for details) -Developement -============ +Development +=========== + +Adding or upgrade dependencies +------------------------------ + +Consider using pip-tools to manage dependencies. + +* add your dependency in setup.py for general dependency, requirements-dev.in for dev dependency, then run : + +:: + + docker-compose run --rm web pip-compile + docker-compose run --rm web pip-compile requirements-dev.in + Model modification ------------------ :: - docker-compose run web ./manage.py makemigrations - docker-compose run web ./manage.py migrate + docker-compose run --rm web ./manage.py makemigrations + docker-compose run --rm web ./manage.py migrate .. note :: @@ -236,7 +255,7 @@ Data only: :: - docker-compose run web ./manage.py flush + docker-compose run --rm web ./manage.py flush Restore existing Database ------------------------- From b638b30533683865b9501c6375bc8d665ff7098c Mon Sep 17 00:00:00 2001 From: J-E Castagnede Date: Wed, 25 Jan 2023 15:26:20 +0100 Subject: [PATCH 03/20] fix lint workflow --- .github/workflows/lint.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index cfa74fcb3e..42066f44d8 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -12,11 +12,13 @@ jobs: runs-on: ubuntu-18.04 steps: + - uses: actions/checkout@v3 + - name: Not evaluated values in migration files run: | test $(ls geotrek/*/migrations/*.py | xargs grep -l srid | xargs grep -L SRID | wc -l) -eq 0 - - uses: actions/checkout@v2 + - name: Set up Python 3.8 uses: actions/setup-python@v4 with: From bbe5f5162680285ff699fcadd06a06a7df224fba Mon Sep 17 00:00:00 2001 From: J-E Castagnede Date: Wed, 25 Jan 2023 15:35:14 +0100 Subject: [PATCH 04/20] improve pre-commit --- .githooks/pre-commit | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.githooks/pre-commit b/.githooks/pre-commit index 9779c2a9c6..e64e1b764f 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -1,17 +1,19 @@ #!/bin/bash -if ! command -v docker-compose &> /dev/null -then - echo "toto"; - alias docker-compose="docker compose" -fi +function dockercompose { + # use docker-compose then fallback to new docker compose + docker-compose "$@" + docker compose "$@" +} -echo "run Flake8" +echo "run Flake8..." -docker-compose run -T --rm web flake8 geotrek +dockercompose run -T --rm web flake8 geotrek status=$? if test $status -eq 1 then exit $status +else + echo "Flake8 check is ok..." fi From 7ebfdfd74ed4c7ad0aadd50f74c58b3d27d9b181 Mon Sep 17 00:00:00 2001 From: J-E Castagnede Date: Wed, 25 Jan 2023 16:25:59 +0100 Subject: [PATCH 05/20] better split dev dependencies --- .github/workflows/test.yml | 2 ++ requirements-dev.in | 9 +++++- requirements-dev.txt | 56 +++++++++++++++++++++++++++++++++++--- requirements.txt | 23 +--------------- setup.py | 7 ----- 5 files changed, 63 insertions(+), 34 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 67a0cf1fc3..12416f4717 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -120,7 +120,9 @@ jobs: run: | python3 -m pip install --upgrade pip setuptools wheel pip3 wheel --wheel-dir=~/.wheel_dir -r requirements.txt + pip3 wheel --wheel-dir=~/.wheel_dir -r requirements-dev.txt pip3 install --find-links=~/.wheel_dir -r requirements.txt + pip3 install --find-links=~/.wheel_dir -r requirements-dev.txt - name: Create test required directories run: | diff --git a/requirements-dev.in b/requirements-dev.in index 29685ec870..7b8fc7ddc4 100644 --- a/requirements-dev.in +++ b/requirements-dev.in @@ -1,2 +1,9 @@ +-c requirements.txt + pip-tools -flake8 \ No newline at end of file +flake8 +freezegun +coverage +factory_boy +django-extensions +django-debug-toolbar \ No newline at end of file diff --git a/requirements-dev.txt b/requirements-dev.txt index 5b74600078..7e3b1e21c3 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -4,26 +4,74 @@ # # pip-compile requirements-dev.in # +asgiref==3.4.1 + # via + # -c requirements.txt + # django build==0.10.0 # via pip-tools click==8.1.3 - # via pip-tools + # via + # -c requirements.txt + # pip-tools +coverage==7.1.0 + # via -r requirements-dev.in +django==3.2.16 + # via + # -c requirements.txt + # django-debug-toolbar + # django-extensions +django-debug-toolbar==3.8.1 + # via -r requirements-dev.in +django-extensions==3.2.1 + # via -r requirements-dev.in +factory-boy==3.2.1 + # via -r requirements-dev.in +faker==16.6.1 + # via factory-boy flake8==6.0.0 # via -r requirements-dev.in +freezegun==1.2.2 + # via -r requirements-dev.in mccabe==0.7.0 # via flake8 -packaging==23.0 - # via build +packaging==21.3 + # via + # -c requirements.txt + # build pip-tools==6.12.1 # via -r requirements-dev.in pycodestyle==2.10.0 # via flake8 pyflakes==3.0.1 # via flake8 +pyparsing==3.0.8 + # via + # -c requirements.txt + # packaging pyproject-hooks==1.0.0 # via build +python-dateutil==2.8.2 + # via + # faker + # freezegun +pytz==2022.1 + # via + # -c requirements.txt + # django +six==1.16.0 + # via + # -c requirements.txt + # python-dateutil +sqlparse==0.4.2 + # via + # -c requirements.txt + # django + # django-debug-toolbar tomli==2.0.1 - # via build + # via + # build + # pyproject-hooks wheel==0.38.4 # via pip-tools diff --git a/requirements.txt b/requirements.txt index 559edd4a18..1239fb8f77 100644 --- a/requirements.txt +++ b/requirements.txt @@ -70,8 +70,6 @@ coreschema==0.0.4 # via # coreapi # drf-yasg -coverage==6.5.0 - # via geotrek (setup.py) cssselect2==0.7.0 # via # cairosvg @@ -87,9 +85,7 @@ django==3.2.16 # django-appconf # django-appypod # django-clearcache - # django-debug-toolbar # django-embed-video - # django-extensions # django-filter # django-js-asset # django-leaflet @@ -115,16 +111,12 @@ django-compressor==3.1 # via mapentity django-crispy-forms==1.13.0 # via mapentity -django-debug-toolbar==3.8.1 - # via geotrek (setup.py) django-embed-video==1.4.8 # via # mapentity # paperclip django-extended-choices==1.3.3 # via geotrek (setup.py) -django-extensions==3.2.1 - # via geotrek (setup.py) django-filter==22.1 # via mapentity django-js-asset==2.0.0 @@ -168,16 +160,10 @@ easy-thumbnails==2.7 # paperclip env-file==2020.12.3 # via geotrek (setup.py) -factory-boy==3.2.1 - # via geotrek (setup.py) -faker==13.3.4 - # via factory-boy fiona==1.8.21 # via # geotrek (setup.py) # mapentity -freezegun==1.2.2 - # via geotrek (setup.py) geojson==2.5.0 # via # geotrek (setup.py) @@ -256,10 +242,6 @@ pypdf2==1.27.5 # via pdfimpose pyphen==0.11.0 # via weasyprint -python-dateutil==2.8.2 - # via - # faker - # freezegun pytz==2022.1 # via # celery @@ -297,14 +279,11 @@ six==1.16.0 # html5lib # munch # pymemcache - # python-dateutil # zodb soupsieve==2.3.2 # via beautifulsoup4 sqlparse==0.4.2 - # via - # django - # django-debug-toolbar + # via django tif2geojson==0.1.3 # via geotrek (setup.py) tinycss2==1.2.1 diff --git a/setup.py b/setup.py index b54570add5..9fc1165a5e 100644 --- a/setup.py +++ b/setup.py @@ -67,13 +67,6 @@ def run(self): # prod, 'gunicorn', 'sentry-sdk', - # tests - 'freezegun', - 'coverage', - 'factory_boy', - # dev, - 'django-extensions', - 'django-debug-toolbar', ], cmdclass={"build": BuildCommand}, include_package_data=True, From fb273ee28beac3005f3ef253bde8b1866fd0d604 Mon Sep 17 00:00:00 2001 From: J-E Castagnede Date: Thu, 26 Jan 2023 10:17:16 +0100 Subject: [PATCH 06/20] split doc to CONTRIBUTING section --- .env-dev.dist | 2 +- .githooks/pre-commit | 5 +++ docs/CONTRIBUTING.rst | 55 ++++++++++++++++++++++++++++ docs/conf.py | 3 +- docs/contribute/development.rst | 63 ++------------------------------- docs/index.rst | 1 + requirements-dev.txt | 2 +- 7 files changed, 67 insertions(+), 64 deletions(-) create mode 100644 docs/CONTRIBUTING.rst diff --git a/.env-dev.dist b/.env-dev.dist index 80de9e14cb..9beb328aed 100644 --- a/.env-dev.dist +++ b/.env-dev.dist @@ -1,5 +1,5 @@ ENV=dev -SERVER_NAME=geotrek.local +SERVER_NAME=geotrek.localhost POSTGRES_HOST=postgres POSTGRES_PORT=5432 POSTGRES_USER=geotrek diff --git a/.githooks/pre-commit b/.githooks/pre-commit index e64e1b764f..a51a42830d 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -6,6 +6,11 @@ function dockercompose { docker compose "$@" } +echo "Check dependency graph and fix requirements" + +dockercompose run -T --user root --rm web pip-compile -q && pip-compile requirements-dev.in -q + + echo "run Flake8..." dockercompose run -T --rm web flake8 geotrek diff --git a/docs/CONTRIBUTING.rst b/docs/CONTRIBUTING.rst new file mode 100644 index 0000000000..76fd4135bf --- /dev/null +++ b/docs/CONTRIBUTING.rst @@ -0,0 +1,55 @@ +============ +Contributing +============ + +Conventions +----------- + +* Before contributing, open an issue and discuss about it with community (is it a bug or a feature ? What is the best way to achieve my goal ?) +* Use flake8 +* KISS & DRY as much as possible +* Elegant and generic is good, simple is better +* Separate bug fixes and new features in several pull requests. +* Open a new Pull Request in "Draft" status until tests passed. Use at least 'bug', 'improvement' or 'feature' label. +* Commits messages are explicit and mention issue number (``(ref #12)`` or ``(fixes #23)``) +* Features are developed in a branch and merged from Github pull-requests. +* Several git hooks are available. Install them with following commands: + * pre-push: `ln -s -f ../../.githooks/pre-push .git/hooks/pre-push` + + * pre-commit: `ln -s -f ../../.githooks/pre-commit .git/hooks/pre-commit` + + +Definition of done +------------------ + +* ``docs/changelog.rst`` is up-to-date +* An explicit unit-test covers the bugfix or the new feature. +* A frontend test (:path:jstests/nav-\*.js) covers the navigation bug fix or feature +* A JS *Mocha* test (:path:jstests/tests.\*.js) covers the JavaScript bug fix or feature +* Unit-tests total coverage is above or at least equal with previous commits. Patch coverage is 100% on new lines. +* Settings have default value in ``settings/base.py`` +* Installation instructions and documentation are up-to-date + +Check TODO in the source tree: + +:: + + find geotrek | xargs egrep -n -i '(TODO|XXX|temporary|FIXME)' + + +Release +------- + +On master branch: + +* If need be, merge ``translations`` branch managed with https://weblate.makina-corpus.net +* Update files *VERSION*, *docs/conf.py* and *docs/changelog.rst* to remove ``+dev`` suffix and increment version (please use semver rules) +* Run ``dch -r -D RELEASED``, update version in the same way and save +* Commit with message 'Release x.y.z' to merge in ``master`` branch before release +* Add git tag X.Y.Z +* Update files *VERSION*, *docs/conf.py* and *docs/changelog.rst* to add ``+dev`` suffix +* Run ``dch -v +dev --no-force-save-on-release`` and save +* Commit with message 'Back to development' +* Push branch and tag +* Add release on Github (copy-paste ``doc/changelog.rst`` paragraph) +* When creating a new release 'x.y.z' on github, Github actions will generate the .deb package file, and publish it on https://packages.geotrek.fr (see ``.circleci/config.yml`` file for details) diff --git a/docs/conf.py b/docs/conf.py index 9262d1bae9..226c845fd4 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,4 +1,5 @@ import sphinx_rtd_theme # noqa +import datetime # Geotrek documentation build configuration file, created by # sphinx-quickstart on Wed May 15 09:50:19 2013. # @@ -41,7 +42,7 @@ # General information about the project. project = 'Geotrek' -copyright = '2013-2021, Makina Corpus' +copyright = f'2013-{datetime.date.today().year}, Makina Corpus' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the diff --git a/docs/contribute/development.rst b/docs/contribute/development.rst index b523940744..7ffd82b000 100644 --- a/docs/contribute/development.rst +++ b/docs/contribute/development.rst @@ -18,68 +18,9 @@ Quickstart docker-compose run --rm web ./manage.py createsuperuser docker-compose up -d -Go to http://localhost:8000 +Go to http://geotrek.localhost:8000 -PDF generation might not work unless you add the following entry to ``/etc/hosts`` and use ``geotrek.local:8000`` to access Geotrek. - -:: - - 127.0.0.1 localhost geotrek.local - - -Contribution guide -================== - -Conventions ------------ - -* Use flake8 -* KISS & DRY as much as possible -* Elegant and generic is good, simple is better -* Before contributing, open an issue and discuss about it with community (is it a bug or a feature ? What is the best way to achieve my goal ?) -* Separate bug fixes and new features in several pull requests. -* Open a new Pull Request in "Draft" status until tests passed. Use at least 'bug', 'improvement' or 'feature' label. -* Commits messages are explicit and mention issue number (``(ref #12)`` or ``(fixes #23)``) -* Features are developed in a branch and merged from Github pull-requests. -* Several git hooks are available. Install them with following commands: - * pre-push: `ln -s -f ../../.githooks/pre-push .git/hooks/pre-push` - * pre-commit: `ln -s -f ../../.githooks/pre-commit .git/hooks/pre-commit` - - -Definition of done ------------------- - -* ``docs/changelog.rst`` is up-to-date -* An explicit unit-test covers the bugfix or the new feature. -* A frontend test (:path:jstests/nav-\*.js) covers the navigation bug fix or feature -* A JS *Mocha* test (:path:jstests/tests.\*.js) covers the JavaScript bug fix or feature -* Unit-tests total coverage is above or at least equal with previous commits. Patch coverage is 100% on new lines. -* Settings have default value in ``settings/base.py`` -* Installation instructions and documentation are up-to-date - -Check TODO in the source tree: - -:: - - find geotrek | xargs egrep -n -i '(TODO|XXX|temporary|FIXME)' - - -Release -------- - -On master branch: - -* If need be, merge ``translations`` branch managed with https://weblate.makina-corpus.net -* Update files *VERSION*, *docs/conf.py* and *docs/changelog.rst* to remove ``+dev`` suffix and increment version (please use semver rules) -* Run ``dch -r -D RELEASED``, update version in the same way and save -* Commit with message 'Release x.y.z' to merge in ``master`` branch before release -* Add git tag X.Y.Z -* Update files *VERSION*, *docs/conf.py* and *docs/changelog.rst* to add ``+dev`` suffix -* Run ``dch -v +dev --no-force-save-on-release`` and save -* Commit with message 'Back to development' -* Push branch and tag -* Add release on Github (copy-paste ``doc/changelog.rst`` paragraph) -* When creating a new release 'x.y.z' on github, Github actions will generate the .deb package file, and publish it on https://packages.geotrek.fr (see ``.circleci/config.yml`` file for details) +PDF generation might not work unless you use this domain and is correctly set to SERVER_NAME variable in your .env file. Development diff --git a/docs/index.rst b/docs/index.rst index 206069a832..6b73284b91 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -38,6 +38,7 @@ Welcome to Geotrek's documentation! :caption: Contribute :maxdepth: 2 + CONTRIBUTING contribute/translating contribute/documentation contribute/development diff --git a/requirements-dev.txt b/requirements-dev.txt index 7e3b1e21c3..fae2cd12a4 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -16,7 +16,7 @@ click==8.1.3 # pip-tools coverage==7.1.0 # via -r requirements-dev.in -django==3.2.16 +django==4.1.0 # via # -c requirements.txt # django-debug-toolbar From ca919eb9ca52d0b778189170b9cba325b560a63c Mon Sep 17 00:00:00 2001 From: J-E Castagnede Date: Thu, 26 Jan 2023 10:28:06 +0100 Subject: [PATCH 07/20] organize doc --- docs/CONTRIBUTING.rst | 4 --- docs/contribute/development.rst | 45 +++++++++++++++++---------------- docs/index.rst | 7 ++++- 3 files changed, 29 insertions(+), 27 deletions(-) diff --git a/docs/CONTRIBUTING.rst b/docs/CONTRIBUTING.rst index 76fd4135bf..bd53ddc22a 100644 --- a/docs/CONTRIBUTING.rst +++ b/docs/CONTRIBUTING.rst @@ -13,10 +13,6 @@ Conventions * Open a new Pull Request in "Draft" status until tests passed. Use at least 'bug', 'improvement' or 'feature' label. * Commits messages are explicit and mention issue number (``(ref #12)`` or ``(fixes #23)``) * Features are developed in a branch and merged from Github pull-requests. -* Several git hooks are available. Install them with following commands: - * pre-push: `ln -s -f ../../.githooks/pre-push .git/hooks/pre-push` - - * pre-commit: `ln -s -f ../../.githooks/pre-commit .git/hooks/pre-commit` Definition of done diff --git a/docs/contribute/development.rst b/docs/contribute/development.rst index 7ffd82b000..e526510d8c 100644 --- a/docs/contribute/development.rst +++ b/docs/contribute/development.rst @@ -23,11 +23,19 @@ Go to http://geotrek.localhost:8000 PDF generation might not work unless you use this domain and is correctly set to SERVER_NAME variable in your .env file. -Development -=========== +Install git hooks +================= + +* Several git hooks are available to prevent pushing to master branch or launch quality tests before committing. Install them with following commands: + +:: + + ln -s -f ../../.githooks/pre-push .git/hooks/pre-push + ln -s -f ../../.githooks/pre-commit .git/hooks/pre-commit + Adding or upgrade dependencies ------------------------------- +============================== Consider using pip-tools to manage dependencies. @@ -40,7 +48,7 @@ Consider using pip-tools to manage dependencies. Model modification ------------------- +================== :: @@ -51,8 +59,8 @@ Model modification Add migration file to source control. -Model modification - Definition of Done for new model fields ------------------------------------------------------------- +Definition of Done for new model fields +--------------------------------------- When updating or adding a new field ``my_field`` to a model ``MyModel``, please proceed with the following changes to ensure this field is included in existing functionalities. @@ -108,7 +116,7 @@ This migration should rename the old fields generated by modeltranslation ``my_f Run tests ---------- +========= **Django tests :** @@ -162,7 +170,7 @@ Launch tests Pictures of the problem and videos are generated in cypress/videos and cypress/screenshots Setup to run rando synchronization locally ------------------------------------------- +========================================== (sync rando is only relevant for an admin paired with geotrek rando v2) @@ -173,24 +181,17 @@ For instance with SERVER_NAME=geotrek.local (default value) :: SYNC_RANDO_OPTIONS = { - 'url': 'http://geotrek.local:8000' + 'url': 'http://geotrek.local:8000' } Setup to use screamshotter-related features locally ---------------------------------------------------- - -Use the domain defined in SERVER_NAME in your .env to reach your local geotrek admin web instance. By default the address is `http://geotrek.local:8000`. +=================================================== -Update the `/etc/hosts` on your machine to resolve `geotrek.local` on `127.0.0.1`. - -:: +Use the domain defined in SERVER_NAME in your .env to reach your local geotrek admin web instance. By default the address is `http://geotrek.localhost:8000`. - $ cat /etc/hosts - 127.0.0.1 geotrek.local - 127.0.0.1 localhost Database reset --------------- +============== Data only: @@ -199,7 +200,7 @@ Data only: docker-compose run --rm web ./manage.py flush Restore existing Database -------------------------- +========================= Assuming a dump of your database is located in your project directory: @@ -212,13 +213,13 @@ Restore your ``./var/conf/`` project files, and data files into ``./var/media``. Then run a synchronization. Mapentity development ---------------------- +===================== TODO UML diagrams of data model --------------------------- +========================== UML diagrams of Geotrek-admin data models are available in ``docs/data-model`` directory. To regenerate them from PostgreSQL, install postgresql-autodoc and graphviz Ubuntu packages diff --git a/docs/index.rst b/docs/index.rst index 6b73284b91..84c4b614a0 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -39,10 +39,15 @@ Welcome to Geotrek's documentation! :maxdepth: 2 CONTRIBUTING + contribute/development contribute/translating contribute/documentation - contribute/development contribute/design + +.. toctree:: + :caption: Others + :maxdepth: 2 + authors changelog From 16308e4776a19ddaa1a8b1f9402d1f9a5dc6cb41 Mon Sep 17 00:00:00 2001 From: J-E Castagnede Date: Thu, 26 Jan 2023 10:42:51 +0100 Subject: [PATCH 08/20] fix doc format --- docs/changelog.rst | 6 +++--- docs/contribute/development.rst | 2 +- docs/faq.rst | 2 +- docs/install/advanced-configuration.rst | 9 +++++++-- docs/install/import.rst | 14 +++++++------- docs/install/installation.rst | 1 + docs/install/sensitivity.rst | 3 +++ docs/usage/configuration-ttw.rst | 5 ++++- docs/usage/editing-objects.rst | 3 ++- docs/usage/qgis.rst | 24 ++++++++++++------------ 10 files changed, 41 insertions(+), 28 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 613b127d3f..5fd89cb829 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -377,7 +377,7 @@ In preparation for HD Views developments (PR #3298) - Upgrade mapentity to 8.2.1 -**/!\ Regression /!\** +**! Regression !** - System permissions on files output by `sync_rando` and `sync_mobile` commands were inadvertently changed to more restricted with no reading allowed by group or other. This may cause trouble if your deployment relies on those permissions. @@ -4166,8 +4166,7 @@ In order to enable those features under construction, add ``experimental = True` :notes: Give related permissions to the managers group in order to allow edition - (``add_flatpage``, ``change_flatpage``, ``delete_flatpage``, - ``add_touristiccontent`` ...). + (``add_flatpage``, ``change_flatpage``, ``delete_flatpage``, ``add_touristiccontent`` ...). 0.27.2 (2010-10-14) @@ -4351,6 +4350,7 @@ Since the map export have changed, empty the cache : * Rework display of lists in detail pages, better factorization * Removed links in logbook list for certain models * Display messages in login page too (useful for redirections) + Support edition of several fields on the same map, via django-leaflet new feature (fixes #53) diff --git a/docs/contribute/development.rst b/docs/contribute/development.rst index e526510d8c..5b9539d80a 100644 --- a/docs/contribute/development.rst +++ b/docs/contribute/development.rst @@ -178,7 +178,7 @@ In your django settings you must set the 'url' key of SYNC_RANDO_OPTIONS to use For instance with SERVER_NAME=geotrek.local (default value) -:: +.. code-block :: python SYNC_RANDO_OPTIONS = { 'url': 'http://geotrek.local:8000' diff --git a/docs/faq.rst b/docs/faq.rst index 01e7d1bbd7..2ed4c9312b 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -121,5 +121,5 @@ the source code is probably the least common action. For example : * Fix bugs or improve layout and apparence (*requires Webmaster skills*) ; * Fix bugs or improve core modules (*requires python/Django skills*). -Join us on the `mailing-list `_! Send an email to ``geotrek-fr+subscribe@googlegroups.com`` +Join us on the `mailing list `_! Send an email to ``geotrek-fr+subscribe@googlegroups.com`` and you will receive an invitation automatically :) diff --git a/docs/install/advanced-configuration.rst b/docs/install/advanced-configuration.rst index b50f017179..ca5dcc6331 100644 --- a/docs/install/advanced-configuration.rst +++ b/docs/install/advanced-configuration.rst @@ -218,7 +218,7 @@ Make sure to run these 3 commands daily to maintain synchronization and update r Display reports with status defined colors -~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block :: python @@ -228,7 +228,7 @@ Go to the Admin Site and select colors to display for each status (`/admin/feedb Use timers to receive alerts for your reports -~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ It is possible to enable receiving email alerts for reports that have remained in the same status for too long. For instance, I can create two report statuses "To program" with timer days set to 10 and "Programmed" with timer days set to 0. @@ -278,6 +278,7 @@ add the following code: The following settings are related to sensitive areas: + .. code-block :: python SHOW_SENSITIVE_AREAS_ON_MAP_SCREENSHOT = True @@ -287,9 +288,13 @@ The following settings are related to sensitive areas: # Buffer around treks to intersects sensitive areas SENSITIVE_AREA_INTERSECTION_MARGIN = 500 # meters + +.. notes + # Take care if you change this value after adding data. You should update buffered geometry in sql. ``` UPDATE sensitivity_sensitivearea SET geom_buffered = ST_BUFFER(geom, ); ``` + To take these changes into account, you need to run : :: diff --git a/docs/install/import.rst b/docs/install/import.rst index 8c2ff17388..c5f3a772f9 100644 --- a/docs/install/import.rst +++ b/docs/install/import.rst @@ -205,13 +205,13 @@ If you need to cancel the aggregation of portals, remove param ``m2m_aggregate_f Importing from multiple sources with deletion ----------------- +--------------------------------------------- When importing data for the same model using two (or more) different sources, the ``provider`` field should be used to differenciate between sources, allowing to enable object deletion with ``delete = True`` without causing the last parser to delete objects created by preceeding parsers. In the following example, ``Provider_1Parser`` and ``Provider_2Parser`` will each import their objects, set the ``provider`` field on these objects, and only delete objects that disappeared from their respective source since last parsing. -:: +.. code-block:: python class Provider_1Parser(XXXXParser): delete = True @@ -232,7 +232,7 @@ In the following example, ``Provider_1Parser`` and ``Provider_2Parser`` will eac The following example would cause ``NoProviderParser`` to delete objects from ``Provider_2Parser`` and ``Provider_1Parser``. -:: +.. code-block:: python class Provider_1Parser(XXXXParser): delete = True @@ -311,7 +311,7 @@ A usecase for this is to aggregate data from several Geotrek-admin instance. For example, to import treks from another instance, edit ``/opt/geotrek-admin/var/conf/parsers.py`` file with the following content: -:: +.. code-block:: python class DemoGeotrekTrekParser(BaseGeotrekTrekParser): url = "https://remote-geotrek-admin.net" # replace url with remote instance url @@ -343,7 +343,7 @@ You can add parsers in your custom `parsers.py` file (``/opt/geotrek-admin/var/c import data from files directly in your admin (superusers only). For example, some parsers are not available by default but you can use them adding some lines in your parsers file : -:: +.. code-block:: python from geotrek.trekking.parsers import TrekParser # only without dynamic segmentation (`TREKKING_TOPOLOGY_ENABLED` = False) from geotrek.trekking.parsers import POIParser @@ -830,8 +830,8 @@ when the order is not well managed during topologies' display. -Automatication commands ------------------------ +Automatic commands +------------------ You can set up automatic commands by creating a `cron` file under ``/etc/cron.d/geotrek_command`` that contains: diff --git a/docs/install/installation.rst b/docs/install/installation.rst index cc09cdffd2..57d0e0fefc 100644 --- a/docs/install/installation.rst +++ b/docs/install/installation.rst @@ -184,6 +184,7 @@ Geotrek-admin requires at least PostGIS 2.5. If you installed Geotrek-admin on bionic ubuntu with provided install method, you should update your database : :: + # Firstly, backup your database (see previous section) # install postgresql APT repository # (from https://wiki.postgresql.org/wiki/Apt) diff --git a/docs/install/sensitivity.rst b/docs/install/sensitivity.rst index fc170b1a3b..a6b2dcbe81 100644 --- a/docs/install/sensitivity.rst +++ b/docs/install/sensitivity.rst @@ -29,6 +29,9 @@ The following settings are related to sensitive areas: # Buffer around treks to intersects sensitive areas SENSITIVE_AREA_INTERSECTION_MARGIN = 500 # meters + +.. notes + # Take care if you change this value after adding data. You should update buffered geometry in sql. ``` UPDATE sensitivity_sensitivearea SET geom_buffered = ST_BUFFER(geom, ); ``` diff --git a/docs/usage/configuration-ttw.rst b/docs/usage/configuration-ttw.rst index b625864b8e..88abde1e23 100644 --- a/docs/usage/configuration-ttw.rst +++ b/docs/usage/configuration-ttw.rst @@ -116,9 +116,12 @@ Utilisateurs et droits Une fois un utilisateur créé avec les informations minimales, il est possible de lui octroyer un certain nombre de permissions : - **Actif** : permet de déterminer si l'utilisateur peut se connecter à Geotrek-Admin ou non. - Il est préférable de désactiver un compte lorsqu'un utilisateur n'intervient plus sur Geotrek, plutôt que de le supprimer. + + Il est préférable de désactiver un compte lorsqu'un utilisateur n'intervient plus sur Geotrek, plutôt que de le supprimer. En effet supprimer le compte supprimera également par exemple toutes les entrées dans l'historique de Geotrek associées à ce compte. + - **Statut équipe** : si la case est cochée l'utilisateur pourra accéder à l'interface d'administration de Geotrek-Admin + - **Statut super-utilisateur** : permet d'octroyer toutes les permissions à un utilisateur sans avoir à les définir explicitement Il est possible pour un utilisateur, de lui donner des permissions spécifiques. Celles-ci sont déterminées par type d'objet. diff --git a/docs/usage/editing-objects.rst b/docs/usage/editing-objects.rst index b17f7c07df..45bc24b66a 100644 --- a/docs/usage/editing-objects.rst +++ b/docs/usage/editing-objects.rst @@ -17,7 +17,8 @@ Les objets ponctuels ne sont associés qu'à un seul tronçon, sauf dans le cas Chaque évènement dispose néanmoins d'une géométrie calculée à partir de leur segmentation dynamique pour faciliter leur affichage dans Geotrek ou dans QGIS. Il ne faut néanmoins pas modifier directement ces géométries, elles sont calculées automatiquement quand on modifie l'évènement d'un objet. -.. notes:: +.. notes + Des vues SQL sont disponibles pour accéder aux objets de manière plus lisible et simplifiée (``v_interventions`` par exemple). Snapping - Aimantage - Accrochage diff --git a/docs/usage/qgis.rst b/docs/usage/qgis.rst index 21b1705a50..054c3bfc9c 100644 --- a/docs/usage/qgis.rst +++ b/docs/usage/qgis.rst @@ -1,11 +1,11 @@ -======== +================================ Visualiser les données dans QGIS -======== +================================ .. image :: ../images/qgis/Qgis_projet.png Création de vues SQL pour afficher des couches dans QGIS -========= +======================================================== Des vues SQL ont été créées dans la base de données PostgreSQL de Geotrek-admin dans le but de les afficher dans QGIS ou autre. Ces vues contiennent les informations essentielles que l'on retrouve dans Geotrek-admin au niveau de chaque module. @@ -14,7 +14,7 @@ Ces vues sont consultables en lecture seule dans QGIS sous forme de couche SIG. Les modifications se font directement dans Geotrek-admin pour chaque projet, et elles sont répercutées instantanément dans les vues SQL. Créer une connexion à la base de données PostgreSQL du projet -========= +============================================================= 1. Ouvrir le logiciel QGIS 2. Créer une nouvelle connexion de base de données PostgreSQL @@ -34,10 +34,10 @@ Créer une connexion à la base de données PostgreSQL du projet .. image :: ../images/qgis/Connexion_bdd.png Créer un projet QGIS à partir des vues SQL -========= +========================================== Afficher une vue SQL sous forme de couche --------------- +----------------------------------------- * Dans l'Explorateur > PostgreSQL > Ouvrir la connexion précédemment créé > Schéma public * Ajouter les vues : Clic droit sur l'objet > Ajouter la couche au projet @@ -60,12 +60,12 @@ Afficher une vue SQL sous forme de couche * Parcours outdoor <> `v_outdoor_courses` Afficher un fond de plan OpenStreetMap --------------- +-------------------------------------- * Dans l'Explorateur > XYZ Tiles > OpenStreetMap Créer des groupes de couches --------------- +---------------------------- * Dans le panneau des couches > clic droit > Ajouter un groupe @@ -74,14 +74,14 @@ Il peut être utile de créer des groupes de couches dans le cas où certaines c .. image :: ../images/qgis/groupe_couches.png Changer le style d'une couche --------------- +----------------------------- * Clic droit sur la couche > Propriétés > Symbologie Selon le type géométrique de la couche (point, ligne, polygone), il est possible de changer à volonté la couleur de remplissage, la couleur de contour, la taille ou l'épaisseur. Dimensionner les colonnes de la table attributaire --------------- +-------------------------------------------------- Le fait de dimensionner la taille des colonnes dans la table attributaire permet une permet lisibilité des noms de champs et des informations contenues à l'intérieur : @@ -91,12 +91,12 @@ Certains champs texte peuvent être très larges (exemple _Description_ dans la * Clic droit sur la couche > Ouvrir la Table d'Attributs > clic droit sur la colonne > Largeur > Entrer une largeur de colonne (exemple : 200) Afficher le décompte des entités d'une couche --------------- +--------------------------------------------- * Clic droit sur la couche > Afficher le nombre d'entités Zoomer sur l'emprise d'une couche --------------- +--------------------------------- * Clic droit sur la couche > Zoomer sur la(les) couche(s) From 1e3c4276b420d6e483333898f6248c65dd06ec31 Mon Sep 17 00:00:00 2001 From: J-E Castagnede Date: Thu, 26 Jan 2023 11:00:28 +0100 Subject: [PATCH 09/20] improve requirmeents and pre-commit --- .githooks/pre-commit | 3 ++- requirements-dev.txt | 2 +- requirements.txt | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.githooks/pre-commit b/.githooks/pre-commit index a51a42830d..d02ed4cb11 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -8,7 +8,8 @@ function dockercompose { echo "Check dependency graph and fix requirements" -dockercompose run -T --user root --rm web pip-compile -q && pip-compile requirements-dev.in -q +dockercompose run -T --user root --rm web bash -c "pip-compile -q && pip-compile requirements-dev.in" + echo "run Flake8..." diff --git a/requirements-dev.txt b/requirements-dev.txt index fae2cd12a4..7e3b1e21c3 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -16,7 +16,7 @@ click==8.1.3 # pip-tools coverage==7.1.0 # via -r requirements-dev.in -django==4.1.0 +django==3.2.16 # via # -c requirements.txt # django-debug-toolbar diff --git a/requirements.txt b/requirements.txt index 1239fb8f77..322fb0d7ea 100644 --- a/requirements.txt +++ b/requirements.txt @@ -176,7 +176,7 @@ html5lib==1.1 # via weasyprint idna==3.4 # via requests -importlib-metadata==5.1.0 +importlib-metadata==6.0.0 # via markdown inflection==0.5.1 # via drf-yasg @@ -330,7 +330,7 @@ zc-lockfile==2.0 # via zodb zconfig==3.6.1 # via zodb -zipp==3.6.0 +zipp==3.11.0 # via importlib-metadata zodb==5.7.0 # via appy From 95565dc344276432a0b5e7dab9d1ccabdbe86767 Mon Sep 17 00:00:00 2001 From: J-E Castagnede Date: Thu, 26 Jan 2023 12:18:42 +0100 Subject: [PATCH 10/20] fix user in dockerfile for git hook and pip-tools --- Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index e436464075..8c0291fc1a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,7 +16,7 @@ ENV CUSTOM_SETTINGS_FILE="/opt/geotrek-admin/var/conf/custom.py" WORKDIR /opt/geotrek-admin RUN mkdir -p /opt/geotrek-admin/var/log /opt/geotrek-admin/var/cache - +RUN adduser geotrek --disabled-password && chown geotrek:geotrek -R /opt # Install postgis because raster2pgsl is required by manage.py loaddem RUN apt-get update -qq && apt-get install -y -qq \ unzip \ @@ -42,8 +42,9 @@ RUN apt-get update -qq && apt-get install -y -qq \ apt-get install -y --no-install-recommends postgis && \ apt-get clean all && rm -rf /var/lib/apt/lists/* && rm -rf /var/cache/apt/* +USER geotrek RUN python3 -m venv /opt/venv -RUN /opt/venv/bin/pip install -U pip setuptools wheel +RUN /opt/venv/bin/pip install --no-cache-dir -U pip setuptools wheel COPY requirements.txt requirements.txt RUN /opt/venv/bin/pip install --no-cache-dir -r requirements.txt -U COPY requirements-dev.txt requirements-dev.txt From 780820910ae484d5d2e6976961304cad7558e657 Mon Sep 17 00:00:00 2001 From: J-E Castagnede Date: Thu, 26 Jan 2023 13:10:51 +0100 Subject: [PATCH 11/20] fix rights in docker image --- Dockerfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8c0291fc1a..f3f2deefed 100644 --- a/Dockerfile +++ b/Dockerfile @@ -50,11 +50,11 @@ RUN /opt/venv/bin/pip install --no-cache-dir -r requirements.txt -U COPY requirements-dev.txt requirements-dev.txt RUN /opt/venv/bin/pip install --no-cache-dir -r requirements-dev.txt -U -COPY geotrek/ geotrek/ -COPY manage.py manage.py -COPY VERSION VERSION -COPY setup.cfg setup.cfg -COPY docker/* /usr/local/bin/ +COPY --chown=geotrek:geotrek geotrek/ geotrek/ +COPY --chown=geotrek:geotrek manage.py manage.py +COPY --chown=geotrek:geotrek VERSION VERSION +COPY --chown=geotrek:geotrek setup.cfg setup.cfg +COPY --chown=geotrek:geotrek docker/* /usr/local/bin/ ENTRYPOINT ["/bin/sh", "-e", "/usr/local/bin/entrypoint.sh"] EXPOSE 8000 From 14b9d02f39330c1f11227e5bc06a84dd1890f53c Mon Sep 17 00:00:00 2001 From: J-E Castagnede Date: Thu, 26 Jan 2023 14:44:16 +0100 Subject: [PATCH 12/20] revert coverage package version --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 7e3b1e21c3..9049efb137 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -14,7 +14,7 @@ click==8.1.3 # via # -c requirements.txt # pip-tools -coverage==7.1.0 +coverage==6.5.0 # via -r requirements-dev.in django==3.2.16 # via From ca05ea1ff2d79ade7f31c0941cff9156bca79986 Mon Sep 17 00:00:00 2001 From: J-E Castagnede Date: Thu, 26 Jan 2023 15:26:34 +0100 Subject: [PATCH 13/20] check dependency graph in CI --- .githooks/pre-commit | 2 +- .github/workflows/lint.yml | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/.githooks/pre-commit b/.githooks/pre-commit index d02ed4cb11..950d51bd16 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -8,7 +8,7 @@ function dockercompose { echo "Check dependency graph and fix requirements" -dockercompose run -T --user root --rm web bash -c "pip-compile -q && pip-compile requirements-dev.in" +dockercompose run -T --rm web bash -c "pip-compile -q && pip-compile requirements-dev.in" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 42066f44d8..56e49296ff 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -7,8 +7,8 @@ env: DEBIAN_FRONTEND: noninteractive jobs: - flake8: - name: Check code styling + quality: + name: Checking dependency graph and code quality runs-on: ubuntu-18.04 steps: @@ -29,6 +29,25 @@ jobs: pip3 install --upgrade pip wheel setuptools pip3 install -r requirements-dev.txt -U + - name: Check dependency graph + run: | + pip-compile -q + pip-compile -q requirements-dev.in + + - name: Verify dependency graph is ok + uses: tj-actions/verify-changed-files@v13 + id: verify-changed-files + with: + files: | + requirements.txt + requirements-dev.txt + + - name: Validating graph + if: steps.verify-changed-files.outputs.files_changed == 'true' + run: | + echo "Dependency file(s) changed: ${{ steps.verify-changed-files.outputs.changed_files }}" + core.setFailed('Please add your new dependencies in setup.py and/or requirements-dev.in then run pip-compile to add them in requirements. (see docs/contribute/development)') + - name: Flake8 run: | flake8 geotrek From 27d6366a8ad54928794cc4eeaccac93a2105ff03 Mon Sep 17 00:00:00 2001 From: J-E Castagnede Date: Thu, 26 Jan 2023 15:52:28 +0100 Subject: [PATCH 14/20] fail doc generation on warning --- .github/workflows/doc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml index 36e4cb8e7f..27d885ac53 100644 --- a/.github/workflows/doc.yml +++ b/.github/workflows/doc.yml @@ -30,4 +30,4 @@ jobs: run: | cd docs/ pip install -r ./requirements.txt - make html + make html SPHINXOPTS="-W" From 3c4de4a422f285ea0587d672d810606e3d710af9 Mon Sep 17 00:00:00 2001 From: J-E Castagnede Date: Thu, 26 Jan 2023 15:52:47 +0100 Subject: [PATCH 15/20] update CI machine on lint workflow --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 56e49296ff..c4faca87e8 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -9,7 +9,7 @@ env: jobs: quality: name: Checking dependency graph and code quality - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v3 From 0d82260f1a5daf5caabe2894f81835493a2cb1a9 Mon Sep 17 00:00:00 2001 From: J-E Castagnede Date: Thu, 26 Jan 2023 16:01:49 +0100 Subject: [PATCH 16/20] add changelog --- docs/changelog.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index 5fd89cb829..2c16ab88a9 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -5,6 +5,13 @@ CHANGELOG 2.95.0+dev (XXXX-XX-XX) ----------------------- +**Development** + +- New contributing guide (docs/CONTRIBUTING.rst) +- Development dependencies are now split in dedicated file. +- pip-tools and flake8 are now available in developer environment +- Dependency graph is now checked in CI (see docs/contribute/development to how add a new dependency) +- New git pre-commit hook to check all is alright before commit (see docs/contribute/development) 2.95.0 (2023-01-24) From a6c3a43b76edb4f2fcbe5119fab2d4ebaeff8778 Mon Sep 17 00:00:00 2001 From: J-E Castagnede Date: Fri, 27 Jan 2023 09:44:34 +0100 Subject: [PATCH 17/20] fix dependency graph --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 9049efb137..67c7545b57 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -4,7 +4,7 @@ # # pip-compile requirements-dev.in # -asgiref==3.4.1 +asgiref==3.6.0 # via # -c requirements.txt # django From 4b23d0d83e3b260c95213fa28a885cb7c70834e8 Mon Sep 17 00:00:00 2001 From: J-E Castagnede Date: Fri, 27 Jan 2023 09:45:09 +0100 Subject: [PATCH 18/20] add make entries --- Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile b/Makefile index dc461d21c7..ec47c78abc 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,12 @@ build-no-cache: serve: docker-compose up +deps: + docker-compose run --rm web bash -c "pip-compile -q && pip-compile -q requirements-dev.in" + +flake8: + docker-compose run --rm web flake8 geotrek + messages: docker-compose run --rm web ./manage.py makemessages -a --no-location From 8ac0ee95ee54e9c182286850e7f985b54ef255a4 Mon Sep 17 00:00:00 2001 From: J-E Castagnede Date: Fri, 27 Jan 2023 10:58:23 +0100 Subject: [PATCH 19/20] add make shortcuts in dev documentation --- docs/contribute/development.rst | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/docs/contribute/development.rst b/docs/contribute/development.rst index 5b9539d80a..069f724cc8 100644 --- a/docs/contribute/development.rst +++ b/docs/contribute/development.rst @@ -46,6 +46,12 @@ Consider using pip-tools to manage dependencies. docker-compose run --rm web pip-compile docker-compose run --rm web pip-compile requirements-dev.in +or + +:: + + make deps + Model modification ================== @@ -115,6 +121,25 @@ This migration should rename the old fields generated by modeltranslation ``my_f (example : ``geotrek/trekking/migrations/0014_auto_20200228_2127.py``) +Check quality +============= + +**Flake8** + +run: + +:: + + docker-compose run --rm web flake8 geotrek + + +or + +:: + + make flake8 + + Run tests ========= @@ -180,9 +205,9 @@ For instance with SERVER_NAME=geotrek.local (default value) .. code-block :: python - SYNC_RANDO_OPTIONS = { - 'url': 'http://geotrek.local:8000' - } + SYNC_RANDO_OPTIONS = { + 'url': 'http://geotrek.local:8000' + } Setup to use screamshotter-related features locally =================================================== From 708d8244d1220bf941275788fd27490bece25bde Mon Sep 17 00:00:00 2001 From: J-E Castagnede Date: Fri, 27 Jan 2023 11:01:19 +0100 Subject: [PATCH 20/20] fix doc with geotrek.localhost as default value --- docs/contribute/development.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/contribute/development.rst b/docs/contribute/development.rst index 069f724cc8..526a79b8a4 100644 --- a/docs/contribute/development.rst +++ b/docs/contribute/development.rst @@ -201,12 +201,12 @@ Setup to run rando synchronization locally In your django settings you must set the 'url' key of SYNC_RANDO_OPTIONS to use the same domain as defined by SERVER_NAME in your .env. -For instance with SERVER_NAME=geotrek.local (default value) +For instance with SERVER_NAME=geotrek.localhost (default value) .. code-block :: python SYNC_RANDO_OPTIONS = { - 'url': 'http://geotrek.local:8000' + 'url': 'http://geotrek.localhost:8000' } Setup to use screamshotter-related features locally