Skip to content

Commit

Permalink
ci: Add gitlab CI/CD pipeline and c2p sync config
Browse files Browse the repository at this point in the history
  • Loading branch information
ewuerger authored and Wuestengecko committed Sep 23, 2024
1 parent 81ebc64 commit ce46a84
Show file tree
Hide file tree
Showing 19 changed files with 1,199 additions and 0 deletions.
69 changes: 69 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Copyright DB InfraGO AG and contributors
# SPDX-License-Identifier: CC0-1.0

include:
- remote: https://raw.githubusercontent.com/DSD-DBS/capella-dockerimages/${CAPELLA_DOCKER_IMAGES_REVISION}/ci-templates/gitlab/diagram-cache.yml
- remote: https://raw.githubusercontent.com/DSD-DBS/py-capellambse/${CAPELLAMBSE_REVISION}/ci-templates/gitlab/model-badge.yml
# - project: se-toolchain/capella-tools/rm-bridge/capella-polarion-mirror
# ref: main
# file: "/ci-templates/gitlab/synchronise_elements.yml"

default:
tags:
- docker

workflow:
rules:
- if: $CI_COMMIT_BRANCH == "master"

generate-model-badge:
image: $DOCKER_REGISTRY/base

variables:
CAPELLA_VERSION: 7.0.0
ENTRYPOINT: "In-Flight Entertainment System.aird"
CAPELLA2POLARION_PROJECT_ID: inflighttest
CAPELLA2POLARION_MODEL_JSON: '{"path": "In-Flight Entertainment System.aird", "diagram_cache": "./diagram_cache"}'
CAPELLA2POLARION_CONFIG: capella2polarion_config.yaml
CAPELLA2POLARION_DEBUG: 1
CAPELLA2POLARION_FORCE_UPDATE: 0
CAPELLAMBSE_PUSH_MODEL_BADGE: 0
CAPELLA2POLARION_DOCUMENT_CONFIG: capella2polarion_document_config.yaml.j2
CAPELLA2POLARION_OVERWRITE_LAYOUTS: 1
CAPELLA2POLARION_OVERWRITE_NUMBERING: 1

capella2polarion_synchronise_elements:
needs:
- job: update_capella_diagram_cache
artifacts: true

script:
- pip install git+https://github.com/DSD-DBS/[email protected]
- >
python \
-m capella2polarion \
$([[ $CAPELLA2POLARION_DEBUG -eq 1 ]] && echo '--debug') \
--polarion-project-id=${CAPELLA2POLARION_PROJECT_ID:?} \
--capella-model="${CAPELLA2POLARION_MODEL_JSON:?}" \
synchronize \
--synchronize-config=${CAPELLA2POLARION_CONFIG:?} \
$([[ $CAPELLA2POLARION_FORCE_UPDATE -eq 1 ]] && echo '--force-update') \
${CAPELLA2POLARION_TYPE_PREFIX:+--type-prefix="$CAPELLA2POLARION_TYPE_PREFIX"} \
${CAPELLA2POLARION_ROLE_PREFIX:+--role-prefix="$CAPELLA2POLARION_ROLE_PREFIX"}
capella2polarion_render_documents:
needs:
- job: capella2polarion_synchronise_elements

script:
- pip install git+https://github.com/DSD-DBS/[email protected]
- >
python \
-m capella2polarion \
$([[ $CAPELLA2POLARION_DEBUG -eq 1 ]] && echo '--debug') \
--polarion-project-id=${CAPELLA2POLARION_PROJECT_ID:?} \
--capella-model="${CAPELLA2POLARION_MODEL_JSON:?}" \
render-documents \
$([[ $CAPELLA2POLARION_OVERWRITE_LAYOUTS -eq 1 ]] && echo '--overwrite-layouts') \
$([[ $CAPELLA2POLARION_OVERWRITE_NUMBERING -eq 1 ]] && echo '--overwrite-numbering') \
--document-rendering-config="${CAPELLA2POLARION_DOCUMENT_CONFIG:?}"
212 changes: 212 additions & 0 deletions capella2polarion_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
# Copyright DB Netz AG and contributors
# SPDX-License-Identifier: Apache-2.0

