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

Third attempt to explore CI failures #407

Closed
wants to merge 50 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
d43db6f
Add django-filters to INSTALLED_APPS
wkirdp Sep 15, 2023
ae493dc
Add a BillingProjectList test to test fillters
wkirdp Sep 19, 2023
6569f96
Added more tests for BillingProjectList filter view
wkirdp Sep 19, 2023
3c885ea
Rename BillingProjectFilter to BillingProjectListFilter
wkirdp Sep 19, 2023
9abb3d8
reorder tests so they are consistent
wkirdp Sep 20, 2023
3e5844b
Define filter for MangagedGroupList
wkirdp Sep 20, 2023
73e4db7
Define filter for WorkspaceList
wkirdp Sep 20, 2023
a507fb4
Define filter for AccountList
wkirdp Sep 20, 2023
6c420c6
Add django-filters to base requirements
wkirdp Sep 20, 2023
a600deb
Add django-filter module
wkirdp Sep 21, 2023
3d9315c
Add a custom filter form to display inputs in a single row
amstilp Sep 22, 2023
a457d54
requires a lower version of django-filter
wkirdp Sep 22, 2023
1c94b67
Modify tests: test case sensitive and case insensitive seperately.
wkirdp Oct 6, 2023
5944844
Streamline filter tests
amstilp Oct 11, 2023
5ac4f88
Use inline filter form for all Filter subclasses
amstilp Oct 11, 2023
9214a1d
Bump version number and update CHANGELOG
amstilp Oct 12, 2023
027512e
Merge branch 'main' into feature/add-search-functionality-for-models
amstilp Oct 12, 2023
4bf2620
Use crispy custom FilterForm in AccountList template
amstilp Oct 12, 2023
49d8ef7
Allow user to specify a list filterset class in the Account adapter
amstilp Oct 12, 2023
30eab11
Update the AccountList views to use the adapter filter
amstilp Oct 12, 2023
8bfd1b9
Add info about AccountAdapter to docs
amstilp Oct 12, 2023
6cc66fa
Update api autodocs
amstilp Oct 12, 2023
7f5633c
Merge branch 'main' into feature/add-search-functionality-for-models
amstilp Oct 17, 2023
b8916dd
Raise required django-filter version number
amstilp Oct 17, 2023
acdd04e
Run tox with high verbosity
amstilp Oct 17, 2023
bb15b28
Add verbosity to sqlite tox run
amstilp Oct 17, 2023
bc88e95
Try removing lintr cache from CI
amstilp Oct 17, 2023
5e7cf9f
Remove buildkit lines from CI
amstilp Oct 17, 2023
b2f48d1
Change max-parallel to 10 in CI
amstilp Oct 18, 2023
5b35a55
Set max-parallel to 1 ¯\_(ツ)_/¯
amstilp Oct 18, 2023
eb8e740
Add CI that works in a different branch
amstilp Oct 23, 2023
8dacf26
Fix tox config file for hopefully working CI
amstilp Oct 23, 2023
bf6406b
Try buildling a wheel
amstilp Oct 23, 2023
65d6b03
Run tox in verbose mode
amstilp Oct 23, 2023
f512c4f
Add py311 to tox envlist
amstilp Oct 23, 2023
c07e969
Add files to MANIFEST.in
amstilp Oct 23, 2023
6c3a326
Remove wheel packaging from tox
amstilp Oct 23, 2023
2ab6ba3
Include py311 in tox testenv envlist match
amstilp Oct 23, 2023
de63ca0
Remove PIP_NO_CACHE_DIR variable
amstilp Oct 23, 2023
b501430
Remove fancy custom FilterForm layout
amstilp Oct 23, 2023
42459fb
Remove caching from setup-python action
amstilp Oct 23, 2023
7da26b1
Only run CI on mariadb 10.4
amstilp Oct 24, 2023
f58aecd
Try interactive debugging step?
amstilp Oct 24, 2023
0636857
Remove verbosity from tox
amstilp Oct 24, 2023
cd31427
Remove MariaDB 10.3-specific step from CI
amstilp Oct 24, 2023
81f3a2a
Try ubuntu-20.04 instead of ubuntu-latest
amstilp Oct 24, 2023
e42e1d5
Try adding a sleep command before tox
amstilp Oct 24, 2023
8818c76
Comment out tmate debugging step
amstilp Oct 24, 2023
88df443
Try retrying the tox command after failure
amstilp Oct 24, 2023
12f196f
Clean up CI file
amstilp Oct 24, 2023
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
44 changes: 22 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: "3.9"
cache: pip
cache-dependency-path: |
requirements/base.txt
requirements/dev.txt

