Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
name: CI Pipeline
on:
push:
branches:
- master
pull_request:
on: [push, workflow_dispatch]

jobs:
Build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up JDK
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 8
distribution: "temurin"
java-version-file: ".java-version"

- name: Build and test
run: ./gradlew clean build -x ktlintCheck -x ktlintFormat
run: ./gradlew clean test
continue-on-error: true

- name: Test report
uses: asadmansr/[email protected]

- name: Lint
run: ./gradlew ktlintCheck ktlintFormat
run: ./gradlew check -x test
27 changes: 14 additions & 13 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ jobs:
Publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v3.x
uses: rlespinasse/github-slug-action@v5

- name: Check CI status
run: |
output=$(curl -sSL -X GET -G -H "Accept: application/vnd.github.v3+json" -d "branch=${{ env.GITHUB_REF_SLUG }}" -d "event=push" https://api.github.com/repos/${{ github.repository }}/actions/workflows/${{ github.event.inputs.ci }}/runs | jq -r '.workflow_runs[0] | "\(.conclusion)"')
echo "::set-output name=status::$output"
id: check
run: |
output=$(curl -sSL -X GET -G -H "Accept: application/vnd.github.v3+json" -d "branch=${{ env.GITHUB_REF_NAME_SLUG }}" -d "event=push" https://api.github.com/repos/${{ github.repository }}/actions/workflows/${{ github.event.inputs.ci }}/runs | jq -r '.workflow_runs[0] | "\(.conclusion)"')
echo "status=$output" >> "$GITHUB_OUTPUT"

- name: Abort if CI not successful
if: steps.check.outputs.status != 'success'
Expand All @@ -29,15 +29,16 @@ jobs:
exit 1

- name: Set up JDK
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 8
distribution: "temurin"
java-version-file: ".java-version"

- name: Publish to Maven Central
env:
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_KEY_PASSPHRASE }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PASSWORD }}
run: |
./gradlew -P signingKey=${{ secrets.SIGNING_KEY }} \
-P signingPassword=${{ secrets.SIGNING_PASSWORD }} \
-P sonatypeUsername=${{ secrets.SONATYPE_USERNAME }} \
-P sonatypePassword=${{ secrets.SONATYPE_PASSWORD }} \
publishToSonatype closeAndReleaseSonatypeStagingRepository
./gradlew publishAndReleaseToMavenCentral --no-configuration-cache
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ bin/
# IntelliJ
.idea/
*.iml
.kotlin

# Maven
target/
Expand All @@ -22,3 +23,6 @@ build/
.gradle/
userHome/
out/

# GPG
.gnupg
1 change: 1 addition & 0 deletions .java-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
17
35 changes: 10 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
# grpc-test

