Skip to content

Commit

Permalink
Merge pull request #1388 from camptocamp/pre-commit-config
Browse files Browse the repository at this point in the history
Update pre-commit configuration
  • Loading branch information
sbrunner authored Aug 30, 2024
2 parents 49089cf + 45609fa commit fc52097
Show file tree
Hide file tree
Showing 12 changed files with 123 additions and 20 deletions.
File renamed without changes.
104 changes: 100 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# https://pre-commit.com/hooks.html

ci:
autoupdate_schedule: quarterly
skip:
- ripsecrets
exclude: |
(?x)^(
CONST_.*
|mapserver/data/lac-leman.osm
)$
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand All @@ -21,6 +22,14 @@ repos:
rev: v3.1.0
hooks:
- id: prettier
- repo: https://github.com/sbrunner/integrity-updater
rev: 0.1.0
hooks:
- id: integrity-updater
exclude: |-
(?x)^(
geoportal/.*
)$
- repo: https://github.com/PyCQA/autoflake
rev: v2.3.1
hooks:
Expand All @@ -33,3 +42,90 @@ repos:
rev: 24.8.0
hooks:
- id: black
- repo: https://github.com/asottile/pyupgrade
rev: v3.16.0
hooks:
- id: pyupgrade
args:
- --py310-plus
exclude: |-
(?x)^(
build
)$
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: detect-private-key
- id: check-merge-conflict
- id: check-ast
- id: debug-statements
- id: check-toml
- id: check-yaml
- id: check-json
- id: end-of-file-fixer
- id: trailing-whitespace
- id: mixed-line-ending
- repo: https://github.com/sbrunner/hooks
rev: 1.0.0
hooks:
- id: copyright
exclude: |-
(?x)^(
build
|geoportal
|scripts/db-backup
|scripts/db-restore
)$
- id: poetry-lock
additional_dependencies:
- poetry==1.8.3 # pypi
exclude: |-
(?x)^(
pyproject\.toml
)$
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
exclude: |-
(?x)^(
(.*/)?poetry\.lock
|ci/cleanup
|geoportal/geomapfish_geoportal/locale/.*
|qgisserver/.*\.qg[sz]
|geoportal/geomapfish_geoportal/static/story-map\.html
|tilegeneration/config\.yaml\.tmpl
|webcomponents/feedback\.ts
)$
args:
- --ignore-words=.github/spell-ignore-words.txt
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.10.0.1
hooks:
- id: shellcheck
- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 3.0.0
hooks:
- id: git-check
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.28.6
hooks:
- id: check-github-actions
- id: check-github-workflows
- id: check-jsonschema
name: Check GitHub Workflows set timeout-minutes
files: ^\.github/workflows/[^/]+$
types:
- yaml
args:
- --builtin-schema
- github-workflows-require-timeout
- repo: https://github.com/sirwart/ripsecrets
rev: v0.1.8
hooks:
- id: ripsecrets
- repo: https://github.com/sbrunner/jsonschema-validator
rev: 0.1.0
hooks:
- id: jsonschema-validator
files: ^ci/config\.yaml$
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.10
1 change: 1 addition & 0 deletions .secretsignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/geoportal/interfaces/desktop_alt.html.mako
3 changes: 2 additions & 1 deletion custom/custom/alembic/env.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"""Pyramid bootstrap environment. """

from alembic import context
from custom.models.meta import Base
from pyramid.paster import get_appsettings, setup_logging
from sqlalchemy import engine_from_config

from custom.models.meta import Base

config = context.config

setup_logging(config.config_file_name)
Expand Down
3 changes: 2 additions & 1 deletion custom/custom/scripts/initialize_db.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import argparse
import sys

from custom.models.meta import Base
from pyramid.paster import bootstrap, setup_logging
from sqlalchemy.exc import OperationalError

from custom.models.meta import Base