- name: Run pre-commit
uses: pre-commit/[email protected]
Expand All @@ -41,7 +37,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 5
max-parallel: 10
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]

Expand All @@ -59,7 +55,15 @@ jobs:
python -m pip install --upgrade tox tox-gh-actions

- name: Test with tox
run: tox
# Sometimes tox fails to build the package correctly and intermittently throws an OSError or BadZipFile error.
# Upon retry, it seems to work.
uses: nick-fields/retry@v2
id: retry-sqlite
with:
timeout_minutes: 10
max_attempts: 3
retry_on: error
command: tox
env:
DBBACKEND: sqlite3
DBNAME: ":memory:"
Expand All @@ -75,10 +79,10 @@ jobs:
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 5
max-parallel: 10
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
mariadb-version: ["10.3", "10.5"]
mariadb-version: ["10.4"]

services:
database:
Expand All @@ -103,19 +107,16 @@ jobs:
python -m pip install --upgrade pip
python -m pip install --upgrade tox tox-gh-actions

- name: Test with tox - 10.3
if: ${{ matrix.mariadb-version == '10.3' }}
run: tox --skip-env ".+?-django42-mysql"
env:
DBBACKEND: mysql
DBNAME: test
DBUSER: root
DBPASSWORD: rootpw
DBHOST: 127.0.0.1

- name: Test with tox - not 10.3
if: ${{ matrix.mariadb-version != '10.3' }}
run: tox
- name: Test with tox
# Sometimes tox fails to build the package correctly and intermittently throws an OSError or BadZipFile error.
# Upon retry, it seems to work.
uses: nick-fields/retry@v2
id: retry-sqlite
with:
timeout_minutes: 10
max_attempts: 3
retry_on: error
command: tox
env:
DBBACKEND: mysql
DBNAME: test
Expand Down Expand Up @@ -143,7 +144,6 @@ jobs:

- run: python -m pip install --upgrade coverage[toml] django==3.2.16 django-coverage-plugin


- name: Download coverage data.
uses: actions/download-artifact@v3
with:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change log

## Devel

* Add filtering in list views.

## 0.18 (2023-10-03)

* Include a workspace_data_object context variable for the `WorkspaceDetail` and `WorkspaceUpdate` views.
Expand Down
4 changes: 4 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ include LICENSE
include README.md
recursive-include anvil_consortium_manager/templates *
recursive-include docs *
recursive-exclude docs/_build *
recursive-include anvil_consortium_manager/tests/test_app/templates *
recursive-exclude example_site *
exclude .coverage
2 changes: 1 addition & 1 deletion anvil_consortium_manager/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.18"
__version__ = "0.19dev1"
25 changes: 25 additions & 0 deletions anvil_consortium_manager/adapters/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.utils.module_loading import import_string
from django_filters import FilterSet

from .. import models


class BaseAccountAdapter(ABC):
Expand All @@ -15,6 +18,11 @@ def list_table_class(self):
"""Table class to use in a list of Accounts."""
...

@abstractproperty
def list_filterset_class(self):
"""FilterSet subclass to use for Account filtering in the AccountList view."""
...

def get_list_table_class(self):
"""Return the table class to use for the AccountList view."""
if not self.list_table_class:
Expand All @@ -23,6 +31,23 @@ def get_list_table_class(self):
)
return self.list_table_class