"*": # All layers
"*": # All class types
links:
- parent # Specify workitem links
- description_reference # Custom attribute
Class:
links:
- state_machines
serializer:
add_tree_diagram:
render_params: # All defaults
edgeRouting: POLYLINE
algorithm: layered
direction: DOWN
partitioning: true
edgeLabelSide: SMART_DOWN
Diagram:
serializer: diagram
links:
- diagram_elements
- polarion_role: parent
capella_attr: target
Constraint:
serializer: linked_text_as_description

sa:
SystemComponent:
- links:
- allocated_functions
serializer: add_context_diagram
- is_actor: true
polarion_type: systemActor
- is_actor: false
polarion_type: systemComponent
SystemFunction:
links:
- polarion_role: input_exchanges
capella_attr: inputs.exchanges
include:
Exchange items: exchange_items
- polarion_role: output_exchanges
capella_attr: outputs.exchanges
include:
Exchange items: exchange_items
- polarion_role: realized_functions
capella_attr: realized_functions
serializer:
add_context_diagram:
filters:
- SHOW_EX_ITEMS # functional exchange name and exchange item name
ComponentExchange:
links:
- allocated_functional_exchanges
serializer:
jinja_as_description:
template_folder: jinja/element_templates
template_path: component_exchange.html.j2
add_context_diagram:
filters:
- SHOW_EX_ITEMS
FunctionalExchange:
links:
- exchange_items
ExchangeItem:
Capability:
polarion_type: systemCapability
serializer:
include_pre_and_post_condition:
add_context_diagram:
render_params:
display_symbols_as_boxes: true
links:
- involved_functions
- constraints
FunctionalChain:
polarion_type: functionalChain
links:
- polarion_role: involves
capella_attr: involved_functions
link_field: involved_functions

la:
LogicalComponent:
- links:
- allocated_functions
serializer:
jinja_as_description:
template_folder: jinja/element_templates
template_path: logical_component.html.j2
add_context_diagram:
filters:
- SHOW_EX_ITEMS
- is_actor: true
polarion_type: logicalActor
- is_actor: false
polarion_type: logicalComponent
CapabilityRealization:
serializer: include_pre_and_post_condition
links:
- constraints
LogicalFunction:
polarion_type: logicalFunction
serializer:
add_context_diagram:
filters:
- SHOW_EX_ITEMS
links:
- polarion_role: input_exchanges
capella_attr: inputs.exchanges
include:
Exchange Items: exchange_items
- polarion_role: output_exchanges
capella_attr: outputs.exchanges
include:
Exchange Items: exchange_items
- realized_functions
ComponentExchange:
serializer:
jinja_as_description:
template_folder: jinja/element_templates
template_path: component_exchange.html.j2
add_context_diagram:
filters:
- SHOW_EX_ITEMS
links:
- allocated_functional_exchanges
FunctionalExchange:
links:
- exchange_items
ExchangeItem:
FunctionalChain:
polarion_type: functionalChain
links:
- polarion_role: involves
capella_attr: involved_functions
link_field: involved_functions

