Skip to content

Commit

Permalink
Merge branch 'main' into bug/templateId-test
Browse files Browse the repository at this point in the history
  • Loading branch information
MateusMolina committed Dec 9, 2024
2 parents bf33a8b + 09fb94e commit 1003de7
Show file tree
Hide file tree
Showing 40 changed files with 532 additions and 70 deletions.
141 changes: 141 additions & 0 deletions .github/workflows/docker-snapshot-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
name: Build and Push Docker Images on PR Merge

on:
push:
branches:
- main
paths-ignore:
- '.github/ISSUE_TEMPLATE/**'
- '.github/CODE_OF_CONDUCT.md'
- '.github/CODING_CONVENTIONS.md'
- '.github/CONTRIBUTING.md'
- '.github/dependabot.yml'
- '.github/pull_request_template.md'
- '.github/SECURITY.md'
- 'docs/**'
- 'examples/**'
- 'README.md'
- '.gitattributes'
- '.gitignore'
- 'LICENSE'
- 'NOTICE'

env:
DOCKER_NAMESPACE: eclipsebasyx

jobs:
build-and-push-prerelease:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- name: aas-environment
path: basyx.aasenvironment/basyx.aasenvironment.component
- name: aas-repository
path: basyx.aasrepository/basyx.aasrepository.component
- name: submodel-repository
path: basyx.submodelrepository/basyx.submodelrepository.component
- name: conceptdescription-repository
path: basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository.component
- name: aas-discovery
path: basyx.aasdiscoveryservice/basyx.aasdiscoveryservice.component
- name: aasxfileserver
path: basyx.aasxfileserver/basyx.aasxfileserver.component
- name: aas-registry-kafka-mem
path: basyx.aasregistry/basyx.aasregistry-service-release-kafka-mem/src/main/docker
- name: aas-registry-kafka-mongodb
path: basyx.aasregistry/basyx.aasregistry-service-release-kafka-mongodb/src/main/docker
- name: aas-registry-log-mem
path: basyx.aasregistry/basyx.aasregistry-service-release-log-mem/src/main/docker
- name: aas-registry-log-mongodb
path: basyx.aasregistry/basyx.aasregistry-service-release-log-mongodb/src/main/docker
- name: submodel-registry-kafka-mem
path: basyx.submodelregistry/basyx.submodelregistry-service-release-kafka-mem/src/main/docker
- name: submodel-registry-kafka-mongodb
path: basyx.submodelregistry/basyx.submodelregistry-service-release-kafka-mongodb/src/main/docker
- name: submodel-registry-log-mem
path: basyx.submodelregistry/basyx.submodelregistry-service-release-log-mem/src/main/docker
- name: submodel-registry-log-mongodb
path: basyx.submodelregistry/basyx.submodelregistry-service-release-log-mongodb/src/main/docker

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: linux/amd64,linux/arm64,linux/arm/v7

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven

- name: Build all modules first
run: mvn clean install -DskipTests

# Build the project
# For registry modules, we activate the dockerbuild profile and specify the module with --pl
- name: Build BaSyx
run: |
if [[ "${{ matrix.name }}" == *"registry"* ]]; then
# Derive the module's artifactId from the path
module_root=$(dirname "$(dirname "$(dirname "${{ matrix.path }}")")")
artifact_id=$(basename "$module_root")
# Run with dockerbuild profile and namespace
mvn clean install -DskipTests -Pdockerbuild "-Ddocker.namespace=${{ env.DOCKER_NAMESPACE }}" --pl "org.eclipse.digitaltwin.basyx:${artifact_id}"
else
echo "Non-registry module - already built in the previous step."
fi
- name: Prepare Registry JAR for Docker
if: contains(matrix.name, 'registry')
run: |
# Go three levels up from src/main/docker to get the module root
module_root=$(dirname "$(dirname "$(dirname "${{ matrix.path }}")")")
# Adjust the path to where the dockerbuild profile places the JAR
JAR_FILE=$(ls "$module_root/target/docker/${{ env.DOCKER_NAMESPACE }}/${{ matrix.name }}/2.0.0-SNAPSHOT/build/maven/"*.jar | head -n 1)
if [ -z "$JAR_FILE" ]; then
echo "No repackaged JAR found in $module_root/target/docker/${{ env.DOCKER_NAMESPACE }}/${{ matrix.name }}/2.0.0-SNAPSHOT/build/maven. Check your build."
exit 1
fi
# Create the maven directory inside the Docker context and copy the JAR there
mkdir -p "${{ matrix.path }}/maven"
cp "$JAR_FILE" "${{ matrix.path }}/maven/"
# Extract the final name without .jar extension
FINAL_NAME=$(basename "$JAR_FILE" .jar)
echo "FINAL_ARGS=FINAL_NAME=${FINAL_NAME}" >> $GITHUB_ENV
- name: No-Op for Non-Registry Modules
if: "!contains(matrix.name, 'registry')"
run: echo "FINAL_ARGS=" >> $GITHUB_ENV

