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

Merge stable into release-1.2 #5855

Closed
wants to merge 6 commits into from
Closed
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
6 changes: 0 additions & 6 deletions .github/file-filters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ release_files: &release_files
- CHANGELOG.md
- "docs/docs/release_notes/infrahub/*.mdx"

helm_files: &helm_files
- "helm/**"

python_all: &python_all
- "**/*.py"

Expand Down Expand Up @@ -83,9 +80,6 @@ documentation_generated_all:
release_all:
- *release_files

helm_all:
- *helm_files

frontend_all:
- *frontend_files
- *ci_config
Expand Down
4 changes: 0 additions & 4 deletions .github/labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@
description: "Issue related to the CI pipeline"
color: "f25009"

- name: "group/helm"
description: "Issue related to the Helm chart"
color: "326ce5"

- name: "group/schema"
description: "Issue related to some schemas"
color: "fbceb1"
Expand Down
16 changes: 0 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ jobs:
documentation_generated: ${{ steps.changes.outputs.documentation_generated_all }}
release: ${{ steps.changes.outputs.release_all }}
frontend: ${{ steps.changes.outputs.frontend_all }}
helm: ${{ steps.changes.outputs.helm_all }}
e2e: ${{ steps.changes.outputs.e2e_all }}
python: ${{ steps.changes.outputs.python_all }}
javascript: ${{ steps.changes.outputs.javascript_all }}
Expand All @@ -62,21 +61,6 @@ jobs:
filters: .github/file-filters.yml

# ------------------------------------------ All Linter ------------------------------------------
helm-lint:
if: needs.files-changed.outputs.helm == 'true'
needs: ["files-changed"]
runs-on: "ubuntu-latest"
timeout-minutes: 5
steps:
- name: "Check out repository code"
uses: "actions/checkout@v4"
with:
submodules: true
- name: "Install Helm"
uses: azure/setup-helm@v4.2.0
- name: "Linting: helm lint"
run: "helm lint helm/"

yaml-lint:
if: needs.files-changed.outputs.yaml == 'true'
needs: ["files-changed"]
Expand Down
71 changes: 0 additions & 71 deletions .github/workflows/publish-helm-chart.yml

This file was deleted.

3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,11 @@ jobs:
publish-helm-chart:
needs: check_release
if: github.event.release.prerelease == false
uses: ./.github/workflows/publish-helm-chart.yml
uses: opsmill/infrahub-helm/.github/workflows/publish-helm-chart.yml@stable
secrets: inherit
with:
publish: true
chart: infrahub

publish-pypi:
needs: check_release
Expand Down
27 changes: 21 additions & 6 deletions .github/workflows/update-compose-file-and-chart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,36 @@ jobs:
- name: "Update Infrahub Image Version in docker-compose.yml file"
if: steps.release.outputs.is_prerelease == 0 && steps.release.outputs.is_devrelease == 0
run: "poetry run invoke release.update-docker-compose"
- name: "Update AppVersion in helm/chart.yaml file"
if: steps.release.outputs.is_prerelease == 0 && steps.release.outputs.is_devrelease == 0
run: "poetry run invoke release.update-helm-chart"
- name: "Update Versions in python_testcontainers/pyproject.toml"
run: "poetry run invoke release.update-test-containers"
- name: Commit docker-compose.yml and helm
- name: Commit docker-compose.yml
uses: github-actions-x/commit@v2.9
with:
github-token: ${{ secrets.GH_INFRAHUB_BOT_TOKEN }}
push-branch: 'stable'
commit-message: 'chore: update docker-compose and helm chart'
commit-message: 'chore: update docker-compose'
files: |
docker-compose.yml
helm/Chart.yaml
python_testcontainers/pyproject.toml
name: opsmill-bot
email: github-bot@opsmill.com
rebase: true

- name: Checkout infrahub-helm
if: steps.release.outputs.is_prerelease == 0 && steps.release.outputs.is_devrelease == 0
uses: actions/checkout@v4
with:
repository: opsmill/infrahub-helm
path: helm
token: ${{ secrets.GH_INFRAHUB_BOT_TOKEN }}

