Skip to content

Commit

Permalink
feat: testbed impl
Browse files Browse the repository at this point in the history
* chore: cleanup

* feat: addition of some valueobjects and cleanup

* feat: additional valueobjects

* feat: use java instead of JSON template for pipeline creation

* feat: extract event stream properties

* feat: event stream properties fetched + managers cleaned up + busy waiting fixed

* feat: little improvements

* feat: refactor Request

* fix: broken ldes client status

* WIP

* feat: shacl validation

* WIP

* feat: impl finished

* chore: big cleanup

* feat: pipelinename is distinct for each run

* ci: add workflows

* chore: add CODEOWNERS

* chore: update README part 1

* ci: release process updated

* feat: better naming for a param

* fix: broken gh actions

* fix: broken cicd pipeline
  • Loading branch information
jobulcke authored Aug 28, 2024
1 parent fe7c29a commit 8928c15
Show file tree
Hide file tree
Showing 74 changed files with 2,014 additions and 1,490 deletions.
13 changes: 13 additions & 0 deletions .github/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#
# RUN THE APPLICATION
#
FROM amazoncorretto:21-alpine-jdk

WORKDIR /validator

COPY ./target/testbed-shacl-validator.jar testbed-shacl-validator.jar

RUN adduser -D -u 2000 validator
USER validator

CMD ["java", "-jar", "testbed-shacl-validator.jar"]
67 changes: 67 additions & 0 deletions .github/workflows/build-project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: 1.a Build & Test Project
on:
pull_request:
types: [ opened, synchronize, reopened ]
workflow_dispatch:

jobs:
build:
name: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'zulu'
# TODO: setup sonar
# - name: Cache SonarCloud packages
# uses: actions/cache@v1
# with:
# path: ~/.sonar/cache
# key: ${{ runner.os }}-sonar
# restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven packages
uses: actions/cache@v1
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build and analyze
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -B verify
- name: Build (Forks) # https://portal.productboard.com/sonarsource/1-sonarcloud/c/50-sonarcloud-analyzes-external-pull-request
if: ${{ github.actor == 'dependabot[bot]' || github.event.pull_request.head.repo.fork }}
run: mvn -B verify
- name: Upload JARs
uses: actions/upload-artifact@v2
with:
name: artifacts
path: |
**/testbed-shacl-validator.jar
build-and-push-image:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Download JARs
uses: actions/download-artifact@v2
with:
name: artifacts
path: .github
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .github
push: false
110 changes: 110 additions & 0 deletions .github/workflows/pr-merged.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: 2. Build & Deploy Project

on:
release:
types: [ published ]
push:
branches:
- main
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: testbed-shacl-validator

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 21
- name: Cache Maven packages
uses: actions/cache@v1
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
# TODO: setup Maven
# # Maven
# - name: Set up Maven Central Repository
# uses: actions/setup-java@v4
# with:
# java-version: '21'
# distribution: 'zulu'
# server-id: ossrh
# server-username: MAVEN_USERNAME
# server-password: MAVEN_PASSWORD
# gpg-private-key: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
# gpg-passphrase: MAVEN_GPG_PASSPHRASE
# TODO: setup Sonar
- name: Analyse & publish package
run: |
mvn -B verify deploy
export VERSION=$(mvn help:evaluate -Dexpression="project.version" -q -DforceStdout)
echo "version=$VERSION" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload JARs
uses: actions/upload-artifact@v2
with:
name: artifacts
path: |
**/testbed-shacl-validator.jar
create-image:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Download JARs
uses: actions/download-artifact@v2
with:
name: artifacts
path: .github
- name: Define docker variables
run: |
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
echo "IMAGE_TAG=${{ env.version }}" >> $GITHUB_ENV
echo "IMAGES=ldes/${{ env.IMAGE_NAME }}" >> $GITHUB_ENV
if [[ "${{ env.version }}" != *"SNAPSHOT"* ]]; then
echo "LATEST=latest" >> $GITHUB_ENV
fi
else
echo "IMAGE_TAG=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV
echo "IMAGES=${{ env.REGISTRY }}/Informatievlaanderen/${{ env.IMAGE_NAME }}" >> $GITHUB_ENV
echo "LATEST=latest" >> $GITHUB_ENV
fi
# TODO: push to docker
- name: Log in to the GitHub Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: Informatievlaanderen
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.IMAGES }}
tags: |
type=raw,value=${{env.IMAGE_TAG}}
type=raw,value=${{env.LATEST}}
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .github
push: true
tags: ${{ steps.meta.outputs.tags }}
platforms: linux/amd64,linux/arm64
2 changes: 2 additions & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* @Yalz @rorlic @jobulcke

35 changes: 10 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,7 @@