- name: Build and Push Docker Image
uses: docker/build-push-action@v6
with:
context: ${{ matrix.path }}
file: ${{ matrix.path }}/Dockerfile
push: true
platforms: linux/amd64,linux/arm64,linux/arm/v7
tags: |
${{ env.DOCKER_NAMESPACE }}/${{ matrix.name }}:2.0.0-SNAPSHOT
build-args: ${{ env.FINAL_ARGS }}

- name: Verify Docker Image
run: |
docker pull ${{ env.DOCKER_NAMESPACE }}/${{ matrix.name }}:2.0.0-SNAPSHOT
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM eclipse-temurin:17
ARG HTTP_PROXY
ARG HTTPS_PROXY
USER nobody
WORKDIR /application
ARG JAR_FILE=target/*-exec.jar
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM eclipse-temurin:17
ARG HTTP_PROXY
ARG HTTPS_PROXY
USER nobody
WORKDIR /application
ARG JAR_FILE=target/*-exec.jar
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
FROM eclipse-temurin:17 as builder
COPY maven/${project.build.finalName}.jar ./
RUN java -Djarmode=layertools -jar ${project.build.finalName}.jar extract
ARG HTTP_PROXY
ARG HTTPS_PROXY
ARG FINAL_NAME=${project.build.finalName}
COPY maven/${FINAL_NAME}.jar ./
RUN java -Djarmode=layertools -jar ${FINAL_NAME}.jar extract

FROM eclipse-temurin:17
RUN mkdir /workspace
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
FROM eclipse-temurin:17 as builder
COPY maven/${project.build.finalName}.jar ./
RUN java -Djarmode=layertools -jar ${project.build.finalName}.jar extract
ARG HTTP_PROXY
ARG HTTPS_PROXY
ARG FINAL_NAME=${project.build.finalName}
COPY maven/${FINAL_NAME}.jar ./
RUN java -Djarmode=layertools -jar ${FINAL_NAME}.jar extract

FROM eclipse-temurin:17
ARG HTTP_PROXY
ARG HTTPS_PROXY
RUN mkdir /workspace
WORKDIR /workspace
COPY --from=builder dependencies/ ./
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
FROM eclipse-temurin:17 as builder
COPY maven/${project.build.finalName}.jar ./
RUN java -Djarmode=layertools -jar ${project.build.finalName}.jar extract
ARG HTTP_PROXY
ARG HTTPS_PROXY
ARG FINAL_NAME=${project.build.finalName}
COPY maven/${FINAL_NAME}.jar ./
RUN java -Djarmode=layertools -jar ${FINAL_NAME}.jar extract

FROM eclipse-temurin:17
ARG HTTP_PROXY
ARG HTTPS_PROXY
RUN mkdir /workspace
WORKDIR /workspace
COPY --from=builder dependencies/ ./
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
FROM eclipse-temurin:17 as builder
COPY maven/${project.build.finalName}.jar ./
RUN java -Djarmode=layertools -jar ${project.build.finalName}.jar extract
ARG HTTP_PROXY
ARG HTTPS_PROXY
ARG FINAL_NAME=${project.build.finalName}
COPY maven/${FINAL_NAME}.jar ./
RUN java -Djarmode=layertools -jar ${FINAL_NAME}.jar extract

FROM eclipse-temurin:17
ARG HTTP_PROXY
ARG HTTPS_PROXY
RUN mkdir /workspace
WORKDIR /workspace
COPY --from=builder dependencies/ ./
Expand Down
15 changes: 15 additions & 0 deletions basyx.aasregistry/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

<properties>
<lombok.maven-plugin.version>1.18.20.0</lombok.maven-plugin.version>
<lombok.maven-plugin.lombok.version>1.18.30</lombok.maven-plugin.lombok.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -75,6 +76,13 @@
<groupId>org.projectlombok</groupId>
<artifactId>lombok-maven-plugin</artifactId>
<version>${lombok.maven-plugin.version}</version>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.maven-plugin.lombok.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -241,6 +249,13 @@
<plugin>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-maven-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.maven-plugin.lombok.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<phase>generate-sources</phase>
Expand Down
2 changes: 2 additions & 0 deletions basyx.aasrepository/basyx.aasrepository.component/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM eclipse-temurin:17
ARG HTTP_PROXY
ARG HTTPS_PROXY
USER nobody
WORKDIR /application
ARG JAR_FILE=target/*-exec.jar
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM eclipse-temurin:17
ARG HTTP_PROXY
ARG HTTPS_PROXY
USER nobody
WORKDIR /application
ARG JAR_FILE=target/*-exec.jar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

package org.eclipse.digitaltwin.basyx.common.mqttcore.serializer;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.DeserializationException;
Expand Down Expand Up @@ -72,6 +74,34 @@ public static String serializeSubmodelElement(SubmodelElement submodelElement) {
throw new RuntimeException(e);
}
}

/**
* Serializer to create a JSON String for the given submodel elements.
*
* @param submodelElement
* @return serialized list of submodelElements as JSON String
*/
public static String serializeSubmodelElements(List<SubmodelElement> submodelElements) {
try {
List<SubmodelElement> updatedSubmodelElements = new ArrayList<>();

for(int i = 0; i < submodelElements.size(); i++) {
SubmodelElement elem = submodelElements.get(i);
SubmodelElement localElement;
if (shouldSendEmptyValueEvent(elem)) {
localElement = getSubmodelElementWithoutValue(elem);
} else {
localElement = elem;
}

updatedSubmodelElements.add(localElement);
}

return new JsonSerializer().writeList(updatedSubmodelElements);
} catch (SerializationException | DeserializationException e) {
throw new RuntimeException(e);
}
}