- name: "Update AppVersion in helm/chart.yaml file"
if: steps.release.outputs.is_prerelease == 0 && steps.release.outputs.is_devrelease == 0
run: "poetry run invoke release.update-helm-chart"

- name: Commit helm
if: steps.release.outputs.is_prerelease == 0 && steps.release.outputs.is_devrelease == 0
working-directory: helm
run: |
git commit -a -m 'chore: bump appVersion'
git push
56 changes: 38 additions & 18 deletions backend/infrahub/core/migrations/query/node_duplicate.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,47 @@ def render_match(self) -> str:

@staticmethod
def _render_sub_query_per_rel_type(
rel_name: str, rel_type: str, rel_def: FieldInfo, direction: GraphRelDirection
rel_name: str,
rel_type: str,
rel_def: FieldInfo,
) -> str:
subquery = [
f"WITH peer_node, {rel_name}, active_node, new_node",
f"WITH peer_node, {rel_name}, active_node, new_node",
f'WHERE type({rel_name}) = "{rel_type}"',
]
if rel_def.default.direction in [direction, GraphRelDirection.EITHER]:
subquery.append(f"CREATE (new_node)-[:{rel_type} $rel_props_new ]->(peer_node)")
subquery.append(f"CREATE (active_node)-[:{rel_type} $rel_props_prev ]->(peer_node)")
elif rel_def.default.direction in [direction, GraphRelDirection.EITHER]:
subquery.append(f"CREATE (new_node)<-[:{rel_type} $rel_props_new ]-(peer_node)")
subquery.append(f"CREATE (active_node)<-[:{rel_type} $rel_props_prev ]-(peer_node)")
if rel_def.default.direction in [GraphRelDirection.OUTBOUND, GraphRelDirection.EITHER]:
subquery.append(f"""
CREATE (new_node)-[new_active_edge:{rel_type} $rel_props_new ]->(peer_node)
SET new_active_edge.branch = CASE WHEN {rel_name}.branch = "-global-" THEN "-global-" ELSE $branch END
SET new_active_edge.branch_level = CASE WHEN {rel_name}.branch = "-global-" THEN {rel_name}.branch_level ELSE $branch_level END
""")
subquery.append(f"""
CREATE (active_node)-[deleted_edge:{rel_type} $rel_props_prev ]->(peer_node)
SET deleted_edge.branch = CASE WHEN {rel_name}.branch = "-global-" THEN "-global-" ELSE $branch END
SET deleted_edge.branch_level = CASE WHEN {rel_name}.branch = "-global-" THEN {rel_name}.branch_level ELSE $branch_level END
""")
elif rel_def.default.direction in [GraphRelDirection.INBOUND, GraphRelDirection.EITHER]:
subquery.append(f"""
CREATE (new_node)<-[new_active_edge:{rel_type} $rel_props_new ]-(peer_node)
SET new_active_edge.branch = CASE WHEN {rel_name}.branch = "-global-" THEN "-global-" ELSE $branch END
SET new_active_edge.branch_level = CASE WHEN {rel_name}.branch = "-global-" THEN {rel_name}.branch_level ELSE $branch_level END
""")
subquery.append(f"""
CREATE (active_node)<-[deleted_edge:{rel_type} $rel_props_prev ]-(peer_node)
SET new_active_edge.branch = CASE WHEN {rel_name}.branch = "-global-" THEN "-global-" ELSE $branch END
SET new_active_edge.branch_level = CASE WHEN {rel_name}.branch = "-global-" THEN {rel_name}.branch_level ELSE $branch_level END
""")
subquery.append("RETURN peer_node as p2")
return "\n".join(subquery)

