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

Incorporate ruff linter into CI pipeline #2311

Merged
merged 2 commits into from
Oct 14, 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
9 changes: 0 additions & 9 deletions .ci/scripts/extra_linting.sh

This file was deleted.

13 changes: 4 additions & 9 deletions .github/workflows/ci_full.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
---
name: galaxy_ng/ci
on:
pull_request:
branches: ['**']
push:
branches: ['**']
- push
- pull_request

jobs:

Expand Down Expand Up @@ -44,11 +42,8 @@ jobs:
- name: Install requirements
run: pip3 install -r lint_requirements.txt

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

- name: Check manifest
run: check-manifest
rochacbruno marked this conversation as resolved.
Show resolved Hide resolved
- name: Run linters
run: make lint

- name: Check for pulpcore imports outside of pulpcore.plugin
run: sh .ci/scripts/check_pulpcore_imports.sh
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ requirements/pip-upgrade-all: ## Update based on setup.py and *.in files, an
lint: ## Lint the code
check-manifest
flake8 --config flake8.cfg
ruff check .

.PHONY: fmt
fmt: ## Format the code using Darker
Expand Down
2 changes: 1 addition & 1 deletion flake8.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ exclude =
.ci/scripts/*,
.github/workflows/scripts/*,
.venv/*,
./galaxy_ng/_vendor/automated_logging/*,
./galaxy_ng/_vendor/*,
.tox/*,

ignore = BLK,W503,Q000,D,D100,D101,D102,D103,D104,D105,D106,D107,D200,D401,D402,E203
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def create_inbound_repo_per_namespace(apps, schema_editor):
name=name,
pulp_type='ansible.ansible',
)
distro = AnsibleDistribution.objects.using(db_alias).create(
AnsibleDistribution.objects.using(db_alias).create(
name=name,
base_path=name,
repository=repo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from django.db import migrations, models
import django.db.models.deletion
import django_lifecycle.mixins
import galaxy_ng.app.access_control.mixins


Expand Down
11 changes: 4 additions & 7 deletions galaxy_ng/app/migrations/0017_populate_repos_and_remotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,35 +62,32 @@ def populate_initial_repos(apps, schema_editor):
db_alias = schema_editor.connection.alias

AnsibleRepository = apps.get_model('ansible', 'AnsibleRepository')

AnsibleDistribution = apps.get_model('ansible', 'AnsibleDistribution')

CollectionRemote = apps.get_model('ansible', 'CollectionRemote')

RepositoryVersion = apps.get_model('core', 'RepositoryVersion')

for repo_data in REPOSITORIES:

remote = repo_data.pop("remote", None)
if remote is not None:
remote, _ = CollectionRemote.objects.get_or_create(
remote, _ = CollectionRemote.objects.using(db_alias).get_or_create(
name=remote["name"], defaults=remote
)
repo_data["remote"] = remote

repository, _ = AnsibleRepository.objects.get_or_create(
repository, _ = AnsibleRepository.objects.using(db_alias).get_or_create(
name=repo_data["name"],
defaults=repo_data
)

if not RepositoryVersion.objects.filter(repository__name=repository.name):
RepositoryVersion.objects.create(
RepositoryVersion.objects.using(db_alias).create(
repository=repository,
number=0,
complete=True
)

AnsibleDistribution.objects.get_or_create(
AnsibleDistribution.objects.using(db_alias).get_or_create(
base_path=repository.name,
defaults={
"name": repository.name,
Expand Down
1 change: 0 additions & 1 deletion galaxy_ng/app/migrations/0034_remove_inbound_repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ def remove_inbound_repos(apps, schema_editor):

AnsibleDistribution = apps.get_model('ansible', 'AnsibleDistribution')
AnsibleRepository = apps.get_model('ansible', 'AnsibleRepository')
RepositoryContent = apps.get_model('core', 'RepositoryContent')

repos = AnsibleRepository.objects.filter(name__startswith="inbound-")

Expand Down
1 change: 0 additions & 1 deletion galaxy_ng/app/migrations/0036_repository_labels.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Generated by Django 3.2.18 on 2023-02-15 13:52

import django.core.validators
from django.db import migrations
from django.db.models import Q

Expand Down
4 changes: 1 addition & 3 deletions galaxy_ng/app/migrations/0038_namespace_sync.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import django.core.validators
from django.db import migrations
import hashlib
import json

Expand Down Expand Up @@ -36,7 +34,7 @@ def add_pulp_ansible_namespace_metadata_objects(apps, schema_editor):

for old_ns in Namespace.objects.all():
new_ns = AnsibleNamespace.objects.create(name=old_ns.name)
links = {l.name: l.url for l in old_ns.links.all()}
links = {link.name: link.url for link in old_ns.links.all()}

metadata = {
"company": old_ns.company,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import django.core.validators
from django.db import migrations
import hashlib
import json

from django.db import migrations, models
import django.db.models.deletion


def set_collection_remote_type(apps, schema_editor):
Expand Down
4 changes: 1 addition & 3 deletions galaxy_ng/app/migrations/0053_wait_for_dab_rbac.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Generated by Django 4.2.10 on 2024-02-15 17:33

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
from django.db import migrations


class Migration(migrations.Migration):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import logging
import time

from django.db import migrations

Expand Down
1 change: 0 additions & 1 deletion galaxy_ng/app/migrations/_dab_rbac.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import logging

from django.apps import apps as global_apps
from django.contrib.contenttypes.models import ContentType
from rest_framework.exceptions import ValidationError

from ansible_base.rbac.management import create_dab_permissions
Expand Down
2 changes: 1 addition & 1 deletion lint_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# python packages handy for developers, but not required by pulp
check-manifest
flake8
yamllint
ruff
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,9 @@ omit = [
"galaxy_ng/_vendor/*",
"galaxy_ng/tests/*",
]

[tool.ruff]
line-length = 100
extend-exclude = [
"galaxy_ng/_vendor/",
]
Loading