Skip to content

Commit ffe292c

Browse files
authored
feat: initial implementation up-java 0.1.11 #1 (#2)
* feat: initial implementation up-java 0.1.10 #1 create maven project * feat: initial implementation up-java 0.1.10 #1 - dummy implementation - test setup - basic pipelines - documentation * feat: initial implementation up-java 0.1.11-SNAPSHOT #1 - implementation of send, registerListener and unregisterListener - added test cases for simple use-cases * feat: initial implementation up-java 0.1.11-SNAPSHOT #1 - added parsing of all MqttUserProperties to uAttributes in receiving messages use-case * feat: initial implementation up-java 0.1.11-SNAPSHOT #1 - replaced asserts with proper condition and error handling * feat: update to up-java 0.1.11 * chore: PR feedback inlined async methods, as the interface methods are now async removed incorrect copy right * fix: serialization of Uri in uAttributes * chore: added eclipse license disclaimer * chore: PR feedback sending messages: - added validation for uAttributes - refactor building methods before receiving message: - extract source and sink from MqttUserProperties * chore: check all uAttribute feelds for beeing set before converting these to MQTT Headers * refactor: remove static import to make it more readable
1 parent 5b3a639 commit ffe292c

24 files changed

+1573
-2
lines changed

.editorconfig

Whitespace-only changes.

.github/workflows/build_and_test.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Verify PR
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- '*'
7+
8+
jobs:
9+
verify-pr:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v3
14+
- name: Set up JDK 17
15+
uses: actions/setup-java@v3
16+
with:
17+
java-version: '17'
18+
distribution: 'temurin'
19+
cache: maven
20+
- name: Build and Test with Maven
21+
run: mvn -B package --file pom.xml

.github/workflows/build_deploy.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Continuous Integration
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build-and-deploy:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
14+
steps:
15+
- uses: actions/checkout@v3
16+
17+
- name: Set up Apache Maven Central
18+
uses: actions/setup-java@v3
19+
with: # configure settings.xml
20+
distribution: 'temurin'
21+
java-version: '17'
22+
server-id: ossrh
23+
server-username: OSSRH_USER
24+
server-password: OSSRH_PASSWORD
25+
26+
- name: Build and Publish to OSSRH snapshot repo
27+
run: mvn clean deploy
28+
env:
29+
OSSRH_USER: ${{ secrets.ORG_OSSRH_USERNAME }}
30+
OSSRH_PASSWORD: ${{ secrets.ORG_OSSRH_PASSWORD }}

.github/workflows/codeql.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: "CodeQL"
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
# schedule:
9+
# - cron: '16 15 * * 1'
10+
11+
jobs:
12+
analyze:
13+
name: Analyze (${{ matrix.language }})
14+
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
15+
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
16+
permissions:
17+
# required for all workflows
18+
security-events: write
19+
20+
# required to fetch internal or private CodeQL packs
21+
packages: read
22+
23+
# only required for workflows in private repositories
24+
actions: read
25+
contents: read
26+
27+
strategy:
28+
fail-fast: false
29+
matrix:
30+
include:
31+
# Analyzes Java code directly from the codebase without a build
32+
- language: java-kotlin
33+
build-mode: none # analyzes Java only
34+
steps:
35+
- name: Checkout repository
36+
uses: actions/checkout@v4
37+
38+
# Setup java 17.
39+
- name: Set up JDK 17
40+
uses: actions/setup-java@v3
41+
with:
42+
java-version: '17'
43+
distribution: 'temurin'
44+
cache: maven
45+
46+
# Initializes the CodeQL tools for scanning.
47+
- name: Initialize CodeQL
48+
uses: github/codeql-action/init@v3
49+
with:
50+
languages: ${{ matrix.language }}
51+
build-mode: ${{ matrix.build-mode }}
52+
53+
- name: Perform CodeQL Analysis
54+
uses: github/codeql-action/analyze@v3
55+
with:
56+
category: "/language:${{matrix.language}}"
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Add coverage comment to PR
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Java Test and Coverage"]
6+
types:
7+
- completed
8+
9+
jobs:
10+
add-coverage-comment:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
pull-requests: write
14+
if: >
15+
github.event.workflow_run.event == 'pull_request' &&
16+
github.event.workflow_run.conclusion == 'success'
17+
steps:
18+
- name: 'Download artifact'
19+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
20+
with:
21+
script: |
22+
var artifacts = await github.rest.actions.listWorkflowRunArtifacts({
23+
owner: context.repo.owner,
24+
repo: context.repo.repo,
25+
run_id: ${{github.event.workflow_run.id }},
26+
});
27+
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
28+
return artifact.name == "pr-comment"
29+
})[0];
30+
var download = await github.rest.actions.downloadArtifact({
31+
owner: context.repo.owner,
32+
repo: context.repo.repo,
33+
artifact_id: matchArtifact.id,
34+
archive_format: 'zip',
35+
});
36+
var fs = require('fs');
37+
fs.writeFileSync('${{github.workspace}}/pr-comment.zip', Buffer.from(download.data));
38+
- run: unzip pr-comment.zip
39+
40+
- name: 'Comment on PR'
41+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
42+
with:
43+
github-token: ${{ secrets.GITHUB_TOKEN }}
44+
script: |
45+
var fs = require('fs');
46+
47+
const issue_number = Number(fs.readFileSync('./pr-number.txt'));
48+
const body = fs.readFileSync('./body.txt', { encoding: 'utf8', flag: 'r' });
49+
50+
await github.rest.issues.createComment({
51+
owner: context.repo.owner,
52+
repo: context.repo.repo,
53+
issue_number: issue_number,
54+
body: body
55+
});

