Skip to content

Commit

Permalink
Backport CI and test modernization
Browse files Browse the repository at this point in the history
  • Loading branch information
fdintino committed Nov 15, 2024
1 parent 2554f51 commit 2e957f4
Show file tree
Hide file tree
Showing 57 changed files with 13,521 additions and 1,980 deletions.
33 changes: 17 additions & 16 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,47 +45,49 @@ jobs:
NODE_ENV: test

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Setup chromedriver
uses: nanasess/setup-chromedriver@v1.0.5
# uses: nanasess/setup-chromedriver@v2.2.2
uses: nanasess/setup-chromedriver@42cc2998329f041de87dc3cfa33a930eacd57eaa

- name: Install tox
run: |
python3 -m pip install tox tox-gh-actions
- name: Cache instrumented static files
id: cache-test-dist
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: nested_admin/tests/static
key: test-dist-${{ hashFiles('package-lock.json', '.github/workflows/test.yml', 'webpack.config.js', 'package.json', '.*rc*', 'frontend/**') }}
key: test-dist-${{ hashFiles('package-lock.json', '.github/workflows/test.yml', 'webpack.config.js', 'package.json', '.*rc*', 'nested_admin/static/nested_admin/src/**/*.*s') }}

- name: Cache node_modules
id: cache-node_modules
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: node_modules
key: node_modules-${{ hashFiles('package-lock.json') }}

- name: Setup nodejs 12
if: steps.cache-test-dist.outputs.cache-hit != 'true' || steps.cache-node_modules.outputs.cache-hit != 'true'
uses: actions/setup-node@v2
- name: Setup nodejs
if: steps.cache-test-dist.outputs.cache-hit != 'true'
uses: actions/setup-node@v3
with:
node-version: '12'
node-version: '16'
cache: 'npm'

- name: npm ci
if: steps.cache-test-dist.outputs.cache-hit != 'true' || steps.cache-node_modules.outputs.cache-hit != 'true'
if: steps.cache-test-dist.outputs.cache-hit != 'true' && steps.cache-node_modules.outputs.cache-hit != 'true'
run: |
npm ci || npm ci || npm ci
- name: Build instrumented static files
if: steps.cache-test-dist.outputs.cache-hit != 'true' || steps.cache-node_modules.outputs.cache-hit != 'true'
if: steps.cache-test-dist.outputs.cache-hit != 'true'
run: |
npm run build
Expand All @@ -98,7 +100,7 @@ jobs:

- name: Upload junit xml
if: always()
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: junit-reports
path: reports/*.xml
Expand All @@ -121,15 +123,14 @@ jobs:
runs-on: ubuntu-latest
name: "Report Test Results"
steps:
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v3
with:
name: junit-reports

- name: Publish tests report
uses: mikepenz/action-junit-report@5703ba1461f35871cde0208140d737d3e1eef38f
uses: mikepenz/action-junit-report@1a91e26932fb7ba410a31fab1f09266a96d29971
with:
report_paths: ./*.xml
github_token: ${{ secrets.GITHUB_TOKEN }}
require_tests: true
fail_on_failure: true
check_name: Test Report
Expand Down
148 changes: 89 additions & 59 deletions nested_admin/tests/admin_widgets/admin.py
Original file line number Diff line number Diff line change
@@ -1,95 +1,116 @@
from django.conf import settings
from django.contrib import admin
from nested_admin import NestedStackedInline, NestedTabularInline, NestedModelAdmin

from .models import (
WidgetsRoot, WidgetsM2M, WidgetsRelated1,
WidgetsRelated2, WidgetsA, WidgetsB,
WidgetsC0, WidgetsC1, WidgetsM2MTwo,
WidgetMediaOrderRoot, WidgetMediaOrderA, WidgetMediaOrderB,
WidgetMediaOrderC0, WidgetMediaOrderC1,
WidgetMediaOrderRootWithDateWidget)
WidgetsRoot,
WidgetsM2M,
WidgetsRelated1,
WidgetsRelated2,
WidgetsA,
WidgetsB,
WidgetsC0,
WidgetsC1,
WidgetsM2MTwo,
WidgetMediaOrderRoot,
WidgetMediaOrderA,
WidgetMediaOrderB,
WidgetMediaOrderC0,
WidgetMediaOrderC1,
WidgetMediaOrderRootWithDateWidget,
)


class WidgetsC0Inline(NestedStackedInline):
model = WidgetsC0
prepopulated_fields = {'slug': ('name', )}
filter_horizontal = ['m2m']
prepopulated_fields = {"slug": ("name",)}
filter_horizontal = ["m2m"]
sortable_field_name = "position"
extra = 0
inline_classes = ("grp-collapse", "grp-open",)
raw_id_fields = ['fk2', 'fk4', 'm2m_two', 'm2m_three']
inline_classes = (
"grp-collapse",
"grp-open",
)
raw_id_fields = ["fk2", "fk4", "m2m_two", "m2m_three"]
autocomplete_lookup_fields = {
'fk': ['fk2'],
'm2m': ['m2m_three'],
'generic': [['relation_type', 'relation_id']],
"fk": ["fk2"],
"m2m": ["m2m_three"],
"generic": [["relation_type", "relation_id"]],
}
autocomplete_fields = ['fk3']
autocomplete_fields = ["fk3"]
related_lookup_fields = {
'fk': ['fk4'],
'm2m': ['m2m_two'],
'generic': [['content_type', 'object_id']],
"fk": ["fk4"],
"m2m": ["m2m_two"],
"generic": [["content_type", "object_id"]],
}


class WidgetsC1Inline(NestedTabularInline):
model = WidgetsC1
prepopulated_fields = {'slug': ('name', )}
filter_horizontal = ['m2m']
prepopulated_fields = {"slug": ("name",)}
filter_horizontal = ["m2m"]
sortable_field_name = "position"
extra = 0
inline_classes = ("grp-collapse", "grp-open",)
raw_id_fields = ['fk2', 'fk4', 'm2m_two']
autocomplete_lookup_fields = {'fk': ['fk2']}
autocomplete_fields = ['fk3']
inline_classes = (
"grp-collapse",
"grp-open",
)
raw_id_fields = ["fk2", "fk4", "m2m_two"]
autocomplete_lookup_fields = {"fk": ["fk2"]}
autocomplete_fields = ["fk3"]
related_lookup_fields = {
'fk': ['fk4'],
'm2m': ['m2m_two'],
'generic': [['content_type', 'object_id']],
"fk": ["fk4"],
"m2m": ["m2m_two"],
"generic": [["content_type", "object_id"]],
}


class WidgetsBInline(NestedStackedInline):
model = WidgetsB
inlines = [WidgetsC0Inline, WidgetsC1Inline]
prepopulated_fields = {'slug': ('name', )}
filter_horizontal = ['m2m']
prepopulated_fields = {"slug": ("name",)}
filter_horizontal = ["m2m"]
sortable_field_name = "position"
extra = 1
inline_classes = ("grp-collapse", "grp-open",)
raw_id_fields = ['fk2', 'fk4', 'm2m_two', 'm2m_three']
inline_classes = (
"grp-collapse",
"grp-open",
)
raw_id_fields = ["fk2", "fk4", "m2m_two", "m2m_three"]
autocomplete_lookup_fields = {
'fk': ['fk2'],
'm2m': ['m2m_three'],
'generic': [['relation_type', 'relation_id']],
"fk": ["fk2"],
"m2m": ["m2m_three"],
"generic": [["relation_type", "relation_id"]],
}
autocomplete_fields = ['fk3']
autocomplete_fields = ["fk3"]
related_lookup_fields = {
'fk': ['fk4'],
'm2m': ['m2m_two'],
'generic': [['content_type', 'object_id']],
"fk": ["fk4"],
"m2m": ["m2m_two"],
"generic": [["content_type", "object_id"]],
}


class WidgetsAInline(NestedStackedInline):
model = WidgetsA
inlines = [WidgetsBInline]
prepopulated_fields = {'slug': ('name', )}
filter_horizontal = ['m2m']
prepopulated_fields = {"slug": ("name",)}
filter_horizontal = ["m2m"]
sortable_field_name = "position"
extra = 1
inline_classes = ("grp-collapse", "grp-open",)
raw_id_fields = ['fk2', 'fk4', 'm2m_two', 'm2m_three']
inline_classes = (
"grp-collapse",
"grp-open",
)
raw_id_fields = ["fk2", "fk4", "m2m_two", "m2m_three"]
autocomplete_lookup_fields = {
'fk': ['fk2'],
'm2m': ['m2m_three'],
'generic': [['relation_type', 'relation_id']],
"fk": ["fk2"],
"m2m": ["m2m_three"],
"generic": [["relation_type", "relation_id"]],
}
autocomplete_fields = ['fk3']
autocomplete_fields = ["fk3"]
related_lookup_fields = {
'fk': ['fk4'],
'm2m': ['m2m_two'],
'generic': [['content_type', 'object_id']],
"fk": ["fk4"],
"m2m": ["m2m_two"],
"generic": [["content_type", "object_id"]],
}


Expand All @@ -105,8 +126,8 @@ class WidgetsRootAdmin(NestedModelAdmin):

@admin.register(WidgetsRelated2)
class WidgetsRelated2Admin(NestedModelAdmin):
ordering = ['-date_created']
search_fields = ['name']
ordering = ["-date_created"]
search_fields = ["name"]


class WidgetMediaOrderC0Inline(NestedStackedInline):
Expand All @@ -117,29 +138,38 @@ class WidgetMediaOrderC0Inline(NestedStackedInline):

class WidgetMediaOrderC1Inline(NestedTabularInline):
model = WidgetMediaOrderC1
prepopulated_fields = {'slug': ('name', )}
filter_horizontal = ['m2m']
prepopulated_fields = {"slug": ("name",)}
filter_horizontal = ["m2m"]
extra = 0
inline_classes = ("grp-collapse", "grp-open",)
raw_id_fields = ['fk2']
autocomplete_lookup_fields = {'fk': ['fk2']}
autocomplete_fields = ['fk3']
inline_classes = (
"grp-collapse",
"grp-open",
)
raw_id_fields = ["fk2"]
autocomplete_lookup_fields = {"fk": ["fk2"]}
autocomplete_fields = ["fk3"]


class WidgetMediaOrderBInline(NestedStackedInline):
model = WidgetMediaOrderB
inlines = [WidgetMediaOrderC0Inline, WidgetMediaOrderC1Inline]
sortable_field_name = "position"
extra = 1
inline_classes = ("grp-collapse", "grp-open",)
inline_classes = (
"grp-collapse",
"grp-open",
)


class WidgetMediaOrderAInline(NestedStackedInline):
model = WidgetMediaOrderA
inlines = [WidgetMediaOrderBInline]
sortable_field_name = "position"
extra = 1
inline_classes = ("grp-collapse", "grp-open",)
inline_classes = (
"grp-collapse",
"grp-open",
)


@admin.register(WidgetMediaOrderRoot)
Expand Down
Loading

0 comments on commit 2e957f4

Please sign in to comment.