From 7e01eec09c80c0caf5c58eaeb4c94bf2aa9ecfee Mon Sep 17 00:00:00 2001 From: ewuerger Date: Fri, 6 Oct 2023 10:50:59 +0200 Subject: [PATCH] wip: First version --- .../github/model-validation/action.yml | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 ci-templates/github/model-validation/action.yml diff --git a/ci-templates/github/model-validation/action.yml b/ci-templates/github/model-validation/action.yml new file mode 100644 index 00000000..e3d51d29 --- /dev/null +++ b/ci-templates/github/model-validation/action.yml @@ -0,0 +1,64 @@ +# SPDX-FileCopyrightText: Copyright DB Netz AG and the capella-collab-manager contributors +# SPDX-License-Identifier: Apache-2.0 + +name: "Capella Model-Validation" +description: "An action to validate a Capella model." + +inputs: + entry_point: + description: "The entry point of the used model" + capella_version: + description: "The version of the Capella model" + capella_docker_images_revision: + description: "The revision of capella-dockerimages to use" + default: main + capella_docker_images_dropins: + description: "Please have a look at https://dsd-dbs.github.io/capella-dockerimages/capella/introduction/#supported-dropins" + required: false + default: selected + github_token: + description: "The GitHub token for authentication" + +runs: + using: "composite" + steps: + - name: Set up Python 3.11 + uses: actions/setup-python@v3 + with: + python-version: 3.11 + - name: Authenticate to GitHub Container Registry + shell: bash + run: docker login ghcr.io -u DSD-DBS --password-stdin <<< "${{ inputs.github_token }}" + - name: Pull Capella Docker image + shell: bash + env: + IMAGE_TAG: ${{ inputs.capella_version }}-${{ inputs.capella_docker_images_dropins }}-dropins-${{ inputs.capella_docker_images_revision }} + run: docker pull ghcr.io/dsd-dbs/capella-dockerimages/capella/base:$IMAGE_TAG + - name: Prepare workspace + shell: bash + env: + REVISION: $(echo ${{ github.ref }} | cut -d'/' -f3) + run: | + git config --global --add safe.directory $GITHUB_WORKSPACE + git fetch + [ ! -z $REVISION ] && git reset --hard origin/$REVISION + mkdir -p /tmp/project + cp -r . /tmp/project + - name: Validate Capella Model + shell: bash + env: + IMAGE_TAG: ${{ inputs.capella_version }}-${{ inputs.capella_docker_images_dropins }}-dropins-${{ inputs.capella_docker_images_revision }} + DISPLAY: ":99" # Virtual display used to run Capella in the background. Do not modify the value! + run: | + echo $DISPLAY + docker run --name capella-pod -v /tmp/project:/tmp/project -e DISPLAY=$DISPLAY -d ghcr.io/dsd-dbs/capella-dockerimages/capella/base:$IMAGE_TAG --entrypoint /bin/sh -c "while sleep 3600; do :; done" + docker exec capella-pod xvfb-run -a /opt/capella/capella -nosplash -application org.polarsys.capella.core.commandline.core -appid org.polarsys.capella.core.validation.commandline -data "/tmp/project" -input "project/{{ inputs.entry_point }}" -outputfolder "project/validation" + docker cp capella-pod:/tmp/MDEReport.html $BUILD_DIR + cp /tmp/project/validation/project/{{ inputs.entry_point }}/validation-results.html $BUILD_DIR + - name: Archive model-validation in artifacts + uses: actions/upload-artifact@v3 + env: + ARTIFACTS: $(pwd) + with: + name: Validation reports + path: ARTIFACTS