Skip to content
Draft
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
5 changes: 5 additions & 0 deletions .ci/scripts/check_bump.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

set -eux
bump-my-version bump release --dry-run --allow-dirty
bump-my-version show-bump
12 changes: 9 additions & 3 deletions .ci/scripts/check_gettext.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@
# make sure this script runs at the repo root
cd "$(dirname "$(realpath -e "$0")")"/../..

set -uv
set -u

MATCHES=$(grep -n -r --include \*.py "_(f")
if [ $# -gt 0 ]; then
MATCHES=$(grep -n "_(f" "$@" 2>/dev/null || true)
else
# fallback to original behavior if no files are provided
set -v
MATCHES=$(grep -n -r --include \*.py "_(f")
fi

if [ $? -ne 1 ]; then
if [ -n "$MATCHES" ]; then
printf "\nERROR: Detected mix of f-strings and gettext:\n"
echo "$MATCHES"
exit 1
Expand Down
63 changes: 20 additions & 43 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,49 +23,26 @@ jobs:
with:
fetch-depth: 1
path: "pulpcore"

- uses: "actions/setup-python@v5"
with:
python-version: "3.11"

- name: "Install python dependencies"
run: |
echo ::group::PYDEPS
pip install -r lint_requirements.txt
echo ::endgroup::

- name: "Lint workflow files"
run: |
yamllint -s -d '{extends: relaxed, rules: {line-length: disable}}' .github/workflows

- name: "Verify bump version config"
run: |
bump-my-version bump --dry-run release
bump-my-version show-bump

# run black separately from flake8 to get a diff
- name: "Run black"
run: |
black --version
black --check --diff .

# Lint code.
- name: "Run flake8"
run: |
flake8

- name: "Run extra lint checks"
run: |
[ ! -x .ci/scripts/extra_linting.sh ] || .ci/scripts/extra_linting.sh

- name: "Check for any files unintentionally left out of MANIFEST.in"
run: |
check-manifest

- name: "Verify requirements files"
run: |
python .ci/scripts/check_requirements.py

- name: "Check for common gettext problems"
run: |
sh .ci/scripts/check_gettext.sh
# cache example from:
# https://pre-commit.com/#github-actions-example
- name: set PY
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
- uses: actions/cache@v5
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Install pre-commit
run: |
pip install pre-commit
- name: Run pre-commit
shell: "bash"
env:
PY_COLORS: "1"
FORCE_COLOR: "1"
PRE_COMMIT_COLOR: "always"
TERM: "xterm-256color"
run: |
pre-commit run --all-files -v
54 changes: 54 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: 'https://github.com/pre-commit/pre-commit-hooks'
rev: v3.2.0
hooks:
- id: check-yaml
- id: check-added-large-files
- repo: 'https://github.com/pycqa/flake8'
rev: 7.3.0
hooks:
- id: flake8
args: ["--config", ".flake8"]
language_version: '3.11'
- repo: 'https://github.com/psf/black'
rev: 24.3.0
hooks:
- id: black
language_version: "3.11"
pass_filenames: false
args: ["--check", "."]
additional_dependencies: ["flake8-black"]
- repo: 'https://github.com/adrienverge/yamllint'
rev: v1.37.1
hooks:
- id: yamllint
- repo: 'https://github.com/mgedmin/check-manifest'
rev: "0.51"
hooks:
- id: check-manifest
- repo: local
hooks:
- id: check-bump
name: check-bump
language: python
entry: .ci/scripts/check_bump.sh
pass_filenames: false
additional_dependencies: ["bump-my-version"]
- id: check-requirements
name: check-requirements
language: python
entry: python .ci/scripts/check_requirements.py
pass_filenames: false
additional_dependencies: ["packaging"]
- id: check-gettext
name: check-gettext
language: unsupported_script
types: [python]
entry: .ci/scripts/check_gettext.sh
- id: extra-lint
name: extra-lint
language: unsupported
entry: sh -c "[ ! -x .ci/scripts/extra_linting.sh ] || .ci/scripts/extra_linting.sh"
pass_filenames: false
4 changes: 4 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
extends: relaxed

rules:
line-length: disable
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ ignore = [
".github/**",
"lint_requirements.txt",
".flake8",
".yamllint.yaml",
".pre-commit-config.yaml",
"pulpcore/tests/functional/assets/**",
]

Expand Down
Loading