Skip to content

Commit

Permalink
chore: move existing samples (#2)
Browse files Browse the repository at this point in the history
* chore: move existing samples

* chore: add discord-webhook.yml
  • Loading branch information
ronjaquensel authored Dec 19, 2022
1 parent 012d6d0 commit abe5bf2
Show file tree
Hide file tree
Showing 104 changed files with 5,711 additions and 178 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ Closes # <-- _insert Issue number if one exists_
- [ ] documented public classes/methods?
- [ ] documented code?
- [ ] assigned appropriate label?
- [ ] formatted title correctly? (_take a look at the [CONTRIBUTING](https://github.com/eclipse-dataspaceconnector/Samples/blob/main/CONTRIBUTING.md#submit-a-pull-request) for details_)
- [ ] formatted title correctly? (_take a look at the [CONTRIBUTING](https://github.com/eclipse-edc/Samples/blob/main/CONTRIBUTING.md#submit-a-pull-request) for details_)
21 changes: 21 additions & 0 deletions .github/actions/run-tests/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "Run tests"
description: "Run tests and archive test results for subsequent publication"
inputs:
command:
required: true
description: "The shell command to run tests"
runs:
using: "composite"
steps:
- name: Run Tests
shell: bash
run: ${{ inputs.command }}

- name: Upload Test Results
uses: actions/upload-artifact@v3
if: always()
with:
name: Test Results ${{ github.job }}
path: |
**/test-results/**/*.xml
**/build/reports/jacoco/test/jacocoTestReport.xml
12 changes: 12 additions & 0 deletions .github/actions/setup-build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: "Setup Gradle"
description: "Setup Gradle"
runs:
using: "composite"
steps:
- uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Setup Gradle cache
uses: gradle/gradle-build-action@v2
51 changes: 51 additions & 0 deletions .github/workflows/discord-webhook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: 'Discord Webhook'
on:
issues:
types: [ opened ]
pull_request_target:
types: [ opened, reopened ]
discussion:
types: [ created ]

jobs:
message:
runs-on: ubuntu-latest
steps:
- name: New Discussion
uses: tsickert/discord-webhook@v5.3.0
if: ${{ (github.event_name == 'discussion') }}
with:
webhook-url: ${{ secrets.DISCORD_WEBHOOK_GITHUB }}
avatar-url: https://avatars.githubusercontent.com/u/9919?s=200&v=4
embed-author-name: ${{ github.event.sender.login }}
embed-author-url: ${{ github.event.sender.html_url }}
embed-author-icon-url: ${{ github.event.sender.avatar_url }}
embed-title: ${{ github.event.discussion.title }}
embed-url: ${{ github.event.discussion.html_url }}
embed-description: A **discussion** has been created in ${{ github.repository }}.

- name: New Issue
uses: tsickert/discord-webhook@v5.3.0
if: ${{ (github.event_name == 'issues') }}
with:
webhook-url: ${{ secrets.DISCORD_WEBHOOK_GITHUB }}
avatar-url: https://avatars.githubusercontent.com/u/9919?s=200&v=4
embed-author-name: ${{ github.event.sender.login }}
embed-author-url: ${{ github.event.sender.html_url }}
embed-author-icon-url: ${{ github.event.sender.avatar_url }}
embed-title: ${{ github.event.issue.title }}
embed-url: ${{ github.event.issue.html_url }}
embed-description: An **issue** has been opened in ${{ github.repository }}.

- name: New Pull Request
uses: tsickert/discord-webhook@v5.3.0
if: ${{ (github.event_name == 'pull_request_target') }}
with:
webhook-url: ${{ secrets.DISCORD_WEBHOOK_GITHUB }}
avatar-url: https://avatars.githubusercontent.com/u/9919?s=200&v=4
embed-author-name: ${{ github.event.sender.login }}
embed-author-url: ${{ github.event.sender.html_url }}
embed-author-icon-url: ${{ github.event.sender.avatar_url }}
embed-title: ${{ github.event.pull_request.title }}
embed-url: ${{ github.event.pull_request.html_url }}
embed-description: A **pull request** has been opened in ${{ github.repository }}.
2 changes: 1 addition & 1 deletion .github/workflows/first-interaction.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ jobs:
issue-message: 'Thanks for your contribution :fire: We will take a look asap :rocket:'
pr-message: >-
'We are always happy to welcome new contributors :heart: To make things easier for everyone, please
- make sure to follow our [contribution guidelines](https://github.com/eclipse-dataspaceconnector/Samples/blob/main/CONTRIBUTING.md),
- make sure to follow our [contribution guidelines](https://github.com/eclipse-edc/Samples/blob/main/CONTRIBUTING.md),
- check if you have already signed the [ECA](http://www.eclipse.org/legal/ecafaq.php), and
- relate this pull request to an existing issue or discussion.'
147 changes: 147 additions & 0 deletions .github/workflows/verify.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
name: Test Code (Style, Tests)

on:
push:
pull_request:
branches: [ main ]
paths-ignore:
- '**.md'
- 'docs/**'
- 'CODEOWNERS'
- 'LICENSE'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
Checkstyle:
permissions:
id-token: write
checks: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-build

- name: Run Checkstyle
run: ./gradlew checkstyleMain checkstyleTest checkstyleTestFixtures

Sanity-Check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-build

- name: Check Sample 01
run: |
./gradlew :01-basic-connector:shadowJar
echo "Checking Sample 01"
java -jar 01-basic-connector/build/libs/basic-connector.jar > log.txt &
sleep 5
grep "INFO.*edc-.*ready" log.txt
rm log.txt
killall java
- name: Check Sample 02
run: |
./gradlew :02-health-endpoint:shadowJar
echo "Checking Sample 02"
java -jar 02-health-endpoint/build/libs/connector-health.jar > log.txt &
sleep 5
grep "INFO.*edc-.*ready" log.txt
rm log.txt
killall java
- name: Check Sample 03
run: |
./gradlew :03-configuration:shadowJar
echo "Checking Sample 03"
java -Dedc.fs.config=03-configuration/config.properties -jar 03-configuration/build/libs/filesystem-config-connector.jar > log.txt &
sleep 5
grep "INFO.*edc-.*ready" log.txt
rm log.txt
killall java
- name: Check Sample 04.0 (Consumer)
run: |
./gradlew :04.0-file-transfer:file-transfer-consumer:shadowJar
echo "Checking Sample 04 - Consumer"
java -Dedc.fs.config=04.0-file-transfer/file-transfer-consumer/config.properties -jar 04.0-file-transfer/file-transfer-consumer/build/libs/consumer.jar > log.txt &
sleep 5
grep "INFO.*edc-.*ready" log.txt
rm log.txt
killall java
- name: Check Sample 04.0 (Provider)
run: |
echo "Checking Sample 04 - Provider"
./gradlew :04.0-file-transfer:file-transfer-provider:shadowJar
java -Dedc.fs.config=04.0-file-transfer/file-transfer-provider/config.properties -jar 04.0-file-transfer/file-transfer-provider/build/libs/provider.jar > log.txt &
sleep 5
grep "INFO.*edc-.*ready" log.txt
rm log.txt
killall java
- name: Check Sample 04.1 (Consumer)
run: |
echo "Checking Sample 04.1 - Consumer"
./gradlew :04.1-file-transfer-listener:file-transfer-listener-consumer:shadowJar
java -Dedc.fs.config=04.1-file-transfer-listener/file-transfer-listener-consumer/config.properties -jar 04.1-file-transfer-listener/file-transfer-listener-consumer/build/libs/consumer.jar > log.txt &
sleep 5
grep "INFO.*edc-.*ready" log.txt
rm log.txt
killall java
- name: Check Sample 04.2 (Command-Q/Watchdog)
run: |
echo "Checking Sample 04.2 - Command-Q/Watchdog"
./gradlew :04.2-modify-transferprocess:modify-transferprocess-consumer:shadowJar
java -Dedc.fs.config=04.2-modify-transferprocess/modify-transferprocess-consumer/config.properties -jar 04.2-modify-transferprocess/modify-transferprocess-consumer/build/libs/consumer.jar > log.txt &
sleep 5
grep "INFO.*edc-.*ready" log.txt
rm log.txt
killall java
# we cannot check sample 5 currently because we'd need repo secrets for that (client id,...)

End-To-End-Tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-build

- name: End to End Integration Tests
uses: ./.github/actions/run-tests
with:
command: ./gradlew test -DincludeTags="EndToEndTest"

- name: "Publish Gatling report"
uses: actions/upload-artifact@v3
if: always()
with:
name: Gatling reports
path: '**/build/reports/gatling/**'

Upload-Test-Report:
needs:
- End-To-End-Tests

permissions:
checks: write
pull-requests: write

runs-on: ubuntu-latest
if: always()
steps:
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
junit_files: "**/test-results/**/*.xml"
62 changes: 62 additions & 0 deletions 01-basic-connector/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Running a simple connector

A runnable connector consists of a `Runtime` and a build file, in our case this is a `build.gradle.kts`.

The first thing we need is the `Runtime` which is the main entry point to the connector application, same as with any
other Java program. In this sample we use the
[`BaseRuntime`](https://github.com/eclipse-edc/Connector/blob/releases/core/common/boot/src/main/java/org/eclipse/edc/boot/system/runtime/BaseRuntime.java),
but this can be extended (take a look at the [`custom-runtime`](../other/custom-runtime) sample for more information)

The second thing we need is a [gradle build file](build.gradle.kts)
that contains the essential dependencies. We'll need at least the following things:

```kotlin
dependencies {
implementation("$groupId:control-plane-core:$edcVersion")
}
```

> _Additional dependencies will be added to this list in the future, so be sure to check back regularly!_
with that we can build and run the connector from the root directory:

```bash
./gradlew clean 01-basic-connector:build
java -jar 01-basic-connector/build/libs/basic-connector.jar
```

_Note: the above snippet assumes that you did not alter the build file, i.e. the `shadow` plugin is used and the build
artifact resides at the path mentioned above. Also, we assume usage of the Gradle Wrapper, as opposed to a local Gradle
installation._

If everything works as intended you should see command-line output similar to this:

```bash
INFO 2022-01-13T13:43:57.677973407 Secrets vault not configured. Defaulting to null vault.
INFO 2022-01-13T13:43:57.680158117 Initialized Null Vault
INFO 2022-01-13T13:43:57.851181615 Initialized Core Services
INFO 2022-01-13T13:43:57.852046576 Initialized Schema Registry
INFO 2022-01-13T13:43:57.853010987 Initialized In-Memory Transfer Process Store
INFO 2022-01-13T13:43:57.856956651 Initialized Core Transfer
INFO 2022-01-13T13:43:57.857664924 Initialized In-Memory Asset Index
INFO 2022-01-13T13:43:57.857957714 Initialized In-Memory Contract Definition Store
INFO 2022-01-13T13:43:57.860738605 Initialized Core Contract Service
INFO 2022-01-13T13:43:57.861390422 Initialized In-Memory Contract Negotiation Store
INFO 2022-01-13T13:43:57.862002044 Started Core Services
INFO 2022-01-13T13:43:57.862247712 Started Schema Registry
INFO 2022-01-13T13:43:57.862782289 Started In-Memory Transfer Process Store
INFO 2022-01-13T13:43:57.8635804 Started Core Transfer
INFO 2022-01-13T13:43:57.86371948 Started In-Memory Asset Index
INFO 2022-01-13T13:43:57.863838751 Started In-Memory Contract Definition Store
INFO 2022-01-13T13:43:57.86497334 Started Core Contract Service
INFO 2022-01-13T13:43:57.865146132 Started In-Memory Contract Negotiation Store
INFO 2022-01-13T13:43:57.866073376 edc-e796b518-35f0-4c45-a333-79ca20a6be06 ready
```

This basic connector - while perfectly fine - does not offer any outward-facing API, nor does it provide any
connector-to-connector communication protocols. However, it will serve us as platform to build out more complex
scenarios.

---

[Next Chapter](../02-health-endpoint/README.md)
37 changes: 37 additions & 0 deletions 01-basic-connector/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2020, 2021 Microsoft Corporation
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* Microsoft Corporation - initial API and implementation
* Fraunhofer Institute for Software and Systems Engineering - added dependencies
*
*/

plugins {
`java-library`
id("application")
id("com.github.johnrengelman.shadow") version "7.1.2"
}

val groupId: String by project
val edcVersion: String by project

dependencies {
implementation("$groupId:control-plane-core:$edcVersion")
}

application {
mainClass.set("org.eclipse.edc.boot.system.runtime.BaseRuntime")
}

tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {
exclude("**/pom.properties", "**/pom.xm")
mergeServiceFiles()
archiveFileName.set("basic-connector.jar")
}
Loading

0 comments on commit abe5bf2

Please sign in to comment.