Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add/update pre-commit hooks #486

Merged
merged 3 commits into from
Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
schedule: 'after 5pm on the first day of the month',
},
baseBranches: ['master', '7.2', '7.4', '7.6', '7.6-20-04', '8.0'],
'pre-commit': { enabled: true },
regexManagers: [
{
fileMatch: ['^.pre-commit-config.yaml$'],
matchStrings: [" +- '?(?<depName>[^' @=]+)(@|==)(?<currentValue>[^' @=]+)'? # (?<datasource>.+)"],
},
],
packageRules: [
/** Docker images versioning */
{
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ jobs:
- run: echo "${HOME}/.local/bin" >> ${GITHUB_PATH}
- run: python3 -m pip install --user --requirement=ci/requirements.txt

- uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: "pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}\npre-commit-"
- run: pre-commit run --all-files
env:
SKIP: poetry-lock
- run: git diff && false
if: failure()
- name: Checks
run: c2cciutils-checks

Expand Down
87 changes: 87 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,90 @@ repos:
- id: prettier
additional_dependencies:
- [email protected]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.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: 0.3.2
hooks:
- id: copyright
- id: poetry-check
additional_dependencies:
- poetry==1.3.2 # pypi
exclude: ^pyproject.toml$
- id: poetry-lock
additional_dependencies:
- poetry==1.3.2 # pypi
exclude: ^pyproject.toml$
- repo: https://github.com/codespell-project/codespell
rev: v2.2.2
hooks:
- id: codespell
exclude: |-
(?x)(
(.*/)?poetry\.lock
|.github/changelog-generator-cache/.*
)
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.9.0.2
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.20.0
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
- id: check-renovate
additional_dependencies:
- pyjson5==1.6.2 # pypi
- repo: https://github.com/sirwart/ripsecrets
rev: v0.1.5
hooks:
- id: ripsecrets
- repo: https://github.com/PyCQA/autoflake
rev: v2.0.0
hooks:
- id: autoflake
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: pyupgrade
args:
- --py38-plus
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 22.12.0
hooks:
- id: black
ci:
autoupdate_schedule: quarterly
skip:
- copyright
- poetry-check
- poetry-lock
- ripsecrets
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,12 @@ your query string.
- `confd` and `entrypoints.d` are removed, you should replace it by a `volume_from` a configuration image
or an init container.
- The `MS_MAPFILE` has no more default value, was `/etc/mapserver/mapserver.map`.

## Contributing

Install the pre-commit hooks:

```bash
pip install pre-commit
pre-commit install --allow-missing-config
```
3 changes: 0 additions & 3 deletions acceptance_tests/test_wfs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from xml.etree import ElementTree


def test_get_feature(connection):
answer = connection.get_xml(
"?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetFeature&TYPENAME=polygons&featureId=polygons.foo"
Expand Down
10 changes: 7 additions & 3 deletions checkout_release
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ if [ "$#" -ne 1 ]; then
fi

BRANCH=$1
TAG_PREFIX=$(echo $BRANCH | sed -e 's/branch-/rel-/')
TAG_PREFIX=${BRANCH//branch-/rel-}

git fetch --tags
LAST_RELEASE=$(git log --format=%H --tags=$TAG_PREFIX* --no-walk | head -1)
git checkout --detach $LAST_RELEASE
LAST_RELEASE=$(git log --format=%H "--tags=$TAG_PREFIX*" --no-walk | head -1)
if [ -z "$LAST_RELEASE" ]; then
echo "No release found for branch $BRANCH"
else
git checkout --detach "$LAST_RELEASE"
fi

echo
echo "Will build: -----------------------------------------"
Expand Down
1 change: 1 addition & 0 deletions ci/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
c2cciutils[checks,publish]==1.5.0
pre-commit==2.21.0
5 changes: 3 additions & 2 deletions runtime/usr/local/bin/mapserv_wrapper
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/bin/bash
#!/bin/bash -ax

# Add the environment variables that were set when apache was started
# shellcheck source=/dev/null
source /tmp/init_env

# GDAL uses CWD to write temporary files. So we better be in a location writable by www-data.
cd /tmp
cd /tmp || exit 1

if [[ "${MAPSERVER_CATCH_SEGV}" == 1 ]]; then
exec catchsegv /usr/local/bin/mapserv "$@"
Expand Down
2 changes: 1 addition & 1 deletion runtime/usr/local/bin/start-server
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ fi

trap '' WINCH

rm -f $APACHE_RUN_DIR/apache2.pid
rm -f "$APACHE_RUN_DIR/apache2.pid"

exec apache2 -DFOREGROUND
Loading