Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for java client release pipeline #1922

Merged
merged 18 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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: 5 additions & 16 deletions .github/workflows/java-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,26 +56,21 @@ jobs:
OS: ubuntu,
RUNNER: ubuntu-latest,
TARGET: x86_64-unknown-linux-gnu,
CLASSIFIER: linux-x86_64
}
- {
OS: ubuntu,
RUNNER: ["self-hosted", "Linux", "ARM64"],
TARGET: aarch64-unknown-linux-gnu,
CLASSIFIER: linux-aarch_64,
CONTAINER: "2_28"
}
- {
OS: macos,
RUNNER: macos-12,
TARGET: x86_64-apple-darwin,
CLASSIFIER: osx-x86_64
}
- {
OS: macos,
RUNNER: macos-latest,
TARGET: aarch64-apple-darwin,
CLASSIFIER: osx-aarch_64
}

runs-on: ${{ matrix.host.RUNNER }}
Expand All @@ -99,7 +94,7 @@ jobs:
- name: Set the release version
shell: bash
run: |
if ${{ github.event_name == 'pull_request' || github.event_name == 'push' }}; then
if ${{ github.event_name == 'pull_request' }}; then
R_VERSION="255.255.255"
elif ${{ github.event_name == 'workflow_dispatch' }}; then
R_VERSION="${{ env.INPUT_VERSION }}"
Expand Down Expand Up @@ -139,18 +134,12 @@ jobs:
env:
SECRING_GPG: ${{ secrets.SECRING_GPG }}

- name: Replace placeholders and version in build.gradle
shell: bash
working-directory: ./java/client
run: |
SED_FOR_MACOS=`if [[ "${{ matrix.host.os }}" =~ .*"macos".* ]]; then echo "''"; fi`
sed -i $SED_FOR_MACOS 's/placeholder/${{ matrix.host.CLASSIFIER }}/g' build.gradle
sed -i $SED_FOR_MACOS "s/255.255.255/${{ env.RELEASE_VERSION }}/g" build.gradle
- name: Build java client
working-directory: java
run: |
./gradlew :client:publishToMavenLocal -Psigning.secretKeyRingFile=secring.gpg -Psigning.password="${{ secrets.GPG_PASSWORD }}" -Psigning.keyId=${{ secrets.GPG_KEY_ID }}
env:
GLIDE_RELEASE_VERSION: ${{ env.RELEASE_VERSION }}

- name: Bundle JAR
working-directory: java
Expand All @@ -160,12 +149,12 @@ jobs:
jar -cvf bundle.jar *
ls -ltr
cd -
cp $src_folder/bundle.jar .
cp $src_folder/bundle.jar bundle-${{ matrix.host.TARGET }}.jar
- name: Upload artifacts to publish
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: java-${{ matrix.host.TARGET }}
path: |
java/bundle.jar
java/bundle*.jar
14 changes: 5 additions & 9 deletions .github/workflows/java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:

- name: Build java client
working-directory: java
run: ./gradlew --continue build
run: ./gradlew --continue build -x javadoc

- name: Ensure no skipped files by linter
working-directory: java
Expand Down Expand Up @@ -163,22 +163,18 @@ jobs:

- name: Install Java
run: |
yum install -y java-${{ matrix.java }}
yum install -y java-${{ matrix.java }}-amazon-corretto-devel.x86_64

- name: Build rust part
- name: Build java wrapper
working-directory: java
run: cargo build --release

- name: Build java part
working-directory: java
run: ./gradlew --continue build
run: ./gradlew --continue build -x javadoc

