Skip to content

Commit

Permalink
Merge pull request #99 from com-pas/develop
Browse files Browse the repository at this point in the history
New release
  • Loading branch information
Dennis Labordus authored Aug 8, 2022
2 parents 0251a9c + c972808 commit f15abbb
Show file tree
Hide file tree
Showing 14 changed files with 767 additions and 48 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 15
timeout-minutes: 30

steps:
- name: Checkout
Expand All @@ -39,11 +39,11 @@ jobs:
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Set up JDK 1.11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
java-version: '17'

- name: Create custom Maven Settings.xml
uses: whelk-io/maven-settings-xml-action@v20
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/release-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
push_to_registry:
name: Build and publish
runs-on: ubuntu-latest
timeout-minutes: 30

steps:
- name: Checkout
Expand Down Expand Up @@ -43,11 +44,11 @@ jobs:
shell: bash
# Extra the tagname form the git reference, value of GITHUB_REF will be something like refs/tags/<tag_name>.
run: echo "##[set-output name=tagname;]$(echo ${GITHUB_REF##*/})"
- name: Set up JDK 1.11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
java-version: '17'

- name: Create custom Maven Settings.xml
uses: whelk-io/maven-settings-xml-action@v20
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/sonarcloud-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
build:
name: SonarCloud
runs-on: ubuntu-latest
timeout-minutes: 15
timeout-minutes: 30