@classmethod
def _render_sub_query_out(cls) -> str:
sub_queries_out = [
cls._render_sub_query_per_rel_type(
rel_name="rel_outband", rel_type=rel_type, rel_def=rel_def, direction=GraphRelDirection.OUTBOUND
rel_name="rel_outband",
rel_type=rel_type,
rel_def=rel_def,
)
for rel_type, rel_def in GraphNodeRelationships.model_fields.items()
]
Expand All @@ -79,7 +99,9 @@ def _render_sub_query_out(cls) -> str:
def _render_sub_query_in(cls) -> str:
sub_queries_in = [
cls._render_sub_query_per_rel_type(
rel_name="rel_inband", rel_type=rel_type, rel_def=rel_def, direction=GraphRelDirection.INBOUND
rel_name="rel_inband",
rel_type=rel_type,
rel_def=rel_def,
)
for rel_type, rel_def in GraphNodeRelationships.model_fields.items()
]
Expand All @@ -94,19 +116,16 @@ async def query_init(self, db: InfrahubDatabase, **kwargs: dict[str, Any]) -> No
self.params["previous_node"] = self.previous_node.model_dump()

self.params["current_time"] = self.at.to_string()
self.params["branch_name"] = self.branch.name
self.params["branch"] = self.branch.name
self.params["branch_level"] = self.branch.hierarchy_level
self.params["branch_support"] = self.new_node.branch_support

self.params["rel_props_new"] = {
"branch": self.branch.name,
"branch_level": self.branch.hierarchy_level,
"status": RelationshipStatus.ACTIVE.value,
"from": self.at.to_string(),
}

