Skip to content

Commit

Permalink
v3.2.0 (#129)
Browse files Browse the repository at this point in the history
* update fullctl dependencies

* use prep-release

* updates

* update gitignore

* poetry lock

* pydantic to v2

* ruff fix/format

* don't fail on linting

* use semver version plugin

* Version 3.2.0-rc.1

* Version 3.2.0-rc.2

* fix trial check if no resolver match set

* ruff config and linting

* poetry lock

* Version 3.2.0-rc.3

* poetry lock

* Version 3.2.0-rc.4

* add slug to service bridge serializer for internet exchange

* poetry lock

* Version 3.2.0-rc.5

* poetry lock

* Version 3.2.0-rc.6

* Version 3.2.0

---------

Co-authored-by: Samsul <samsulhadikediri@gmail.com>
Co-authored-by: Stefan Pratter <stefan@20c.com>
  • Loading branch information
3 people authored Mar 7, 2024
1 parent a6ec547 commit b3735aa
Show file tree
Hide file tree
Showing 21 changed files with 1,121 additions and 604 deletions.
11 changes: 4 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,19 @@ jobs:
linting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Install virtualenv from poetry
uses: 20c/workflows/poetry@v1
# poetry run pre-commit run --all-files
- name: Run linters
run: |
poetry run pre-commit run --all-files
poetry run pre-commit run --all-files
test:
needs: linting
# needs: linting
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Copy .env file
run: cp Ctl/dev/example.env Ctl/dev/.env
- name: Launch database container
Expand All @@ -33,5 +32,3 @@ jobs:
uses: codecov/codecov-action@v3
with:
file: ./src/coverage.xml
# until random codcov errors are fixed
# fail_ci_if_error: true
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
*.sqlite3
*.sql
*.egg-info
.coverage
.pytest-cache
coverage.xml
Ctl/.state/
Ctl/dev/.env
build/
40 changes: 14 additions & 26 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,40 +1,28 @@
fail_fast: false
exclude: |
(?x)^(
tests/data/.*
)$
(?x)^(
tests/data/.*
)$
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
rev: v4.5.0
hooks:
- id: check-yaml
- id: trailing-whitespace
- repo: local
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.14
hooks:
- id: system
name: isort
entry: poetry run isort .
language: system
pass_filenames: false
# Run the linter.
- id: ruff
args: [--fix]
# Run the formatter.
- id: ruff-format
- repo: local
hooks:
- id: pyupgrade
- id: pyupgrade
name: pyupgrade
entry: poetry run pyupgrade --py36-plus
entry: poetry run pyupgrade --py39-plus
language: python
types: [python]
pass_filenames: true
- repo: local
hooks:
- id: system
name: Black
entry: poetry run black .
language: system
pass_filenames: false
- repo: local
hooks:
- id: system
name: flake8
entry: poetry run flake8 .
language: system
pass_filenames: false
2 changes: 1 addition & 1 deletion Ctl/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.0
3.2.0
2 changes: 1 addition & 1 deletion Ctl/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ctl:
- type: changelog
name: changelog

- type: version
- type: semver2
name: version
config:
repository: git
Expand Down
3 changes: 0 additions & 3 deletions Ctl/requirements.txt

This file was deleted.

1,508 changes: 1,025 additions & 483 deletions poetry.lock

Large diffs are not rendered by default.

48 changes: 33 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.poetry]
name = "ixctl"
repository = "https://github.com/fullctl/ixctl"
version = "3.1.0"
version = "3.2.0"
description = "ix control"
authors = ["20C <code@20c.com>"]
license = "Apache-2.0"
Expand All @@ -21,30 +21,33 @@ ixctl = "ixctl.cli:main"
[tool.poetry.dependencies]
python = "^3.9"
fullctl = { git = "https://github.com/fullctl/fullctl.git", branch = "prep-release" }
arouteserver = "^1.17"
pydantic = "^1.10.2"

arouteserver = ">=1.17"
pydantic = ">=1.10.2"