if: ${{ (github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]') || (github.actor == 'dependabot[bot]' && github.event_name == 'pull_request_target') }}
steps:
Expand All @@ -31,11 +31,11 @@ jobs:
fetch-depth: 0
submodules: 'true'

- name: Set up JDK 1.11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
java-version: '17'
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
Expand Down
20 changes: 18 additions & 2 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.1/apache-maven-3.8.1-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
113 changes: 103 additions & 10 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,29 @@ SPDX-FileCopyrightText: 2022 Alliander N.V.
SPDX-License-Identifier: Apache-2.0
-->

# Development
# Development for CoMPAS SCL Validator


---
**Note**
Mac M1 chip users, see [below](#mac-m1)

---


Since version 1.2.x the JAR Files of RiseClipse are distributed through Maven Central Repository. The JAR Files can be
retrieved from there and don't need to be build locally anymore. Only the OCL Files for the SCL validation still need to
be downloaded from RiseClipse GIT Repository. This is still done using Git Submodules.

To clone the project or update the project this means that the Git commands are sometimes a little different. To clone
the project use the following command `git clone --recurse-submodules [email protected]:com-pas/compas-scl-validator.git`.
This will also clone the submodules.

Tip: The URL to the submodules are configured in the file `.gitmodules`, but these are using the SSH URL. There is a way
described [here](https://git-scm.com/book/en/v2/Git-Tools-Submodules) to overwrite the URL locally with an HTTPS URL of
the GIT Repository.

Check the [Development](DEVELOPMENT.md) page for more detail information how to develop in this GIT repository.

## Git

Expand Down Expand Up @@ -56,6 +78,22 @@ maven module is created here, see [README.md](riseclipse/riseclipse-p2-to-m2/REA
Example about how to use Eclipse OCL was found
[here](https://help.eclipse.org/latest/index.jsp?topic=%2Forg.eclipse.ocl.doc%2Fhelp%2FPivotStandalone.html).

## Building the application

You can use Maven to build the application and see if all tests are working using:

```shell script
./mvnw clean verify
```

This should normally be enough to also run the application, but there were cases that we need to build using:

```shell script
./mvnw clean install
```

This to make the local modules available for the app module to run the application.

## Running the application in dev mode

You can run your application in dev mode that enables live coding using:
Expand All @@ -66,22 +104,77 @@ You can run your application in dev mode that enables live coding using:

> **_NOTE:_** Quarkus now ships with a Dev UI, which is available in dev mode only at http://localhost:8080/q/dev/.
## Packaging and running the application
### Application depends on a running KeyCloak instance for dev mode

The application can be packaged using:
There is a KeyCloak instance need to be running on port 8089 by default in dev mode.
See [Security](README.md#security) for default values, if custom keycloak is used.

```shell script
./mvnw package
There is a preconfigured keycloak instance available in
the [CoMPAS Deployment Repository](https://github.com/com-pas/compas-deployment). This repository can be cloned and
when going to this directory the following command can be executed to create a local Docker Image with configuration.

```shell
cd <CoMPAS Deployment Repository Directory>/compas/keycloak
docker build -t compas_keycloak .
```

It produces the `quarkus-run.jar` file in the `app/target/quarkus-app/` directory. Be aware that it’s not an _über-jar_
as the dependencies are copied into the `app/target/quarkus-app/lib/` directory.
There is now a Docker Image `compas_keycloak` created that can be started using the following command

```shell
docker run --rm --name compas_keycloak \
-p 8089:8080
-d compas_keycloak:latest
```

## Testing the application

The application is tested with unit and integration tests, but you can also manually test the application using for
instance Postman. And there is also a way to test this service with the CoMPAS OpenSCD Frontend application.

### Postman

To manually test the application there is a Postman collection in the directory `postman` that can be imported
and used to execute REST XML Calls.

To make the call work we also need to import an environment and authorisation collection. These files can be found
in [CoMPAS Deployment Repository](https://github.com/com-pas/compas-deployment) in the directory `postman`
(`auth.collection.json` and `local.environment.json`).

In the authorisation collection there are called for the 3 users known within the Demo KeyCloak instance.
If one of these calls are executed there is a variable `bearer` filled.

Now one of the SCL Auto Alignment calls can be executed, the variable `bearer` is added to the header of the request.
After the call is executed the result should be shown in Postman.

If you want to build an _über-jar_, execute the following command:
### CoMPAS OpenSCD Frontend application

To test the SCL Validator with the CoMPAS OpenSCD application just run the application in dev mode, including the
KeyCloak instance. For further instruction how to start the CoMPAS OpenSCD application and use this locally see
the file `DEVELOPMENT.md` in [CoMPAS OpenSCD application](https://github.com/com-pas/compas-open-scd).

## Docker Images

### Creating a Docker image with native executable

The CoMPAS SCL Validator currently isn't build as Native executable, GraalVM has a lot of problems to strip the
Eclipse libraries and make them work as Native executable.

### Creating a Docker image with JVM executable

The release action is creating a Docker Image which runs the application using a JVM. You can create a Docker Image
with JVM executable using:

```shell script
./mvnw package -Dquarkus.package.type=uber-jar
./mvnw package -Pjvm-image
```

The application is now runnable using `java -jar app/target/quarkus-app/quarkus-run.jar`.
## Mac M1

The Mac M1 chip is ARM based. In order to make this project work, you need to install the x86 version of your IDE.
You also need Rosetta2 to virtualize your os. In the x86 version of your IDE, you also need to install the x86 Java version.
You can use SDK-Man to easily switch between java versions.

While calling maven scripts, you need to add the os.arch flag.
```shell script
./mvnw clean compile -Dos.arch=x86_64
```
16 changes: 2 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SPDX-License-Identifier: Apache-2.0
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/5925/badge)](https://bestpractices.coreinfrastructure.org/projects/5925)
[![Slack](https://raw.githubusercontent.com/com-pas/compas-architecture/master/public/LFEnergy-slack.svg)](http://lfenergy.slack.com/)

# compas-scl-validator
# CoMPAS SCL Validator

Service to validate SCL Files.

Expand All @@ -28,19 +28,7 @@ automatically determine the URL to be used.

## Development

Since version 1.2.x the JAR Files of RiseClipse are distributed through Maven Central Repository. The JAR Files can be
retrieved from there and don't need to be build locally anymore. Only the OCL Files for the SCL validation still need to
be downloaded from RiseClipse GIT Repository. This is still done using Git Submodules.

To clone the project or update the project this means that the Git commands are sometimes a little different. To clone
the project use the following command `git clone --recurse-submodules [email protected]:com-pas/compas-scl-validator.git`.
This will also clone the submodules.

Tip: The URL to the submodules are configured in the file `.gitmodules`, but these are using the SSH URL. There is a way
described [here](https://git-scm.com/book/en/v2/Git-Tools-Submodules) to overwrite the URL locally with an HTTPS URL of
the GIT Repository.

Check the [Development](DEVELOPMENT.md) page for more detail information how to develop in this GIT repository.
Information about how to run and develop for this project check [Development](DEVELOPMENT.md).

## Custom OCL Files

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/docker/Dockerfile.jvm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
###
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.6

ARG JAVA_PACKAGE=java-11-openjdk-headless
ARG JAVA_PACKAGE=java-17-openjdk-headless
ARG RUN_JAVA_VERSION=1.3.8
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en'
# Install java and the run-java script
Expand Down
5 changes: 2 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ SPDX-License-Identifier: Apache-2.0

<properties>
<maven.compiler.parameters>true</maven.compiler.parameters>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.release>17</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

Expand All @@ -27,7 +26,7 @@ SPDX-License-Identifier: Apache-2.0
<compas.scl.xsd.version>0.0.4</compas.scl.xsd.version>
<compas.core.version>0.9.1</compas.core.version>

<quarkus.platform.version>2.10.1.Final</quarkus.platform.version>
<quarkus.platform.version>2.10.3.Final</quarkus.platform.version>
<slf4j.version>1.7.36</slf4j.version>
<openpojo.version>0.9.1</openpojo.version>
</properties>
Expand Down
Loading

0 comments on commit f15abbb

Please sign in to comment.