-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1395 from opsmill/develop
Version 0.8.2
- Loading branch information
Showing
103 changed files
with
1,669 additions
and
1,909 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#!/bin/bash | ||
|
||
poetry config virtualenvs.create true | ||
poetry install --no-interaction --no-ansi --no-root | ||
poetry install --no-interaction --no-ansi | ||
|
||
invoke demo.build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
#!/bin/bash | ||
|
||
invoke demo.init demo.start | ||
invoke demo.start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,6 @@ jobs: | |
backend: ${{ steps.changes.outputs.backend_all }} | ||
frontend: ${{ steps.changes.outputs.frontend_all }} | ||
sdk: ${{ steps.changes.outputs.sdk_all }} | ||
nornir: ${{ steps.changes.outputs.nornir_all }} | ||
sync: ${{ steps.changes.outputs.sync_all }} | ||
e2e: ${{ steps.changes.outputs.e2e_all }} | ||
python: ${{ steps.changes.outputs.python_all }} | ||
|
@@ -175,43 +174,6 @@ jobs: | |
flag-name: python-sdk-integration | ||
parallel: true | ||
|
||
nornir-plugin-tests: | ||
if: | | ||
always() && !cancelled() && | ||
!contains(needs.*.result, 'failure') && | ||
!contains(needs.*.result, 'cancelled') && | ||
needs.files-changed.outputs.nornir == 'true' | ||
needs: ["files-changed", "yaml-lint", "python-lint"] | ||
runs-on: "ubuntu-20.04" | ||
timeout-minutes: 30 | ||
steps: | ||
- name: "Check out repository code" | ||
uses: "actions/checkout@v3" | ||
- name: "Install Invoke" | ||
run: "pip install toml invoke" | ||
- name: "Build Test Image" | ||
run: "invoke test.build" | ||
- name: "Black Tests" | ||
run: "invoke nornir.black --docker" | ||
- name: "Isort Tests" | ||
run: "invoke nornir.isort --docker" | ||
- name: "Pylint Tests" | ||
run: "invoke nornir.pylint --docker" | ||
- name: "Mypy Tests" | ||
run: "invoke nornir.mypy --docker" | ||
- name: "Unit Tests" | ||
run: "invoke nornir.test-unit" | ||
env: | ||
BUILDKITE_ANALYTICS_TOKEN: ${{ secrets.BUILDKITE_NORNIR_UNIT }} | ||
- name: "Coveralls : Unit Tests" | ||
uses: coverallsapp/[email protected] | ||
env: | ||
COVERALLS_SERVICE_NUMBER: ${{ github.sha }} | ||
with: | ||
flag-name: nornir-plugin-unit | ||
parallel: true | ||
|
||
|
||
infrahub-sync-tests: | ||
if: | | ||
always() && !cancelled() && | ||
|
@@ -338,6 +300,18 @@ jobs: | |
- name: "Run integration tests" | ||
working-directory: ./frontend | ||
run: "npm run cypress:run" | ||
- name: Upload cypress screenshots | ||
if: failure() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: screenshots | ||
path: docs/media/* | ||
- name: Upload cypress videos | ||
if: failure() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: screenshots | ||
path: frontend/cypress/videos/* | ||
- name: "Coveralls : Unit Tests" | ||
uses: coverallsapp/[email protected] | ||
env: | ||
|
@@ -375,7 +349,7 @@ jobs: | |
# run: "invoke demo.pull" | ||
# - name: Initialize Demo | ||
# id: init-demo | ||
# run: "invoke demo.init demo.start demo.load-infra-schema" | ||
# run: "invoke demo.start demo.load-infra-schema" | ||
# - name: Check Demo Status | ||
# run: "invoke demo.status" | ||
# - name: Load Data | ||
|
@@ -417,7 +391,7 @@ jobs: | |
!contains(needs.*.result, 'failure') && | ||
!contains(needs.*.result, 'cancelled') | ||
runs-on: "runner-ubuntu-8-32" | ||
timeout-minutes: 30 | ||
timeout-minutes: 40 | ||
env: | ||
INFRAHUB_DB_TYPE: neo4j | ||
steps: | ||
|
@@ -440,7 +414,7 @@ jobs: | |
run: "invoke demo.pull" | ||
- name: Initialize Demo | ||
id: init-demo | ||
run: "invoke demo.init demo.start demo.load-infra-schema" | ||
run: "invoke demo.start demo.load-infra-schema" | ||
- name: Check Demo Status | ||
run: "invoke demo.status" | ||
- name: Load Data | ||
|
@@ -476,7 +450,7 @@ jobs: | |
run: invoke demo.status | ||
|
||
coverall-report: | ||
needs: ["frontend-tests", "backend-tests-default", "python-sdk-tests", "nornir-plugin-tests"] | ||
needs: ["frontend-tests", "backend-tests-default", "python-sdk-tests"] | ||
if: | | ||
always() && !cancelled() | ||
runs-on: ubuntu-latest | ||
|
@@ -508,5 +482,5 @@ jobs: | |
env: | ||
COVERALLS_SERVICE_NUMBER: ${{ github.sha }} | ||
with: | ||
carryforward: "backend-unit,backend-integration,frontend-unit,python-sdk-unit,python-sdk-integration,nornir-plugin-unit" | ||
carryforward: "backend-unit,backend-integration,frontend-unit,python-sdk-unit,python-sdk-integration" | ||
parallel-finished: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
from __future__ import annotations | ||
|
||
from typing import Dict, List | ||
|
||
from fastapi import APIRouter, Depends | ||
from pydantic import BaseModel, Field | ||
|
||
from infrahub.api.dependencies import get_branch_dep | ||
from infrahub.core import registry | ||
from infrahub.core.branch import Branch # noqa: TCH001 | ||
from infrahub.core.schema import GroupSchema, NodeSchema | ||
from infrahub.log import get_logger | ||
|
||
log = get_logger() | ||
router = APIRouter(prefix="/menu") | ||
|
||
|
||
class InterfaceMenu(BaseModel): | ||
title: str = Field(..., description="Title of the menu item") | ||
path: str = Field(default="", description="URL endpoint if applicable") | ||
icon: str = Field(default="", description="The icon to show for the current view") | ||
children: List[InterfaceMenu] = Field(default_factory=list, description="Child objects") | ||
kind: str = Field(default="") | ||
|
||
def __lt__(self, other: object) -> bool: | ||
if not isinstance(other, InterfaceMenu): | ||
raise NotImplementedError | ||
return self.title < other.title | ||
|
||
def list_title(self) -> str: | ||
return f"All {self.title}(s)" | ||
|
||
|
||
def add_to_menu(structure: Dict[str, List[InterfaceMenu]], menu_item: InterfaceMenu) -> None: | ||
all_items = InterfaceMenu(title=menu_item.list_title(), path=menu_item.path, icon=menu_item.icon) | ||
menu_item.path = "" | ||
menu_item.icon = "" | ||
for child in structure[menu_item.kind]: | ||
menu_item.children.append(child) | ||
if child.kind in structure: | ||
add_to_menu(structure, child) | ||
menu_item.children.sort() | ||
menu_item.children.insert(0, all_items) | ||
|
||
|
||
@router.get("") | ||
async def get_menu( | ||
branch: Branch = Depends(get_branch_dep), | ||
) -> List[InterfaceMenu]: | ||
log.info("menu_request", branch=branch.name) | ||
|
||
full_schema = registry.schema.get_full(branch=branch) | ||
objects = InterfaceMenu( | ||
title="Objects", | ||
children=[], | ||
) | ||
|
||
structure: Dict[str, List[InterfaceMenu]] = {} | ||
|
||
groups = InterfaceMenu( | ||
title="Groups", | ||
) | ||
for key in full_schema.keys(): | ||
model = full_schema[key] | ||
|
||
if isinstance(model, GroupSchema) or not model.include_in_menu: | ||
continue | ||
|
||
if isinstance(model, NodeSchema) and "CoreGroup" in model.inherit_from: | ||
groups.children.append(InterfaceMenu(title=model.label or model.name, path=f"/groups/{model.kind}")) | ||
continue | ||
|
||
menu_name = model.menu_placement or "base" | ||
if menu_name not in structure: | ||
structure[menu_name] = [] | ||
|
||
structure[menu_name].append( | ||
InterfaceMenu( | ||
title=model.label or model.name, path=f"/objects/{model.kind}", icon=model.icon or "", kind=model.kind | ||
) | ||
) | ||
|
||
for menu_item in structure["base"]: | ||
if menu_item.kind in structure: | ||
add_to_menu(structure, menu_item) | ||
|
||
objects.children.append(menu_item) | ||
|
||
objects.children.sort() | ||
groups.children.sort() | ||
groups.children.insert(0, InterfaceMenu(title="All Groups", path="/groups")) | ||
unified_storage = InterfaceMenu( | ||
title="Unified Storage", | ||
children=[ | ||
InterfaceMenu(title="Schema", path="/schema", icon="mdi:file-code"), | ||
InterfaceMenu(title="Repository", path="/objects/CoreRepository", icon="mdi:source-repository"), | ||
InterfaceMenu(title="GraphQL Query", path="/objects/CoreGraphQLQuery", icon="mdi:graphql"), | ||
], | ||
) | ||
|
||
change_control = InterfaceMenu( | ||
title="Change Control", | ||
children=[ | ||
InterfaceMenu(title="Branches", path="/branches", icon="mdi:layers-triple"), | ||
InterfaceMenu(title="Proposed Changes", path="/proposed-changes", icon="mdi:file-replace-outline"), | ||
InterfaceMenu(title="Check Definition", path="/objects/CoreCheckDefinition", icon="mdi:check-all"), | ||
], | ||
) | ||
deployment = InterfaceMenu( | ||
title="Deployment", | ||
children=[ | ||
InterfaceMenu(title="Artifact", path="/objects/CoreArtifact", icon="mdi:file-document-outline"), | ||
InterfaceMenu( | ||
title="Artifact Definition", | ||
path="/objects/CoreArtifactDefinition", | ||
icon="mdi:file-document-multiple-outline", | ||
), | ||
InterfaceMenu(title="Transformation", path="/objects/CoreTransformation", icon="mdi:cog-transfer"), | ||
], | ||
) | ||
admin = InterfaceMenu( | ||
title="Admin", children=[InterfaceMenu(title="Accounts", path="/objects/CoreAccount", icon="mdi:account")] | ||
) | ||
|
||
return [objects, groups, unified_storage, change_control, deployment, admin] |
Oops, something went wrong.