def get_list_filterset_class(self):
"""Return the FilterSet subclass to use for Account filtering in the AccountList view."""
if not self.list_filterset_class:
raise ImproperlyConfigured(
"Set `list_filterset_class` in `{}`.".format(type(self))
)
if not issubclass(self.list_filterset_class, FilterSet):
raise ImproperlyConfigured(
"list_filterset_class must be a subclass of FilterSet."
)
# Make sure it has the correct model set.
if self.list_filterset_class.Meta.model != models.Account:
raise ImproperlyConfigured(
"list_filterset_class Meta model field must be anvil_consortium_manager.models.Account."
)
return self.list_filterset_class

def get_autocomplete_queryset(self, queryset, q):
"""Filter the Account `queryset` using the query `q` for use in the autocomplete."""
queryset = queryset.filter(email__icontains=q)
Expand Down
3 changes: 2 additions & 1 deletion anvil_consortium_manager/adapters/default.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Default adapters for the app."""

from .. import forms, models, tables
from .. import filters, forms, models, tables
from .account import BaseAccountAdapter
from .workspace import BaseWorkspaceAdapter

Expand All @@ -9,6 +9,7 @@ class DefaultAccountAdapter(BaseAccountAdapter):
"""Default account adapter for use with the app."""

list_table_class = tables.AccountTable
list_filterset_class = filters.AccountListFilter


class DefaultWorkspaceAdapter(BaseWorkspaceAdapter):
Expand Down
27 changes: 27 additions & 0 deletions anvil_consortium_manager/filters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from django_filters import FilterSet

from . import models


class AccountListFilter(FilterSet):
class Meta:
model = models.Account
fields = {"email": ["icontains"]}


class BillingProjectListFilter(FilterSet):
class Meta:
model = models.BillingProject
fields = {"name": ["icontains"]}


class ManagedGroupListFilter(FilterSet):
class Meta:
model = models.ManagedGroup
fields = {"name": ["icontains"]}


class WorkspaceListFilter(FilterSet):
class Meta:
model = models.Workspace
fields = {"name": ["icontains"]}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{% load static %}

{% load render_table from django_tables2 %}
{% load crispy_forms_tags %}

{% block title %}Accounts{% endblock %}

Expand All @@ -13,6 +14,13 @@

<h2>Accounts</h2>

<div class="my-3 p-3 bg-light border rounded shadow-sm">
<form method="get">
{{ filter.form|crispy }}
<button type="submit" class="btn btn-primary">Filter</button>
</form>
</div>

{% render_table table %}

</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{% load static %}

{% load render_table from django_tables2 %}
{% load crispy_forms_tags %}

{% block title %}Billing Projects{% endblock %}

Expand All @@ -13,6 +14,13 @@

<h2>Billing Projects</h2>

<div class="my-3 p-3 bg-light border rounded shadow-sm">
<form method="get">
{{ filter.form|crispy }}
<button type="submit" class="btn btn-primary">Filter</button>
</form>
</div>

{% render_table table %}

</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,24 @@
{% load static %}

{% load render_table from django_tables2 %}
{% load crispy_forms_tags %}

{% block title %}Managed Groups{% endblock %}

{% block content %}
<div class="container">

<div class="row">
<div class="col-sm-12">

<h2>Managed Groups</h2>

<div class="my-3 p-3 bg-light border rounded shadow-sm">
<form method="get">
{{ filter.form|crispy }}
<button type="submit" class="btn btn-primary">Filter</button>
</form>
</div>

{% render_table table %}

</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,24 @@
{% load static %}

{% load render_table from django_tables2 %}
{% load crispy_forms_tags %}

{% block title %}{{workspace_type_display_name}}s{% endblock %}

{% block content %}
<div class="container">

<div class="row">
<div class="col-sm-12">

<h2>{{workspace_type_display_name}}s</h2>

<div class="my-3 p-3 bg-light border rounded shadow-sm">
<form method="get">
{{ filter.form|crispy }}
<button type="submit" class="btn btn-primary">Filter</button>
</form>
</div>

{% render_table table %}

</div>
Expand Down
43 changes: 42 additions & 1 deletion anvil_consortium_manager/tests/test_adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
BaseWorkspaceAdapter,
WorkspaceAdapterRegistry,
)
from ..filters import AccountListFilter, BillingProjectListFilter
from ..forms import DefaultWorkspaceDataForm, WorkspaceForm
from ..models import Account, DefaultWorkspaceData
from ..tables import AccountTable, WorkspaceTable
from . import factories
from .test_app import forms, models, tables
from .test_app import filters, forms, models, tables
from .test_app.adapters import TestWorkspaceAdapter


Expand All @@ -26,6 +27,7 @@ def get_test_adapter(self):

class TestAdapter(BaseAccountAdapter):
list_table_class = tables.TestAccountTable
list_filterset_class = filters.TestAccountListFilter

return TestAdapter

Expand All @@ -46,6 +48,45 @@ def test_list_table_class_none(self):
with self.assertRaises(ImproperlyConfigured):
TestAdapter().get_list_table_class()

def test_list_filterset_class_default(self):
"""get_list_filterset_class returns the correct filter when using the default adapter."""
self.assertEqual(
DefaultAccountAdapter().get_list_filterset_class(), AccountListFilter
)

def test_list_filterset_class_custom(self):
"""get_list_filterset_class returns the correct filter when using a custom adapter."""
TestAdapter = self.get_test_adapter()
setattr(TestAdapter, "list_filterset_class", filters.TestAccountListFilter)
self.assertEqual(
TestAdapter().get_list_filterset_class(), filters.TestAccountListFilter
)

def test_list_filterset_class_none(self):
"""get_list_filterset_class raises ImproperlyConfigured when get_list_filterset_class is not set."""
TestAdapter = self.get_test_adapter()
setattr(TestAdapter, "list_filterset_class", None)
with self.assertRaises(ImproperlyConfigured):
TestAdapter().get_list_filterset_class()

def test_list_filterset_class_different_model(self):
"""get_list_filterset_class raises ImproperlyConfigured when incorrect model is used."""
TestAdapter = self.get_test_adapter()
setattr(TestAdapter, "list_filterset_class", BillingProjectListFilter)
with self.assertRaises(ImproperlyConfigured):
TestAdapter().get_list_filterset_class()

def test_list_filterset_class_not_filterset(self):
"""get_list_filterset_class raises ImproperlyConfigured when not a subclass of FilterSet."""

class Foo:
pass

TestAdapter = self.get_test_adapter()
setattr(TestAdapter, "list_filterset_class", Foo)
with self.assertRaises(ImproperlyConfigured):
TestAdapter().get_list_filterset_class()

def test_get_autocomplete_queryset_default(self):
"""get_autocomplete_queryset returns the correct queryset when using the default adapter."""
account_1 = factories.AccountFactory.create(email="[email protected]")
Expand Down
3 changes: 2 additions & 1 deletion anvil_consortium_manager/tests/test_app/adapters.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from anvil_consortium_manager.adapters.account import BaseAccountAdapter
from anvil_consortium_manager.adapters.workspace import BaseWorkspaceAdapter

from . import forms, models, tables
from . import filters, forms, models, tables


class TestWorkspaceAdapter(BaseWorkspaceAdapter):
Expand Down Expand Up @@ -30,6 +30,7 @@ class TestAccountAdapter(BaseAccountAdapter):
"""Test adapter for accounts."""

list_table_class = tables.TestAccountTable
list_filterset_class = filters.TestAccountListFilter

def get_autocomplete_queryset(self, queryset, q):
if q:
Expand Down
11 changes: 11 additions & 0 deletions anvil_consortium_manager/tests/test_app/filters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from django_filters import FilterSet

from anvil_consortium_manager.models import Account


class TestAccountListFilter(FilterSet):
"""Test filter for Accounts."""

class Meta:
model = Account
fields = {"email": ["icontains"], "is_service_account": ["exact"]}
Loading
Loading