def setup_models(dbsession):
"""
Expand Down
3 changes: 2 additions & 1 deletion custom/custom/views/feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
import pyramid.request
import requests
from cornice import Service
from pyramid.httpexceptions import HTTPBadRequest

from custom.models.feedback import Feedback
from custom.util.send_mail import send_mail
from pyramid.httpexceptions import HTTPBadRequest

LOG = logging.getLogger(__name__)

Expand Down
5 changes: 3 additions & 2 deletions custom/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
import pytest
import transaction
import webtest
from custom import main, models
from custom.models.meta import Base
from pyramid.paster import get_appsettings
from pyramid.scripting import prepare
from pyramid.testing import DummyRequest, testConfig

from custom import main, models
from custom.models.meta import Base


def pytest_addoption(parser):
parser.addoption("--ini", action="store", metavar="INI_FILE")
Expand Down
4 changes: 2 additions & 2 deletions mapserver/mapserver.map.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ MAP
END
WEB
METADATA
"wms_title" "Démo du c2cgeoportal"
"wms_abstract" "Des exemples de couches à partir de données OpenData de différentes villes françaises et suisse."
"wms_title" "GeoMapFish demo"
"wms_abstract" "Some example layers"
"ows_onlineresource" "${VISIBLE_WEB_PROTOCOL}://${VISIBLE_WEB_HOST}${VISIBLE_ENTRY_POINT}mapserv_proxy?ogcserver=Main+PNG"
"ows_srs" "EPSG:2056"
"wms_enable_request" "*"
Expand Down
1 change: 1 addition & 0 deletions project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ managed_files:
- geoportal/interfaces/desktop_alt\.html\.mako
- tests/test_app.py
- .editorconfig
- .pre-commit-config\.yaml
unmanaged_files:
- geoportal/geomapfish_geoportal/static-ngeo/js/apps/Controller.*\.js
- geoportal/geomapfish_geoportal/static-ngeo/js/apps/.*\.html\.ejs
Expand Down
14 changes: 7 additions & 7 deletions scripts/osm_data.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#!/bin/bash -aux

cd /var/sig/demo/c2cgeoportal
cd /var/sig/demo/c2cgeoportal || exit 1

rm switzerland-latest.osm.pbf
wget http://download.geofabrik.de/europe/switzerland-latest.osm.pbf
Expand All @@ -16,8 +16,8 @@ wget http://download.geofabrik.de/europe/switzerland-latest.shp.zip
unzip switzerland-latest.shp.zip
shp2pgsql -c -s 4326:2056 -g geom -I osm_switzerland/points swiss_points | psql -h localhost -U www-data -W osm

sudo -u postgres psql -c "ALTER TABLE swiss_points RENAME COLUMN "timestamp" TO timestamp_;" osm
sudo -u postgres psql -c "ALTER TABLE swiss_points ADD COLUMN "timestamp" timestamp;" osm
sudo -u postgres psql -c "UPDATE ONLY swiss_points SET "timestamp" = timestamp_::timestamp;" osm
sudo -u postgres psql -c "CREATE INDEX ON swiss_points("timestamp");" osm
sudo -u postgres psql -c "ALTER TABLE swiss_points DROP COLUMN timestamp_;" osm
sudo -u postgres psql -c 'ALTER TABLE swiss_points RENAME COLUMN "timestamp" TO timestamp_;' osm
sudo -u postgres psql -c 'ALTER TABLE swiss_points ADD COLUMN "timestamp" timestamp;' osm
sudo -u postgres psql -c 'UPDATE ONLY swiss_points SET "timestamp" = timestamp_::timestamp;' osm
sudo -u postgres psql -c 'CREATE INDEX ON swiss_points("timestamp");' osm
sudo -u postgres psql -c 'ALTER TABLE swiss_points DROP COLUMN timestamp_;' osm
4 changes: 2 additions & 2 deletions scripts/upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

function printdiff {
ls -l .UPGRADE*
for f in $(ls -1 *.diff || true); do
for f in $(ls -1 '*.diff' || true); do
echo "--- $f ---"
cat "$f"
done
Expand Down Expand Up @@ -50,4 +50,4 @@ if [[ $(git status --porcelain) == "" ]]; then
fi
git add --all
git commit --message="Upgrade to $1"
git push $2
git push "$2"

0 comments on commit fc52097

Please sign in to comment.