.github/workflows/coverage.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Java Test and Coverage
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
jobs:
9+
test-and-coverage:
10+
name: Test with coverage
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- run: |
15+
git config --global user.name 'eclipse-uprotocol-bot'
16+
git config --global user.email '[email protected]'
17+
18+
- name: Checkout code
19+
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
20+
21+
- name: Set up Apache Maven Central
22+
uses: actions/setup-java@v3
23+
with: # configure settings.xml
24+
distribution: 'temurin'
25+
java-version: '17'
26+
server-id: ossrh
27+
server-username: OSSRH_USER
28+
server-password: OSSRH_PASSWORD
29+
gpg-private-key: ${{ secrets.ORG_GPG_PRIVATE_KEY }}
30+
gpg-passphrase: GPG_PASSPHRASE
31+
32+
33+
- name: Run tests with coverage
34+
run: |
35+
mvn clean test jacoco:report
36+
37+
38+
- name: Extract JaCoCo report
39+
run: |
40+
echo "Extracting coverage percentage from JaCoCo report"
41+
INDEX_PATH="target/site/jacoco/index.html"
42+
export COVERAGE_PERCENTAGE=$(grep -oP '(?<=<td class="ctr2">).*?(?=%</td>)' $INDEX_PATH | sed 's/ //g')
43+
export COVERAGE_PERCENTAGE=$(printf "%.2f" "$COVERAGE_PERCENTAGE")
44+
echo "COVERAGE_PERCENTAGE= $COVERAGE_PERCENTAGE" >> $GITHUB_ENV
45+
echo "COVERAGE_PERCENTAGE: $COVERAGE_PERCENTAGE"
46+
47+
48+
- name: Upload JaCoCo Coverage report
49+
uses: actions/upload-artifact@v3
50+
with:
51+
name: coverage-report
52+
path: target/site/jacoco
53+
54+
- name: Generate coverage comment
55+
uses: actions/github-script@v7
56+
with:
57+
script: |
58+
const fs = require('fs');
59+
const COVERAGE_PERCENTAGE = `${{ env.COVERAGE_PERCENTAGE }}`;
60+
const COVERAGE_REPORT_PATH = `https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/`;
61+
62+
fs.mkdirSync('./pr-comment', { recursive: true });
63+
64+
var pr_number = `${{ github.event.number }}`;
65+
var body = `
66+
Code coverage report is ready! :chart_with_upwards_trend:
67+
68+
- **Code Coverage Percentage:** ${COVERAGE_PERCENTAGE}%
69+
- **Code Coverage Report:** [View Coverage Report](${COVERAGE_REPORT_PATH})
70+
`;
71+
72+
fs.writeFileSync('./pr-comment/pr-number.txt', pr_number);
73+
fs.writeFileSync('./pr-comment/body.txt', body);
74+
75+
- uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
76+
with:
77+
name: pr-comment
78+
path: pr-comment/

