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

CI updates #568

Merged
merged 3 commits into from
Jan 7, 2025
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/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/camptocamp/tag-publish/0.13.0/tag_publish/schema.json

pypi:
packages:
- {}
dispatch:
- {}
78 changes: 11 additions & 67 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
@@ -1,90 +1,34 @@
{
extends: ['config:base'],
timezone: 'Europe/Zurich',
schedule: 'after 5pm on the first day of the month',
labels: ['dependencies'],
separateMajorMinor: true,
separateMinorPatch: true,
prHourlyLimit: 0,
prConcurrentLimit: 0,
lockFileMaintenance: {
enabled: true,
automerge: true,
schedule: 'after 5pm on the first day of the month',
},
'pre-commit': { enabled: true },
extends: [
'config:base',
'github>camptocamp/gs-renovate-config-preset:base.json5#0.3.3',
'github>camptocamp/gs-renovate-config-preset:ci.json5#0.3.3',
'github>camptocamp/gs-renovate-config-preset:pre-commit.json5#0.3.3',
'github>camptocamp/gs-renovate-config-preset:python.json5#0.3.3',
'github>camptocamp/gs-renovate-config-preset:json-schema.json5#0.3.3',
'github>camptocamp/gs-renovate-config-preset:shellcheck.json5#0.3.3',
],
osvVulnerabilityAlerts: true,
vulnerabilityAlerts: {
schedule: ['at any time'],
automerge: true,
},
regexManagers: [
/** Do updates on pre-commit additional dependencies */
{
fileMatch: ['^\\.pre\\-commit\\-config\\.yaml$'],
matchStrings: [" +- '?(?<depName>[^' @=]+)(@|==)(?<currentValue>[^' @=]+)'? # (?<datasource>.+)"],
},
customManagers: [
/** Do update on the schema present in the ci/config.yaml */
{
fileMatch: ['^ci/config\\.yaml$'],
matchStrings: [
'.*https://raw\\.githubusercontent\\.com/(?<depName>[^\\s]+)/(?<currentValue>[0-9\\.]+)/.*',
],
datasourceTemplate: 'github-tags',
},
/** Python version in actions/setup-python action */
{
fileMatch: ['^\\.github/workflows/.*\\.yaml$'],
matchStrings: [' python-version: [\'"](?<currentValue>[0-9\\.]+)[\'"]'],
datasourceTemplate: 'python-version',
depNameTemplate: 'python',
customType: 'regex',
},
],
packageRules: [
/** Auto merge the dev dependency update */
{
matchDepTypes: ['devDependencies'],
automerge: true,
},
/** Group and auto merge the patch updates */
{
matchUpdateTypes: ['patch'],
groupName: 'all patch versions',
automerge: true,
},
/** Group and auto merge the minor updates */
{
matchUpdateTypes: ['minor'],
groupName: 'all minor versions',
automerge: true,
},
/** Group Poetry packages */
{
matchPackagePrefixes: ['poetry-'],
groupName: 'Poetry',
automerge: true,
matchDepNames: ['poetry', 'pip'],
},
/** Separate pull request for scikit-image */
{
groupName: 'scikit-image',
matchDepNames: ['scikit-image'],
},
/** Support the 4 parts of shellcheck-py version with a v prefix */
{
versioning: 'regex:^v(?<major>\\d+)\\.(?<minor>\\d+)\\.(?<patch>\\d+)\\.(?<build>\\d+)$',
matchDepNames: ['shellcheck-py/shellcheck-py'],
},
/** Group and auto merge the CI dependencies */
{
matchFileNames: ['.github/**', '.pre-commit-config.yaml', 'ci/**'],
groupName: 'CI dependencies',
automerge: true,
},
/** Ungroup Python dependencies */
{
matchDepNames: ['python'],
groupName: 'Python',
},
],
}
18 changes: 10 additions & 8 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ on:
tags:
- '*'

permissions:
contents: write
id-token: write

env:
HAS_SECRETS: ${{ secrets.HAS_SECRETS }}
PYTHON_KEYRING_BACKEND: keyring.backends.null.Keyring
Expand Down Expand Up @@ -37,8 +41,8 @@ jobs:
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
- run: git diff --exit-code --patch > /tmp/pre-commit.patch || true
- run: pre-commit run --all-files --color=always
- run: git diff --exit-code --patch > /tmp/pre-commit.patch; git diff --color; git reset --hard || true
if: failure()
- uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -89,10 +93,8 @@ jobs:
[ "$(python3 --version)" == "$(poetry run python --version)" ]

- run: |
poetry run coverage run --source=deskew --module pytest --durations=0 --verbose --color=yes \
poetry run pytest --durations=0 --verbose --color=yes \
--profile --profile-svg --junitxml=results/test-reports/junit.xml tests
poetry run coverage report
poetry run coverage html --directory=results/coverage

- uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -133,12 +135,12 @@ jobs:
echo "password = ${{ secrets.PYPI_PASSWORD }}" >> ~/.pypirc
if: env.HAS_SECRETS == 'HAS_SECRETS'
- name: Publish
run: c2cciutils-publish
run: tag-publish
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
GITHUB_TOKEN: ${{ secrets.TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: env.HAS_SECRETS == 'HAS_SECRETS'
- run: git diff --exit-code --patch > /tmp/dpkg-versions.patch || true
- run: git diff --exit-code --patch > /tmp/dpkg-versions.patch; git diff --color; git reset --hard || true
if: failure()
- uses: actions/upload-artifact@v4
with:
Expand Down
46 changes: 12 additions & 34 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ repos:
hooks:
- id: copyright
- id: workflows-require-timeout
- id: poetry-check
additional_dependencies:
- poetry==1.8.5 # pypi
- id: poetry-lock
additional_dependencies:
- poetry==1.8.5 # pypi
Expand Down Expand Up @@ -49,9 +46,6 @@ repos:
rev: 0.30.0
hooks:
- id: check-github-workflows
- id: check-renovate
additional_dependencies:
- pyjson5==1.6.7 # pypi
- id: check-github-actions
- id: check-jsonschema
name: Check GitHub Workflows set timeout-minutes
Expand All @@ -65,43 +59,27 @@ repos:
rev: v0.1.8
hooks:
- id: ripsecrets
- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
exclude: README\.md
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/PyCQA/autoflake
rev: v2.3.1
hooks:
- id: autoflake
- repo: https://github.com/asottile/pyupgrade
rev: v3.19.1
hooks:
- id: pyupgrade
args:
- --py39-plus
- repo: https://github.com/PyCQA/prospector
rev: v1.13.3
hooks:
- id: prospector
args:
- --tool=pydocstyle
- --tool=ruff
- --die-on-tool-error
- --output-format=pylint
additional_dependencies:
- prospector-profile-duplicated==1.10.0 # pypi
- repo: https://github.com/sbrunner/jsonschema-validator
rev: 1.0.0
hooks:
- id: jsonschema-validator
files: |-
(?x)^(
ci/config\.yaml
)$
- prospector-profile-utils==1.14.1 # pypi
- ruff==0.7.3 # pypi
- repo: https://github.com/renovatebot/pre-commit-hooks
rev: 39.86.3
hooks:
- id: renovate-config-validator
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.1
hooks:
- id: ruff-format
- repo: https://github.com/sbrunner/python-versions-hook
rev: 0.8.0
hooks:
- id: python-versions
38 changes: 9 additions & 29 deletions .prospector.yaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,14 @@
inherits:
- utils:base
- utils:no-design-checks
- utils:fix
- utils:unsafe
- duplicated
strictness: veryhigh
max-line-length: 110
doc-warnings: true

pylint:
disable:
- too-many-arguments
- too-many-statements

pycodestyle:
disable:
- E501 # line too long
- E722 # do not use bare 'except'

pydocstyle:
disable:
- D102 # Missing docstring in public method
- D104 # Missing docstring in public package
- D212 # Multi-line docstring summary should start at the first line
- D202 # No blank lines allowed after function docstring

bandit:
run: true

mypy:
run: true

pyroma:
run: true
options:
python-version: '3.10'

mccabe:
run: false
ruff:
options:
target-version: py310
3 changes: 0 additions & 3 deletions ci/config.yaml

This file was deleted.

1 change: 1 addition & 0 deletions ci/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ poetry-plugin-export==1.8.0
importlib-metadata<8.5.1
certifi>=2024.7.4 # not directly required, pinned by Snyk to avoid a vulnerability
zipp>=3.19.1 # not directly required, pinned by Snyk to avoid a vulnerability
tag-publish==0.13.0
12 changes: 6 additions & 6 deletions deskew/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import subprocess # nosec
import tempfile
import warnings
from typing import TYPE_CHECKING, Any, Optional
from typing import TYPE_CHECKING, Any

import matplotlib.axes
import matplotlib.projections.polar
Expand Down Expand Up @@ -42,13 +42,13 @@ def determine_skew_dev(
"""Calculate skew angle."""

num_angles = round(np.pi / min_deviation)
imagergb = rgba2rgb(image) if len(image.shape) == 3 and image.shape[2] == 4 else image
imagergb = rgba2rgb(image) if len(image.shape) == 3 and image.shape[2] == 4 else image # type: ignore[no-untyped-call]
img = rgb2gray(imagergb) if len(imagergb.shape) == 3 else imagergb
edges = canny(img, sigma=sigma)
out, angles, distances = hough_line(edges, np.linspace(-np.pi / 2, np.pi / 2, num_angles, endpoint=False))
edges = canny(img, sigma=sigma) # type: ignore[no-untyped-call]
out, angles, distances = hough_line(edges, np.linspace(-np.pi / 2, np.pi / 2, num_angles, endpoint=False)) # type: ignore[no-untyped-call]
hough_line_out = (out, angles, distances)

hspace, angles_peaks, dists = hough_line_peaks(
hspace, angles_peaks, dists = hough_line_peaks( # type: ignore[no-untyped-call]
out, angles, distances, num_peaks=num_peaks, threshold=0.05 * np.max(out)
)
hough_line_peaks_out = (hspace, angles_peaks, dists)
Expand Down Expand Up @@ -341,7 +341,7 @@ def determine_skew(
"""
if num_angles is not None:
min_deviation = 180 / num_angles
warnings.warn("num_angles is deprecated, please use min_deviation", DeprecationWarning)
warnings.warn("num_angles is deprecated, please use min_deviation", DeprecationWarning, stacklevel=2)

angle, _ = determine_skew_dev(
image,
Expand Down
4 changes: 2 additions & 2 deletions deskew/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ def main() -> None:
print("Wrong background color, should be r,g,b")
sys.exit(1)

rotated = rotate(image, angle, resize=True, cval=-1) * 255
rotated = rotate(image, angle, resize=True, cval=-1) * 255 # type: ignore[no-untyped-call]
pos = np.where(rotated == -255)
if len(image.shape) == 2:
rotated[pos[0], pos[1]] = int(round(np.mean(background)))
else:
rotated[pos[0], pos[1], :] = background
else:
rotated = rotate(image, angle, resize=True) * 255
rotated = rotate(image, angle, resize=True) * 255 # type: ignore[no-untyped-call]
io.imsave(options.output, rotated.astype(np.uint8))


Expand Down
Loading
Loading