- name: Upload test & spotbugs reports
if: always()
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: test-reports-${{ matrix.java }}
name: test-reports-${{ matrix.java }}-amazon-linux
path: |
java/client/build/reports/**
java/integTest/build/reports/**
Expand Down
2 changes: 1 addition & 1 deletion examples/java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repositories {
}

dependencies {
implementation group: 'io.valkey', name: 'valkey-glide', version: '1.0.0', classifier: osdetector.classifier
implementation "io.valkey:valkey-glide:1.0.1:${osdetector.classifier}"
}

application {
Expand Down
7 changes: 3 additions & 4 deletions java/DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,10 @@ dependencies {
}
```

Optionally: you can specify a snapshot release and classifier:
Optionally: you can specify a snapshot release:

```bash
export GLIDE_LOCAL_VERSION=1.0.0-SNAPSHOT
export GLIDE_LOCAL_CLASSIFIER=osx-aarch_64
export GLIDE_RELEASE_VERSION=1.0.1-SNAPSHOT
./gradlew publishToMavenLocal
```

Expand All @@ -191,7 +190,7 @@ repositories {
}
dependencies {
// Update to use version defined in the previous step
implementation group: 'io.valkey', name: 'valkey-glide', version: '1.0.0-SNAPSHOT', classifier='osx-aarch_64'
implementation group: 'io.valkey', name: 'valkey-glide', version: '1.0.1-SNAPSHOT', classifier='osx-aarch_64'
}
```

Expand Down
42 changes: 33 additions & 9 deletions java/client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ plugins {
id 'java-library'
id 'maven-publish'
id 'signing'
id ("com.github.spotbugs") version "6.0.18"
id 'io.freefair.lombok' version '8.6'
id 'com.github.spotbugs' version '6.0.18'
id 'com.google.osdetector' version '1.7.3'
}

repositories {
Expand Down Expand Up @@ -156,7 +158,11 @@ tasks.register('copyNativeLib', Copy) {
into sourceSets.main.output.resourcesDir
}

def defaultReleaseVersion = "255.255.255";

delombok.dependsOn('compileJava')
jar.dependsOn('copyNativeLib')
javadoc.dependsOn('copyNativeLib')
copyNativeLib.dependsOn('buildRustRelease')
compileTestJava.dependsOn('copyNativeLib')
test.dependsOn('buildRust')
Expand All @@ -177,16 +183,13 @@ sourceSets {
}
}

// version is replaced during released workflow java-cd.yml
def defaultReleaseVersion = "255.255.255";

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
groupId = 'io.valkey'
artifactId = 'valkey-glide'
version = System.getenv("GLIDE_LOCAL_VERSION") ?: defaultReleaseVersion;
version = System.getenv("GLIDE_RELEASE_VERSION") ?: defaultReleaseVersion;
pom {
name = 'valkey-glide'
description = 'General Language Independent Driver for the Enterprise (GLIDE) for Valkey'
Expand Down Expand Up @@ -218,8 +221,14 @@ publishing {
}
}

java {
modularity.inferModulePath = true
withSourcesJar()
withJavadocJar()
Yury-Fridlyand marked this conversation as resolved.
Show resolved Hide resolved
}

tasks.withType(Sign) {
def releaseVersion = System.getenv("GLIDE_LOCAL_VERSION") ?: defaultReleaseVersion;
def releaseVersion = System.getenv("GLIDE_RELEASE_VERSION") ?: defaultReleaseVersion;
def isReleaseVersion = !releaseVersion.endsWith("SNAPSHOT") && releaseVersion != defaultReleaseVersion;
onlyIf("isReleaseVersion is set") { isReleaseVersion }
}
Expand All @@ -239,9 +248,24 @@ tasks.withType(Test) {
}

jar {
archiveBaseName = "valkey-glide"
// placeholder will be renamed by platform+arch on the release workflow java-cd.yml
archiveClassifier = System.getenv("GLIDE_LOCAL_CLASSIFIER") ?: "placeholder"
archiveClassifier = osdetector.classifier
}

sourcesJar {
// suppress following error
// Entry glide/api/BaseClient.java is a duplicate but no duplicate handling strategy has been set
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

delombok {
modulePath = classpath
}

javadoc {
dependsOn delombok
source = delombok.outputs
options.tags = [ "example:a:Example:" ]
failOnError = false // TODO fix all javadoc errors and warnings and remove that
}

spotbugsMain {
Expand Down
Loading