Skip to content

Commit

Permalink
Merge pull request #107 from RADAR-base/release-1.0.0
Browse files Browse the repository at this point in the history
Release 1.0.0
  • Loading branch information
blootsvoets committed May 2, 2023
2 parents b407e20 + 860e1fb commit a69574e
Show file tree
Hide file tree
Showing 179 changed files with 8,245 additions and 8,427 deletions.
26 changes: 26 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true

[*]
# Change these settings to your own preference
indent_style = space
indent_size = 4

# We recommend you to keep these unchanged
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.{kt,kts}]
ktlint_standard_no-wildcard-imports = disabled

[*.md]
trim_trailing_whitespace = false

[*.{json,yaml,yml}]
indent_style = space
indent_size = 2
9 changes: 9 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,12 @@ jobs:
# Gradle check
- name: Check
run: ./gradlew check

- name: Check version
run: |
projectVersion=$(./gradlew properties | grep '^version:.*$')
pluginVersion=$(./gradlew :radar-commons-gradle:properties | grep '^version:.*$')
if [ "$projectVersion" != "$pluginVersion" ]; then
echo "Project version $projectVersion does not match plugin version $pluginVersion"
exit 1
fi
15 changes: 11 additions & 4 deletions .github/workflows/publish_snapshots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ jobs:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

- name: Has SNAPSHOT version
id: is-snapshot
run: grep "version = '.*-SNAPSHOT'" build.gradle

- uses: actions/setup-java@v3
with:
distribution: temurin
Expand All @@ -29,6 +25,9 @@ jobs:
- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Has SNAPSHOT version
run: ./gradlew properties | grep '^version:.*-SNAPSHOT$'