Includes a JUnit
5 [Extension](https://junit.org/junit5/docs/current/api/org.junit.jupiter.api/org/junit/jupiter/api/extension/Extension.html)
Includes a JUnit 5 [Extension](https://junit.org/junit5/docs/current/api/org.junit.jupiter.api/org/junit/jupiter/api/extension/Extension.html)
that can automatically release gRPC resources at the end of the test.
Like [GrpcCleanupRule](https://grpc.github.io/grpc-java/javadoc/io/grpc/testing/GrpcCleanupRule.html), but built for
JUnit 5 and actively maintained.

If you like it, consider becoming a
[![](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub&color=%23fe8e86)](https://github.com/sponsors/asarkar).

[![](https://github.com/asarkar/grpc-test/workflows/CI%20Pipeline/badge.svg)](https://github.com/asarkar/grpc-test/actions?query=workflow%3A%22CI+Pipeline%22)

## Installation

You can find the latest version
on [Maven Central](https://search.maven.org/search?q=g:com.asarkar.grpc%20AND%20a:grpc-test).
[![Sponsor](https://img.shields.io/static/v1?style=for-the-badge&label=Sponsor&message=%E2%9D%A4&logo=GitHub&color=%23fe8e86)](https://github.com/sponsors/asarkar)
[![CI](<https://img.shields.io/github/actions/workflow/status/asarkar/grpc-test/ci.yml?branch=main&logo=GitHub&style=for-the-badge>)](https://github.com/asarkar/grpc-test/actions?query=workflow%3A%22CI+Pipeline%22)
[![Maven](https://img.shields.io/maven-central/v/com.asarkar.grpc/grpc-test?style=for-the-badge&logo=apache-maven)](https://central.sonatype.com/artifact/com.asarkar.grpc/grpc-test?smo=true)
[![Javadoc](https://javadoc.io/badge2/com.asarkar.grpc/grpc-test/javadoc.svg?style=for-the-badge)](https://javadoc.io/doc/com.asarkar.grpc/grpc-test)
[![License](https://img.shields.io/github/license/asarkar/grpc-test?style=for-the-badge&logo=apache&color=blue)](https://www.apache.org/licenses/LICENSE-2.0)
[![COC](https://img.shields.io/static/v1?style=for-the-badge&label=COC&message=Code+Of+Conduct&color=brightgreen)](https://github.com/asarkar/.github/blob/main/CODE_OF_CONDUCT.md)

## Usage

Expand Down Expand Up @@ -50,18 +46,7 @@ extension will not reinitialize it.

:information_source: If you're writing `@Nested` tests, see [issues/8](https://github.com/asarkar/grpc-test/issues/8).

## Minimum Requirements
- Java 8

## Contributing
The test class in [client](client/src/test) project uses the `GrpcCleanupExtension` from Java code.

This project is a volunteer effort. You are welcome to send pull requests, ask questions, or create issues.

## Code of Conduct

This project adheres to the Contributor Covenant [code of conduct](https://github.com/asarkar/.github/blob/main/CODE_OF_CONDUCT.md).
By participating, you are expected to uphold this code.

## License

Copyright 2022 Abhijit Sarkar - Released under [Apache License v2.0](LICENSE).
## Minimum Requirements
- See [.java-version](.java-version). See releases for previous versions supporting older Java versions.
148 changes: 0 additions & 148 deletions build.gradle.kts

This file was deleted.

73 changes: 73 additions & 0 deletions client/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import com.github.spotbugs.snom.SpotBugsTask

plugins {
`java-library`
alias(libs.plugins.spotbugs)
alias(libs.plugins.spotless)
alias(libs.plugins.errorprone)

}

repositories {
mavenCentral()
}

dependencies {
testImplementation(platform(libs.grpc.bom))
testImplementation(platform(libs.junit.bom))
testImplementation(platform(libs.mockito.bom))
testImplementation("org.junit.jupiter:junit-jupiter")
testImplementation("io.grpc:grpc-api")
testImplementation("org.mockito:mockito-core")
testImplementation(project(":lib"))
testRuntimeOnly("io.grpc:grpc-core")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
errorprone(libs.errorprone)
}

val javaVersion = JavaLanguageVersion.of(rootDir.resolve(".java-version").readText(Charsets.UTF_8).trim())

java {
toolchain {
languageVersion = javaVersion
}
}

spotbugs {
toolVersion = libs.versions.spotbugs.get()
}

spotless {
java {
palantirJavaFormat(libs.versions.palantirJavaFmt.get()).style("GOOGLE")
toggleOffOn()
}
}

val ci: Boolean by lazy { listOf("CI").any { System.getenv(it) != null } }
val spotlessTasks = arrayOf("spotlessApply", "spotlessCheck")
val spotlessTask = spotlessTasks[true.compareTo(ci)] // true > false

tasks.named(spotlessTask) {
enabled = false
}

tasks.named("check") {
dependsOn(spotlessTasks[0])
}

tasks.withType<Test> {
useJUnitPlatform()
testLogging {
showStandardStreams = true
}
// Suppress warning: Sharing is only supported for boot loader classes...
// https://stackoverflow.com/q/54205486/839733
jvmArgs("-Xshare:off")
}

tasks.withType<SpotBugsTask> {
reports.create("html") {
required = !ci
}
}
Loading