pa:
ComponentExchange:
links:
- allocated_functional_exchanges
- exchange_items
- polarion_role: physical_links
capella_attr: allocating_physical_link
serializer:
jinja_as_description:
template_folder: jinja/element_templates
template_path: component_exchange.html.j2
add_context_diagram:
filters:
- SHOW_EX_ITEMS
FunctionalExchange:
links:
- exchange_items
PhysicalComponent:
- links:
- allocated_functions
serializer: add_context_diagram
- is_actor: false
nature: UNSET
polarion_type: physicalComponent
- is_actor: false
nature: NODE
polarion_type: physicalComponentNode
links:
- polarion_role: physical_links
capella_attr: physical_ports.links
- is_actor: false
nature: BEHAVIOR
polarion_type: physicalComponentBehavior
links:
- polarion_role: exchanges
capella_attr: related_exchanges
- is_actor: true
polarion_type: physicalActor
links:
- polarion_role: physical_links
capella_attr: physical_ports.links
- polarion_role: exchanges
capella_attr: related_exchanges
PhysicalFunction:
serializer: add_context_diagram
links:
- polarion_role: input_exchanges
capella_attr: inputs.exchanges
- polarion_role: output_exchanges
capella_attr: outputs.exchanges
PhysicalPath:
PhysicalLink:
serializer: add_context_diagram
ExchangeItem:
serializer:
jinja_as_description:
template_folder: jinja/element_templates
template_path: exchange_item.html.j2
DataPkg:
Class:
links:
- state_machines
serializer:
add_tree_diagram:
jinja_as_description:
template_folder: jinja/element_templates
template_path: class.html.j2
Property:
serializer:
jinja_as_description:
template_folder: jinja/element_templates
template_path: class_property.html.j2
116 changes: 116 additions & 0 deletions capella2polarion_document_config.yaml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# Copyright DB InfraGO AG and contributors
# SPDX-License-Identifier: Apache-2.0

full_authority:
- template_directory: jinja/document_templates
template: icd-interfaces-full_authority.html.j2
project_id: null # None -> Defaults to Sync Project
{# status_allow_list: # Only overwrite content when document has this status
- draft
- open #}
heading_numbering: True
work_item_layouts:
componentExchange:
fields_at_start:
- id
fields_at_end:
- context_diagram
physicalLink:
fields_at_start:
- id
fields_at_end:
- context_diagram
physicalActor:
fields_at_start:
- id
physicalComponentActor:
fields_at_start:
- id
physicalComponentNode:
fields_at_start:
- id
physicalComponentBehavior:
fields_at_start:
- id
class:
show_title: False
fields_at_end:
- tree_view
exchangeItem:
show_title: False
instances:
{%- for pl in model.search("PhysicalLink") %}
{%- if pl.ends %}
- polarion_space: Interface Documents
polarion_name: {{ pl.uuid }}
polarion_title: "{{ pl.name | safe }}"
params:
physical_link: {{ pl.uuid }}
{%- endif -%}
{% endfor %}
- template_directory: jinja/document_templates/logical-architecture
template: logical-component-full-authority.html.j2
heading_numbering: True
work_item_layouts:
logicalComponent:
fields_at_start:
- id
fields_at_end:
- context_diagram
logicalActor:
fields_at_start:
- id
fields_at_end:
- context_diagram
componentExchange:
fields_at_start:
- id
fields_at_end:
- context_diagram
exchangeItem:
show_title: False
instances:
{%- for cmp in model.search("LogicalComponent") %}
- polarion_space: Logical Component Documents
polarion_name: {{ cmp.uuid }}
polarion_title: "{{ cmp.name | safe }}"
params:
uuid: {{ cmp.uuid }}
{% endfor %}

mixed_authority:
- template_directory: jinja/document_templates/logical-architecture
heading_numbering: True
project_id: null
work_item_layouts:
text:
show_title: False
logicalComponent:
fields_at_start:
- id
fields_at_end:
- context_diagram
logicalActor:
fields_at_start:
- id
fields_at_end:
- context_diagram
componentExchange:
fields_at_start:
- id
fields_at_end:
- context_diagram
exchangeItem:
show_title: False
sections:
IcdContent: logical-component-mixed-authority.html.j2
instances:
- polarion_space: _default
polarion_name: Mixed authority showcase
polarion_title: Mixed authority showcase
params:
uuids:
- c8b78c78-5b11-4fc0-87b7-3ca84622efea # Aircraft
- d475ed7d-4644-4461-97d4-b52772c9b425 # Ground Operator
- 4890eae8-7a62-4d7b-bf8a-1590a199eebf # Cabin Crew
- 181a678c-dca9-46c1-9d18-b5a0c457c0de # Passenger
Loading

0 comments on commit ce46a84

Please sign in to comment.