self.params["rel_props_prev"] = {
"branch": self.branch.name,
"branch_level": self.branch.hierarchy_level,
"status": RelationshipStatus.DELETED.value,
"from": self.at.to_string(),
}
Expand Down Expand Up @@ -141,12 +160,12 @@ async def query_init(self, db: InfrahubDatabase, **kwargs: dict[str, Any]) -> No
LIMIT 1
}
WITH n1 as active_node, rel_outband1 as rel_outband, p1 as peer_node, new_node
WHERE rel_outband.status = "active"
WHERE rel_outband.status = "active" AND rel_outband.to IS NULL
CALL {
%(sub_query_out)s
}
WITH p2 as peer_node, rel_outband, active_node, new_node
FOREACH (i in CASE WHEN rel_outband.branch = $branch_name THEN [1] ELSE [] END |
FOREACH (i in CASE WHEN rel_outband.branch IN ["-global-", $branch] THEN [1] ELSE [] END |
SET rel_outband.to = $current_time
)
WITH active_node, new_node
Expand All @@ -160,14 +179,15 @@ async def query_init(self, db: InfrahubDatabase, **kwargs: dict[str, Any]) -> No
LIMIT 1
}
WITH n1 as active_node, rel_inband1 as rel_inband, p1 as peer_node, new_node
WHERE rel_inband.status = "active"
WHERE rel_inband.status = "active" AND rel_inband.to IS NULL
CALL {
%(sub_query_in)s
}
WITH p2 as peer_node, rel_inband, active_node, new_node
FOREACH (i in CASE WHEN rel_inband.branch = $branch_name THEN [1] ELSE [] END |
FOREACH (i in CASE WHEN rel_inband.branch IN ["-global-", $branch] THEN [1] ELSE [] END |
SET rel_inband.to = $current_time
)

RETURN DISTINCT new_node
""" % {
"branch_filter": branch_filter,
Expand Down
38 changes: 26 additions & 12 deletions backend/infrahub/core/migrations/schema/node_remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,28 @@

class NodeRemoveMigrationBaseQuery(MigrationQuery):
def render_sub_query_per_rel_type(
self, rel_name: str, rel_type: str, rel_def: FieldInfo, direction: GraphRelDirection
self,
rel_name: str,
rel_type: str,
rel_def: FieldInfo,
) -> str:
subquery = [
f"WITH peer_node, {rel_name}, active_node",
f"WITH peer_node, {rel_name}, active_node",
f'WHERE type({rel_name}) = "{rel_type}"',
]
if rel_def.default.direction in [direction, GraphRelDirection.EITHER]:
subquery.append(f"CREATE (active_node)-[:{rel_type} $rel_props ]->(peer_node)")
elif rel_def.default.direction in [direction, GraphRelDirection.EITHER]:
subquery.append(f"CREATE (active_node)<-[:{rel_type} $rel_props ]-(peer_node)")
if rel_def.default.direction in [GraphRelDirection.OUTBOUND, GraphRelDirection.EITHER]:
subquery.append(f"""
CREATE (active_node)-[edge:{rel_type} $rel_props ]->(peer_node)
SET edge.branch = CASE WHEN {rel_name}.branch = "-global-" THEN "-global-" ELSE $branch END
SET edge.branch_level = CASE WHEN {rel_name}.branch = "-global-" THEN {rel_name}.branch_level ELSE $branch_level END
""")
elif rel_def.default.direction in [GraphRelDirection.INBOUND, GraphRelDirection.EITHER]:
subquery.append(f"""
CREATE (active_node)<-[edge:{rel_type} $rel_props ]-(peer_node)
SET edge.branch = CASE WHEN {rel_name}.branch = "-global-" THEN "-global-" ELSE $branch END
SET edge.branch_level = CASE WHEN {rel_name}.branch = "-global-" THEN {rel_name}.branch_level ELSE $branch_level END
""")
subquery.append("RETURN peer_node as p2")
return "\n".join(subquery)

Expand All @@ -38,10 +49,10 @@ async def query_init(self, db: InfrahubDatabase, **kwargs: dict[str, Any]) -> No

self.params["current_time"] = self.at.to_string()
self.params["branch_name"] = self.branch.name
self.params["branch"] = self.branch.name
self.params["branch_level"] = self.branch.hierarchy_level

self.params["rel_props"] = {
"branch": self.branch.name,
"branch_level": self.branch.hierarchy_level,
"status": RelationshipStatus.DELETED.value,
"from": self.at.to_string(),
}
Expand Down Expand Up @@ -99,7 +110,7 @@ def render_node_remove_query(self, branch_filter: str) -> str:
%(sub_query)s
}
WITH p2 as peer_node, rel_inband, active_node
FOREACH (i in CASE WHEN rel_inband.branch = $branch_name THEN [1] ELSE [] END |
FOREACH (i in CASE WHEN rel_inband.branch IN ["-global-", $branch] THEN [1] ELSE [] END |
SET rel_inband.to = $current_time
)
""" % {"sub_query": sub_query, "branch_filter": branch_filter}
Expand All @@ -108,7 +119,9 @@ def render_node_remove_query(self, branch_filter: str) -> str:
def render_sub_query_in(self) -> str:
sub_queries_in = [
self.render_sub_query_per_rel_type(
rel_name="rel_inband", rel_type=rel_type, rel_def=rel_def, direction=GraphRelDirection.INBOUND
rel_name="rel_inband",
rel_type=rel_type,
rel_def=rel_def,
)
for rel_type, rel_def in GraphNodeRelationships.model_fields.items()
]
Expand Down Expand Up @@ -142,8 +155,7 @@ def render_node_remove_query(self, branch_filter: str) -> str:
CALL {
%(sub_query)s
}
WITH p2 as peer_node, rel_outband, active_node
FOREACH (i in CASE WHEN rel_outband.branch = $branch_name THEN [1] ELSE [] END |
FOREACH (i in CASE WHEN rel_outband.branch IN ["-global-", $branch] THEN [1] ELSE [] END |
SET rel_outband.to = $current_time
)
""" % {"sub_query": sub_query, "branch_filter": branch_filter}
Expand All @@ -153,7 +165,9 @@ def render_node_remove_query(self, branch_filter: str) -> str:
def render_sub_query_out(self) -> str:
sub_queries_out = [
self.render_sub_query_per_rel_type(
rel_name="rel_outband", rel_type=rel_type, rel_def=rel_def, direction=GraphRelDirection.OUTBOUND
rel_name="rel_outband",
rel_type=rel_type,
rel_def=rel_def,
)
for rel_type, rel_def in GraphNodeRelationships.model_fields.items()
]
Expand Down
Loading
Loading