[tool.poetry.dev-dependencies]
django = ">=2.2"
django-handleref = ">=0.5"
djangorestframework = ">=3.11"

# testing
coverage = ">=5"
pytest = ">=6"
pytest-django = ">=3.8"
pytest-cov = "*"
requests-mock = ">=1.11"
tox = ">=3.23"

# linting
# bandit = ">=1.6.2"
black = ">=20"
isort = ">=5.7"
flake8 = ">=3.8"
bandit = ">=1.6.2"
mypy = ">=0.950"
pre-commit = ">=2.13"
pyupgrade = ">=2.19"
ruff = ">=0.1"

# docs
markdown = "*"
markdown-include = ">=0.5,<1"
mkdocs = "^1.2.3"
mkdocs = ">=1.2.3"

# ctl
ctl = ">=1"
Expand All @@ -53,13 +56,28 @@ tmpl = ">=1"

[tool.poetry.group.tasks]
optional = true

[tool.poetry.group.tasks.dependencies]

[tool.isort]
profile = "black"
multi_line_output = 3
[tool.poetry.plugins."markdown.extensions"]
pymdgen = "pymdgen.md:Extension"

[tool.ruff]
# Same as Black.
line-length = 88
indent-width = 4

[tool.ruff.lint.per-file-ignores]
# E402 = module import not at top level
"src/ixctl/wsgi.py" = ["E402"]

# F821 = undefined variable
"src/ixctl/settings/__init__.py" = ["F821"]
"src/ixctl/settings/dev.py" = ["F821"]

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.ruff.lint]
# Enable the isort rules.
extend-select = ["I"]
5 changes: 4 additions & 1 deletion src/django_ixctl/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ def trial_available(request):

# retrieve ix_tag from request url parse information

ix_tag = request.resolver_match.kwargs.get("ix_tag")
try:
ix_tag = request.resolver_match.kwargs.get("ix_tag")
except AttributeError:
ix_tag = None

if ix_tag is None:
return {"trial_available": False}
Expand Down
8 changes: 6 additions & 2 deletions src/django_ixctl/models/ixctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
from datetime import datetime
from secrets import token_urlsafe

from pydantic.utils import deep_update
try:
from pydantic.utils import deep_update
except ImportError:
from pydantic.v1.utils import deep_update


try:
from yaml import CDumper as Dumper
from yaml import CLoader as Loader
except ImportError:
from yaml import Loader, Dumper
from yaml import Dumper, Loader

import fullctl.service_bridge.devicectl as devicectl
import fullctl.service_bridge.pdbctl as pdbctl
Expand Down
2 changes: 1 addition & 1 deletion src/django_ixctl/rest/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def __init__(self, *args, **kwargs):
instance_class=models.Instance,
explicit=kwargs.pop("explicit", False),
*args,
**kwargs
**kwargs,
)
if "namespace" not in kwargs:
self.namespace += ["ixctl"]
2 changes: 1 addition & 1 deletion src/django_ixctl/rest/serializers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from rest_framework import serializers