/**
* Generator to create a copy of a submodelElement without its value.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM eclipse-temurin:17
ARG HTTP_PROXY
ARG HTTPS_PROXY
USER nobody
WORKDIR /application
ARG JAR_FILE=target/*-exec.jar
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
FROM eclipse-temurin:17 as builder
COPY maven/${project.build.finalName}.jar ./
RUN java -Djarmode=layertools -jar ${project.build.finalName}.jar extract
ARG HTTP_PROXY
ARG HTTPS_PROXY
ARG FINAL_NAME=${project.build.finalName}
COPY maven/${FINAL_NAME}.jar ./
RUN java -Djarmode=layertools -jar ${FINAL_NAME}.jar extract

FROM eclipse-temurin:17
ARG HTTP_PROXY
ARG HTTPS_PROXY
RUN mkdir /workspace
WORKDIR /workspace
COPY --from=builder dependencies/ ./
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
FROM eclipse-temurin:17 as builder
COPY maven/${project.build.finalName}.jar ./
RUN java -Djarmode=layertools -jar ${project.build.finalName}.jar extract
ARG HTTP_PROXY
ARG HTTPS_PROXY
ARG FINAL_NAME=${project.build.finalName}
COPY maven/${FINAL_NAME}.jar ./
RUN java -Djarmode=layertools -jar ${FINAL_NAME}.jar extract

FROM eclipse-temurin:17
ARG HTTP_PROXY
ARG HTTPS_PROXY
RUN mkdir /workspace
WORKDIR /workspace
COPY --from=builder dependencies/ ./
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
FROM eclipse-temurin:17 as builder
COPY maven/${project.build.finalName}.jar ./
RUN java -Djarmode=layertools -jar ${project.build.finalName}.jar extract
ARG HTTP_PROXY
ARG HTTPS_PROXY
ARG FINAL_NAME=${project.build.finalName}
COPY maven/${FINAL_NAME}.jar ./
RUN java -Djarmode=layertools -jar ${FINAL_NAME}.jar extract

FROM eclipse-temurin:17
ARG HTTP_PROXY
ARG HTTPS_PROXY
RUN mkdir /workspace
WORKDIR /workspace
COPY --from=builder dependencies/ ./
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
FROM eclipse-temurin:17 as builder
COPY maven/${project.build.finalName}.jar ./
RUN java -Djarmode=layertools -jar ${project.build.finalName}.jar extract
ARG HTTP_PROXY
ARG HTTPS_PROXY
ARG FINAL_NAME=${project.build.finalName}
COPY maven/${FINAL_NAME}.jar ./
RUN java -Djarmode=layertools -jar ${FINAL_NAME}.jar extract

FROM eclipse-temurin:17
ARG HTTP_PROXY
ARG HTTPS_PROXY
RUN mkdir /workspace
WORKDIR /workspace
COPY --from=builder dependencies/ ./
Expand Down
2 changes: 1 addition & 1 deletion basyx.submodelregistry/open-api/patch-base-extensions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
value: "^(0|[1-9][0-9]{0,3})$"
- op: replace
path: /components/schemas/AdministrativeInformation/allOf/1/properties/templateId/pattern
value: "^([\\t\\n\\r \\ud7ff\\ue000-\\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$"
value: "^([\\x09\\x0a\\x0d\\x20-\\ud7ff\\ue000-\\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$"
## EmbeddedDataSpecification
- op: replace
path: /components/schemas/EmbeddedDataSpecification/properties/dataSpecificationContent/$ref
Expand Down
Loading

0 comments on commit 1003de7

Please sign in to comment.