- name: Install gpg secret key
run: |
cat <(echo -e "${{ secrets.OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import
Expand All @@ -39,3 +38,11 @@ jobs:
OSSRH_USER: ${{ secrets.OSSRH_USER }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
run: ./gradlew -Psigning.gnupg.keyName=CBEF2CF0 -Psigning.gnupg.executable=gpg -Psigning.gnupg.passphrase=${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} publish

- name: Plugin has SNAPSHOT version
run: ./gradlew :radar-commons-gradle:properties | grep '^version:.*-SNAPSHOT$'

- name: Publish gradle plugin
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew :radar-commons-gradle:publish
14 changes: 14 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ jobs:
- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Check version
run: |
projectVersion=$(./gradlew properties | grep '^version:.*$')
pluginVersion=$(./gradlew :radar-commons-gradle:properties | grep '^version:.*$')
if [ "$projectVersion" != "$pluginVersion" ]; then
echo "Project version $projectVersion does not match plugin version $pluginVersion"
exit 1
fi
# Compile code
- name: Compile code
run: ./gradlew assemble
Expand All @@ -44,3 +53,8 @@ jobs:
OSSRH_USER: ${{ secrets.OSSRH_USER }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
run: ./gradlew -Psigning.gnupg.keyName=CBEF2CF0 -Psigning.gnupg.executable=gpg -Psigning.gnupg.passphrase=${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} publish closeAndReleaseSonatypeStagingRepository

- name: Publish gradle plugin
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew :radar-commons-gradle:publish
11 changes: 9 additions & 2 deletions .github/workflows/scheduled_snyk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,21 @@ name: Snyk scheduled test
on:
schedule:
- cron: '0 2 * * 1'
push:
branches:
- master

jobs:
security:
runs-on: ubuntu-latest
env:
REPORT_FILE: test.json

steps:
- uses: actions/checkout@v3
- uses: snyk/actions/setup@master
with:
snyk-version: v1.931.0
snyk-version: v1.1032.0

- uses: actions/setup-java@v3
with:
Expand All @@ -28,13 +33,15 @@ jobs:
snyk test
--all-sub-projects
--configuration-matching='^runtimeClasspath$'
--fail-on=upgradable
--json-file-output=${{ env.REPORT_FILE }}
--org=radar-base
--policy-path=$PWD/.snyk
- name: Report new vulnerabilities
uses: thehyve/report-vulnerability@master
if: success() || failure()
with:
report-file: ${{ env.REPORT_FILE }}
env:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ failure() }}
6 changes: 3 additions & 3 deletions .github/workflows/snyk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ on:
pull_request:
branches:
- master

jobs:
security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: snyk/actions/setup@master
with:
snyk-version: v1.931.0
snyk-version: v1.1032.0

- uses: actions/setup-java@v3
with:
Expand All @@ -27,6 +28,5 @@ jobs:
snyk test
--all-sub-projects
--configuration-matching='^runtimeClasspath$'
--fail-on=upgradable
--org=radar-base
--severity-threshold=high
--policy-path=$PWD/.snyk
85 changes: 40 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,75 +1,68 @@
# RADAR-Commons
[![Build Status](https://travis-ci.org/RADAR-base/radar-commons.svg?branch=master)](https://travis-ci.org/RADAR-base/radar-commons)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/9fe7a419c83e4798af671e468c7e91cf)](https://www.codacy.com/app/RADAR-base/radar-commons?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=RADAR-base/radar-commons&amp;utm_campaign=Badge_Grade)

Common utilities library containing basic schemas, streaming features, testing bridges and utils.

# Usage

Add the RADAR-Commons library to your project with Gradle by updating your `build.gradle` file with:
Add the RADAR-Commons library to your project with Gradle by updating your `build.gradle.kts` file with:

```gradle
repositories {
mavenCentral()
}
dependencies {
implementation group: 'org.radarbase', name: 'radar-commons', version: '0.15.0'
implementation("org.radarbase:radar-commons:1.0.0")
}
```

Example use, after adding [`radar-schemas`](https://github.com/radar-base/radar-schemas) to classpath:

```kotlin
// Set URLs for RADAR-base installation
val baseUrl = "..."
val kafkaUrl = "$baseUrl/kafka/"
val schemaUrl = "$baseUrl/schema/"
val oauthHeaders = ...
val key = ObservationKey("myProject", "myUser", "mySource")

// Configure RADAR-base clients
val client = RestClient.global().apply {
server(ServerConfig(kafkaUrl))
gzipCompression(true)
}.build()
val baseUrl = "https://..."
val oauthToken = ...

val kafkaSender = restKafkaSender {
baseUrl = "$baseUrl/kafka/"
headers.append("Authorization", "Bearer $oauthToken")
httpClient {
timeout(10.seconds)
}
schemaRetriever ("$baseUrl/schema/")
}

val schemaRetriever = SchemaRetriever(ServerConfig(schemaUrl), 30)
// Configure topic to send data over
val topic = AvroTopic(
"linux_raspberry_temperature",
ObservationKey.getClassSchema(),
RaspberryTemperature.getClassSchema(),
ObservationKey::class.java,
RaspberryTemperature::class.java
)

val restSender = RestSender.Builder().apply {
httpClient(client)
schemaRetriever(schemaRetriever)
useBinaryContent(true)
headers(oauthHeaders)
}.build()
val topicSender = kafkaSender.sender(topic)

val sender = BatchedKafkaSender(restSender, 60_000L, 1000L)
val key = ObservationKey("myProject", "myUser", "mySource")

// Configure topic to send data over
val topic = AvroTopic("linux_raspberry_temperature",
ObservationKey.getClassSchema(), RaspberryTemperature.getClassSchema(),
ObservationKey::class.java, RaspberryTemperature::class.java)

// Send data to topic. Be sure to close
// the sender after use. Preferably, a sender is reused
// for many observations so that requests are efficiently
// batched.
sender.sender(topic).use { topicSender ->
readValuesFromSystem() { value ->
topicSender.send(key, value)
}
// Send data to topic.
runBlocking {
val values: List<RaspberryTemperature> = readValuesFromSystem()
topicSender.send(key, values)
}
```
Note that this code above does not include any flows for registering a source with the managmentportal.

Note that this code above does not include any flows for registering a source with the ManagementPortal.

For server utilities, include `radar-commons-server`:
```gradle
repositories {
mavenCentral()
maven { url 'https://packages.confluent.io/maven/' }
maven(url = "https://packages.confluent.io/maven/")
}
dependencies {
implementation group: 'org.radarbase', name: 'radar-commons-server', version: '0.15.0'
implementation("org.radarbase:radar-commons-server:1.0.0")
}
```

Expand All @@ -78,11 +71,11 @@ For mocking clients of the RADAR-base infrastructure, use that 'radar-commons-te
```gradle
repositories {
mavenCentral()
maven { url 'https://packages.confluent.io/maven/' }
maven(url = "https://packages.confluent.io/maven/")
}
dependencies {
testImplementation group: 'org.radarbase', name: 'radar-commons-testing', version: '0.15.0'
testImplementation("org.radarbase:radar-commons-testing:1.0.0")
}
```

Expand All @@ -92,24 +85,26 @@ To test your backend with a MockProducer, copy `testing/mock.yml.template` to `t
```
to send data to your backend.

To use the RADAR Gradle plugins, see the README of the `radar-commons-gradle` directory.

## Contributing

For latest code use `dev` branch. This is released on JFrog's OSS Artifactory. To use that release, add the following fragment to your `build.gradle` file.

```gradle
repositories {
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
maven(url = "https://oss.sonatype.org/content/repositories/snapshots")
}
configurations.all {
// Check for updates every build
resolutionStrategy.cacheChangingModulesFor 0, 'SECONDS'
resolutionStrategy.cacheChangingModulesFor(0, "SECONDS")
}
dependencies {
implementation group: 'org.radarbase', name: 'radar-commons', version: '0.15.1-SNAPSHOT'
implementation("org.radarbase:radar-commons:1.0.1-SNAPSHOT")
}
```

Code should be formatted using the [Google Java Code Style Guide](https://google.github.io/styleguide/javaguide.html).
Code should be formatted using the Kotlin official style guide, in addition to ktlint rules.
If you want to contribute a feature or fix browse our [issues](https://github.com/RADAR-base/radar-commons/issues), and please make a pull request.
Loading

0 comments on commit a69574e

Please sign in to comment.