.github/workflows/release.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Release to maven central
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
release:
8+
if: github.event.ref == 'refs/heads/main'
9+
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
packages: write
14+
15+
steps:
16+
- run: |
17+
git config --global user.name 'eclipse-uprotocol-bot'
18+
git config --global user.email '[email protected]'
19+
20+
- uses: actions/checkout@v4
21+
with:
22+
token: ${{ secrets.BOT_GITHUB_TOKEN }}
23+
24+
- name: Set up Apache Maven Central
25+
uses: actions/setup-java@v3
26+
with: # configure settings.xml
27+
distribution: 'temurin'
28+
java-version: '17'
29+
server-id: ossrh
30+
server-username: OSSRH_USER
31+
server-password: OSSRH_PASSWORD
32+
gpg-private-key: ${{ secrets.ORG_GPG_PRIVATE_KEY }}
33+
gpg-passphrase: GPG_PASSPHRASE
34+
35+
- name: Stage to Nexus and Release to Maven central
36+
run: |
37+
mvn -B release:clean release:prepare -P release release:perform
38+
env:
39+
OSSRH_USER: ${{ secrets.ORG_OSSRH_USERNAME }}
40+
OSSRH_PASSWORD: ${{ secrets.ORG_OSSRH_PASSWORD }}
41+
GPG_PASSPHRASE: ${{ secrets.ORG_GPG_PASSPHRASE }}
42+
GH_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
43+
GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
44+
45+
- if: cancelled() || failure()
46+
run: |
47+
mvn -B release:rollback
48+
env:
49+
GH_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
50+
GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}

.gitignore

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
### Maven template
2+
target/
3+
pom.xml.tag
4+
pom.xml.releaseBackup
5+
pom.xml.versionsBackup
6+
pom.xml.next
7+
release.properties
8+
dependency-reduced-pom.xml
9+
buildNumber.properties
10+
.mvn/timing.properties
11+
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
12+
.mvn/wrapper/maven-wrapper.jar
13+
14+
# Eclipse m2e generated files
15+
# Eclipse Core
16+
.project
17+
# JDT-specific (Eclipse Java Development Tools)
18+
.classpath
19+
20+
### JetBrains template
21+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
22+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
23+
24+
# User-specific stuff
25+
.idea/**/workspace.xml
26+
.idea/**/tasks.xml
27+
.idea/**/usage.statistics.xml
28+
.idea/**/dictionaries
29+
.idea/**/shelf
30+
31+
# AWS User-specific
32+
.idea/**/aws.xml
33+
34+
# Generated files
35+
.idea/**/contentModel.xml
36+
37+
# Sensitive or high-churn files
38+
.idea/**/dataSources/
39+
.idea/**/dataSources.ids
40+
.idea/**/dataSources.local.xml
41+
.idea/**/sqlDataSources.xml
42+
.idea/**/dynamic.xml
43+
.idea/**/uiDesigner.xml
44+
.idea/**/dbnavigator.xml
45+
46+
# Gradle
47+
.idea/**/gradle.xml
48+
.idea/**/libraries
49+
50+
# Gradle and Maven with auto-import
51+
# When using Gradle or Maven with auto-import, you should exclude module files,
52+
# since they will be recreated, and may cause churn. Uncomment if using
53+
# auto-import.
54+
# .idea/artifacts
55+
# .idea/compiler.xml
56+
# .idea/jarRepositories.xml
57+
# .idea/modules.xml
58+
# .idea/*.iml
59+
# .idea/modules
60+
# *.iml
61+
# *.ipr
62+
63+
# CMake
64+
cmake-build-*/
65+
66+
# Mongo Explorer plugin
67+
.idea/**/mongoSettings.xml
68+
69+
# File-based project format
70+
*.iws
71+
72+
# IntelliJ
73+
out/
74+
75+
# mpeltonen/sbt-idea plugin
76+
.idea_modules/
77+
78+
# JIRA plugin
79+
atlassian-ide-plugin.xml
80+
81+
# Cursive Clojure plugin
82+
.idea/replstate.xml
83+
84+
# SonarLint plugin
85+
.idea/sonarlint/
86+
87+
# Crashlytics plugin (for Android Studio and IntelliJ)
88+
com_crashlytics_export_strings.xml
89+
crashlytics.properties
90+
crashlytics-build.properties
91+
fabric.properties
92+
93+
# Editor-based Rest Client
94+
.idea/httpRequests
95+
96+
# Android studio 3.1+ serialized cache file
97+
.idea/caches/build_file_checksums.ser
98+

0 commit comments

Comments
 (0)