Expand Down
2 changes: 1 addition & 1 deletion src/django_ixctl/rest/serializers/ixctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import fullctl.service_bridge.pdbctl as pdbctl
import yaml
from django.core.validators import RegexValidator
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django_inet.rest import IPAddressField
from fullctl.django.models.concrete.tasks import TaskLimitError
from fullctl.django.rest.decorators import serializer_registry
Expand Down
1 change: 1 addition & 0 deletions src/django_ixctl/rest/serializers/service_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Meta:
fields = [
"org_id",
"id",
"slug",
"pdb_id",
"name",
"verified",
Expand Down
4 changes: 3 additions & 1 deletion src/django_ixctl/rest/views/ixctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,9 @@ def list(self, request, org, instance, *args, **kwargs):
return Response(serializer.data)

@action(
detail=False, methods=["GET"], url_path=r"presence/(?P<asn>[\d]+)" # noqa: W605
detail=False,
methods=["GET"],
url_path=r"presence/(?P<asn>[\d]+)", # noqa: W605
)
@grainy_endpoint(namespace="net.{request.org.permission_id}.{asn}")
@load_object("net", models.Network, asn="asn", instance="instance")
Expand Down
4 changes: 1 addition & 3 deletions src/tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
def reset_auto_fields():
from django.core.management.color import no_style
from django.db import connection

from django_ixctl.models import Organization

sequence_sql = connection.ops.sequence_reset_sql(no_style(), [Organization])
Expand All @@ -23,12 +22,11 @@ def reset_auto_fields():
class AccountObjects:
def __init__(self, handle):
from django.contrib.auth import get_user_model
from django_ixctl.models import Organization
from fullctl.django.auth import permissions
from fullctl.django.models.concrete import OrganizationUser
from rest_framework.test import APIClient

from django_ixctl.models import Organization

reset_auto_fields()

self.user = user = get_user_model().objects.create_user(
Expand Down
5 changes: 2 additions & 3 deletions src/tests/test_ixctl_api.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import json

from django.urls import reverse

import django_ixctl.models as models
from django.urls import reverse


def test_ix_import_peeringdb(db, pdb_data, account_objects):
Expand Down Expand Up @@ -492,7 +491,7 @@ def test_update_routeserver(db, pdb_data, account_objects):

def test_retrieve_routeserverconfig(db, pdb_data, account_objects):
rs = account_objects.routeserver
routeserver_config = rs.routeserver_config
rs.routeserver_config
# routeserver_config.generate()
ix = account_objects.ix
client = account_objects.api_client
Expand Down
4 changes: 1 addition & 3 deletions src/tests/test_ixctl_management.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import django_ixctl.models as models
import pytest
from django.conf import settings
from django.core.management import call_command

import django_ixctl.models as models


@pytest.mark.skip
def test_routeserver_config_generate(db, pdb_data, account_objects, capsys):
Expand Down
4 changes: 1 addition & 3 deletions src/tests/test_ixctl_models.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import ipaddress
import json
import os

import django_ixctl.models as models
import pytest
from django.core.exceptions import ValidationError
from django.urls import reverse
from fullctl.service_bridge.pdbctl import NetworkIXLan

import django_ixctl.models as models


def test_instance(db, pdb_data, account_objects):
instance = account_objects.ixctl_instance
Expand Down
21 changes: 1 addition & 20 deletions src/tests/test_ixctl_peeringdb.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import pytest
from fullctl.service_bridge.pdbctl import InternetExchange, Network

import django_ixctl.models as models
from django_ixctl import peeringdb
from fullctl.service_bridge.pdbctl import InternetExchange, Network


def test_import_exchange(db, pdb_data, account_objects):
Expand All @@ -14,23 +12,6 @@ def test_import_exchange(db, pdb_data, account_objects):
assert ix.pdb_id == pdb_ix.id


@pytest.mark.skip
def test_import_exchanges(db, pdb_data, account_objects):
pdb_org = pdb_models.Organization.objects.filter(id=10843).first()
exchanges = peeringdb.import_exchanges(pdb_org, account_objects.ixctl_instance)
assert len(exchanges) == pdb_org.ix_set.count()
for ix in exchanges:
assert pdb_org.ix_set.filter(name=ix.name).exists()
assert pdb_org.ix_set.filter(id=ix.pdb_id).exists()


@pytest.mark.skip
def test_import_org(db, pdb_data, account_objects):
pdb_org = pdb_models.Organization.objects.filter(id=10843).first()
org = peeringdb.import_org(pdb_org, account_objects.ixctl_instance)
assert len(org["exchanges"]) == pdb_org.ix_set.count()


def test_get_as_set(db, pdb_data, account_objects):
pdb_net = Network().object(20)
pdb_net.irr_as_set = "foo::bar"
Expand Down
Loading

0 comments on commit b3735aa

Please sign in to comment.