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
2 changes: 1 addition & 1 deletion .ci/ansible/build_container.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@

- name: "Clean image cache"
docker_prune:
images : true
images: true
...
12 changes: 12 additions & 0 deletions .ci/scripts/check_bump.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

# WARNING: DO NOT EDIT!
#
# This file was generated by plugin_template, and is managed by it. Please use
# './plugin-template --github pulpcore' to update this file.
#
# For more info visit https://github.com/pulp/plugin_template

set -eux
bump-my-version bump release --dry-run --allow-dirty
bump-my-version show-bump
21 changes: 17 additions & 4 deletions .ci/scripts/check_gettext.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,25 @@
# 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")
PATTERN="_(f[\"\']"

if [ $? -ne 1 ]; then
if [ $# -gt 0 ]; then
# check files provided via arguments
RESULT=$(grep -n "$PATTERN" "$@")
EXIT_CODE=$?
else
# original behavior (check all)
set -v
RESULT=$(grep -n -r --include \*.py "$PATTERN")
EXIT_CODE=$?
fi

# grep returns 1 if it doesn't find a match
if [ $EXIT_CODE -eq 0 ]; then
printf "\nERROR: Detected mix of f-strings and gettext:\n"
echo "$MATCHES"
echo "$RESULT"
exit 1
fi
exit 0
53 changes: 17 additions & 36 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,41 +31,22 @@ jobs:
- name: "Install python dependencies"
run: |
echo ::group::PYDEPS
pip install -r lint_requirements.txt
pip install pre-commit
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: 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
70 changes: 70 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# WARNING: DO NOT EDIT!
#
# This file was generated by plugin_template, and is managed by it. Please use
# './plugin-template --github pulpcore' to update this file.
#
# For more info visit https://github.com/pulp/plugin_template

# 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: ["--extend-exclude", ".*venv.*", "."]
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

# Custom checks
- 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
types: [python]
entry: sh -c "[ ! -x .ci/scripts/extra_linting.sh ] || .ci/scripts/extra_linting.sh"
10 changes: 10 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# WARNING: DO NOT EDIT!
#
# This file was generated by plugin_template, and is managed by it. Please use
# './plugin-template --github pulpcore' to update this file.
#
# For more info visit https://github.com/pulp/plugin_template

extends: relaxed
rules:
line-length: disable
11 changes: 7 additions & 4 deletions lint_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
#
# For more info visit https://github.com/pulp/plugin_template

# CI linting uses pre-commit
# keeping here for compatibility
black==24.3.0
bump-my-version
check-manifest
flake8
check-manifest==0.51
flake8==7.3.0
yamllint==1.37.1

flake8-black
bump-my-version
packaging
yamllint
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ ignore = [
"lint_requirements.txt",
".flake8",
"pulpcore/tests/functional/assets/**",
".yamllint.yaml",
".pre-commit-config.yaml",
]

[tool.bumpversion]
Expand Down
Loading