This application implements the [GITB test service APIs](https://www.itb.ec.europa.eu/docs/services/latest/) in a
[Spring Boot](https://spring.io/projects/spring-boot) web application that is meant to support
[GITB TDL test cases](https://www.itb.ec.europa.eu/docs/tdl/latest/) running in the Interoperability Test Bed.

## Messaging service implementation

The sample messaging service is used by the Test Bed to send and receive a text message. When told to `send` a message
this service simply logs it. Regarding received messages, these are provided via HTTP GET call upon which time the
appropriate active test sessions get notified via callback. To manually complete a pending 'receive' call, make a GET
request to http://localhost:8080/input?message=MESSAGE&session=SESSION in which you set the 'MESSAGE' placeholder to the
text to send back, and the 'SESSION' placeholder to the test session ID to notify. Note that the 'session' parameter can
be altogether skipped to notify all pending test sessions.

Once running, the messaging endpoint's WDSL is available at http://localhost:8080/services/messaging?WSDL. See
[here](https://www.itb.ec.europa.eu/docs/services/latest/messaging/) for further information on messaging service implementations.

## Processing service implementation

The sample processing service is used by the Test Bed to lowercase or uppercase a given text input.

Once running, the processing endpoint's WDSL is available at http://localhost:8080/services/process?WSDL. See
[here](https://www.itb.ec.europa.eu/docs/services/latest/processing/) for further information on validation service implementations.
[GITB TDL test cases](https://www.itb.ec.europa.eu/docs/tdl/latest/) running in the Interoperability Test Bed.

## Validation service implementation

Expand All @@ -32,6 +13,10 @@ is also returned in case values match but when ignoring casing.
Once running, the validation endpoint's WDSL is available at http://localhost:8080/services/validation?WSDL. See
[here](https://www.itb.ec.europa.eu/docs/services/latest/validation/) for further information on processing service implementations.

This validation services requires in the validation call two parameters:
1. **ldes-url**: the url of the LDES to validate
2. **shacl-shape**: the shacl shape that will be used to validate the server against to

# Prerequisites

The following prerequisites are required:
Expand All @@ -41,9 +26,7 @@ The following prerequisites are required:
# Building and running

1. Build using `mvn clean package`.
2. Once built you can run the application in two ways:
a. With maven: `mvn spring-boot:run`.
b. Standalone: `java -jar ./target/validator-VERSION.jar`.
2. Once built you can run the application using `mvn spring-boot:run`.

## Live reload for development

Expand All @@ -59,6 +42,8 @@ through Maven:
1. Build the JAR file with `mvn package`.
2. Build the Docker image with `mvn dockerfile:build`.

### Running the Docker container
[//]: # (TODO: how to run)
[//]: # (### Running the Docker container)

Assuming an image name of `local/validator`, it can be ran using `docker --name validator -p 8080:8080 -d local/validator`.
[//]: # ()
[//]: # (Assuming an image name of `local/validator`, it can be ran using `docker --name validator -p 8080:8080 -d local/validator`.)
41 changes: 22 additions & 19 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<version>3.3.1</version>
</parent>
<groupId>be.vlaanderen.informatievlaanderen.ldes</groupId>
<artifactId>validator</artifactId>
<version>1.0-SNAPSHOT</version>
<artifactId>testbed-shacl-validator</artifactId>
<version>1.0.0-SNAPSHOT</version>
<properties>
<!-- Dependency and plugin versions. -->
<com.gitb.version>1.23.1</com.gitb.version>
Expand All @@ -21,7 +21,8 @@
<docker.image.prefix>local</docker.image.prefix>

<scribejava.version>8.3.3</scribejava.version>
<rdf4j.version>4.3.6</rdf4j.version>
<rdf4j.version>4.3.5</rdf4j.version>
<jetbrains-annotations.version>24.1.0</jetbrains-annotations.version>
</properties>
<dependencies>
<dependency>
Expand All @@ -48,6 +49,11 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>${jetbrains-annotations.version}</version>
</dependency>


<dependency>
Expand All @@ -74,38 +80,35 @@
</dependency>
<dependency>
<groupId>org.eclipse.rdf4j</groupId>
<artifactId>rdf4j-client</artifactId>
<artifactId>rdf4j-runtime</artifactId>
<type>pom</type>
<version>4.3.5</version>
<!-- <version>${rdf4j.version}</version>-->
<version>${rdf4j.version}</version>
<exclusions>
<exclusion>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<!-- Used to create an executable JAR file. -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>be.vlaanderen.informatievlaanderen.ldes.Application</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>build-info</goal>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Used to build a Docker image if Docker is natively supported. -->
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>${com.spotify.dockerfile-maven-plugin.version}</version>
<configuration>
<repository>${docker.image.prefix}/${project.artifactId}</repository>
<buildArgs>
<JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
</buildArgs>
</configuration>
</plugin>
</plugins>
</build>
</project>

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import org.eclipse.rdf4j.model.impl.SimpleValueFactory;

public class RDFConstants {
public static String SHACL = "http://www.w3.org/ns/shacl#";
public static IRI SEVERITY = SimpleValueFactory.getInstance().createIRI(SHACL + "resultSeverity");
public static IRI VIOLATION = SimpleValueFactory.getInstance().createIRI(SHACL + "Violation");
public static IRI WARNING = SimpleValueFactory.getInstance().createIRI(SHACL + "Warning");
public static IRI INFO = SimpleValueFactory.getInstance().createIRI(SHACL + "Info");
public static final String SHACL = "http://www.w3.org/ns/shacl#";
public static final IRI SEVERITY = SimpleValueFactory.getInstance().createIRI(SHACL + "resultSeverity");
public static final IRI VIOLATION = SimpleValueFactory.getInstance().createIRI(SHACL + "Violation");
public static final IRI WARNING = SimpleValueFactory.getInstance().createIRI(SHACL + "Warning");
public static final IRI INFO = SimpleValueFactory.getInstance().createIRI(SHACL + "Info");
private RDFConstants() {
}
}
Loading

0 comments on commit 8928c15

Please sign in to comment.