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

Use PDM & Ruff instead of Poetry+Black+Flake8+isort #82

Merged
merged 5 commits into from
Jul 8, 2024
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
27 changes: 27 additions & 0 deletions .cruft.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"template": "https://github.com/getpelican/cookiecutter-pelican-plugin",
"commit": "b4b9b4f83b624cfd7728a3f1527d272be28ee916",
"checkout": null,
"context": {
"cookiecutter": {
"plugin_name": "Image Process",
"repo_name": "image-process",
"package_name": "image_process",
"distribution_name": "pelican-image-process",
"version": "3.0.4",
"description": "Pelican plugin that automates image processing.",
"authors": "{name = \"Pelican Dev Team\", email = \"[email protected]\"}",
"keywords": "\"pelican\", \"plugin\", \"image\", \"responsive\", \"optimization\"",
"readme": "README.md",
"contributing": "CONTRIBUTING.md",
"license": "GNU Affero General Public License v3|AGPL-3.0",
"repo_url": "https://github.com/pelican-plugins/image-process",
"dev_status": "5 - Production/Stable",
"tests_exist": true,
"python_version": ">=3.8.1,<4.0",
"pelican_version": ">=4.5",
"_template": "https://github.com/getpelican/cookiecutter-pelican-plugin"
}
},
"directory": null
}
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
custom: https://donate.getpelican.com
github: justinmayer
liberapay: pelican
107 changes: 48 additions & 59 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,101 +5,90 @@ on: [push, pull_request]
env:
PYTEST_ADDOPTS: "--color=yes"

permissions:
contents: read

jobs:
test:
name: Test - ${{ matrix.python-version }}
name: Test - Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Install Exiftool
run: sudo apt install libimage-exiftool-perl
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2

- name: Set up Python ${{ matrix.python-version }} & PDM
uses: pdm-project/setup-pdm@v4
with:
python-version: ${{ matrix.python-version }}
- name: Set up Pip cache
uses: actions/cache@v2
id: pip-cache
with:
path: ~/.cache/pip
key: pip-${{ hashFiles('**/pyproject.toml') }}
- name: Upgrade Pip
run: python -m pip install --upgrade pip
- name: Install Poetry
run: python -m pip install poetry
- name: Set up Poetry cache
uses: actions/cache@v2
id: poetry-cache
with:
path: ~/.cache/pypoetry/virtualenvs
key: poetry-${{ hashFiles('**/poetry.lock') }}
cache: true
cache-dependency-path: ./pyproject.toml

- name: Install dependencies
run: |
poetry run pip install --upgrade pip
poetry install
- name: Run tests
run: poetry run invoke tests
run: pdm install

- name: Run tests
run: pdm run invoke tests

lint:
name: Lint
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.9"
- name: Set Poetry cache
uses: actions/cache@v2
id: poetry-cache
- uses: actions/checkout@v4

- name: Set up Python & PDM
uses: pdm-project/setup-pdm@v4
with:
path: ~/.cache/pypoetry/virtualenvs
key: poetry-${{ hashFiles('**/poetry.lock') }}
- name: Upgrade Pip
run: python -m pip install --upgrade pip
- name: Install Poetry
run: python -m pip install poetry
python-version: "3.10"

- name: Install dependencies
run: |
poetry run pip install --upgrade pip
poetry install
- name: Run linters
run: poetry run invoke lint
run: pdm install

- name: Run linters
run: pdm run invoke lint --diff

deploy:
name: Deploy
environment: Deployment
needs: [test, lint]
runs-on: ubuntu-latest
if: ${{ github.ref=='refs/heads/main' && github.event_name!='pull_request' }}
if: github.ref=='refs/heads/main' && github.event_name!='pull_request'

permissions:
contents: write
id-token: write

steps:
- uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.9"
python-version: "3.10"

- name: Check release
id: check_release
run: |
python -m pip install --upgrade pip
python -m pip install poetry githubrelease httpx==0.16.1 autopub
echo "##[set-output name=release;]$(autopub check)"
python -m pip install autopub httpx
python -m pip install https://github.com/scikit-build/github-release/archive/master.zip
autopub check

- name: Publish
if: ${{ steps.check_release.outputs.release=='' }}
if: ${{ steps.check_release.outputs.autopub_release=='true' }}
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git remote set-url origin https://[email protected]/${{ github.repository }}
autopub prepare
poetry build
autopub commit
autopub build
autopub githubrelease
poetry publish -u __token__ -p $PYPI_PASSWORD

- name: Upload package to PyPI
if: ${{ steps.check_release.outputs.autopub_release=='true' }}
uses: pypa/gh-action-pypi-publish@release/v1
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
poetry.lock
.pdm-python
pdm.lock
34 changes: 6 additions & 28 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ci:
# See https://pre-commit.com/hooks.html for info on hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.6.0
hooks:
- id: check-added-large-files
- id: check-ast
Expand All @@ -20,31 +20,9 @@ repos:
- id: forbid-new-submodules
- id: trailing-whitespace

- repo: https://github.com/psf/black
rev: 23.3.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.1
hooks:
- id: black

- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
args: [--max-line-length=88]
language_version: python3

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort

- repo: https://github.com/asottile/pyupgrade
rev: v3.8.0
hooks:
- id: pyupgrade
args: [--py38-plus]

- repo: https://github.com/hakancelikdev/unimport
rev: 0.16.0
hooks:
- id: unimport
args: [--remove, --include-star-import]
- id: ruff
- id: ruff-format
args: ["--check"]
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

[![Build Status](https://img.shields.io/github/actions/workflow/status/pelican-plugins/image-process/main.yml?branch=main)](https://github.com/pelican-plugins/image-process/actions)
[![PyPI Version](https://img.shields.io/pypi/v/pelican-image-process)](https://pypi.org/project/pelican-image-process/)
[![Downloads](https://img.shields.io/pypi/dm/pelican-image-process)](https://pypi.org/project/pelican-image-process/)
![License](https://img.shields.io/badge/license-AGPL--3.0-blue)

*Image Process* is a plugin for [Pelican](https://getpelican.com),
Expand All @@ -27,6 +28,12 @@ will also install the required dependencies automatically.
python -m pip install pelican-image-process
```

As long as you have not explicitly added a `PLUGINS` setting to your Pelican
settings file, then the newly-installed plugin should be automatically detected
and enabled. Otherwise, you must add `image_process` to your existing `PLUGINS`
list. For more information, please see the documentation regarding
[How to Use Plugins](https://docs.getpelican.com/en/latest/plugins.html#how-to-use-plugins).

You will then need to configure your desired transformations (see *Usage*
below) and add the appropriate class to images you want processed.

Expand Down
2 changes: 1 addition & 1 deletion pelican/plugins/image_process/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .image_process import * # NOQA
from .image_process import * # noqa: F403,PGH004,RUF100
Loading