Skip to content

Commit

Permalink
CUST-110209: do SDK maven snapshot release on push and use the snapsh…
Browse files Browse the repository at this point in the history
…ot SDK in smoke test.
  • Loading branch information
cleverchuk committed Aug 20, 2024
1 parent 5a747d3 commit de36002
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 4 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,16 @@ env:
SWO_EMAIL: ${{ secrets.SWO_EMAIL }}
SWO_PWORD: ${{ secrets.SWO_PWORD }}
STAGE_BUCKET: ${{ secrets.STAGE_BUCKET }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_TOKEN: ${{ secrets.SONATYPE_TOKEN }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PRIVATE_KEY_PASSPHRASE: ${{ secrets.GPG_PRIVATE_KEY_PASSPHRASE }}

jobs:
s3-stage-upload: # this job uploads the jar to stage s3
needs:
- maven_snapshot_release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -309,6 +316,12 @@ jobs:
java-version: '17'
distribution: 'temurin'

- name: Set agent version env
run: |
./gradlew build -x test
GIT_HASH=$(git rev-parse --short "$GITHUB_SHA")
echo "AGENT_VERSION=$(cd agent/build/libs && unzip -p solarwinds-apm-agent.jar META-INF/MANIFEST.MF | grep Implementation-Version | awk '{ print $2 }' | sed 's/[^a-z0-9.-]//g').$GIT_HASH" >> $GITHUB_ENV
- name: Run application
working-directory: smoke-tests
run: |
Expand Down Expand Up @@ -420,3 +433,28 @@ jobs:
- name: Docker logout
if: always()
run: docker logout

maven_snapshot_release:
runs-on: ubuntu-latest
env:
SNAPSHOT_BUILD: true
steps:
- uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3

- name: Set agent version env
run: |
./gradlew build -x test
GIT_HASH=$(git rev-parse --short "$GITHUB_SHA")
echo "AGENT_VERSION=$(cd agent/build/libs && unzip -p solarwinds-apm-agent.jar META-INF/MANIFEST.MF | grep Implementation-Version | awk '{ print $2 }' | sed 's/[^a-z0-9.-]//g').$GIT_HASH" >> $GITHUB_ENV
- name: Publish
run: ./gradlew publish
12 changes: 11 additions & 1 deletion smoke-tests/netty-test/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import java.net.URI

/*
* © SolarWinds Worldwide, LLC. All rights reserved.
*
Expand Down Expand Up @@ -25,10 +27,19 @@ version = "unspecified"

repositories {
mavenCentral()
maven {
url = URI.create("https://s01.oss.sonatype.org/content/repositories/snapshots/")
credentials {
username = System.getenv("SONATYPE_USERNAME")
password = System.getenv("SONATYPE_TOKEN")
}
}
}

val sdkVersion = System.getenv("AGENT_VERSION") ?: "2.6.0"
dependencies {
implementation("io.netty:netty-common:4.1.94.Final")
implementation("io.github.appoptics:solarwinds-otel-sdk:$sdkVersion-SNAPSHOT")
testImplementation(platform("org.junit:junit-bom:5.9.1"))
testImplementation("org.junit.jupiter:junit-jupiter")
}
Expand All @@ -38,7 +49,6 @@ tasks.test {
}

val swoAgentPath = project.buildDir.toString() + "/swo/solarwinds-apm-agent.jar"

fun getAgentPath(downloadPath: String) = if (System.getenv("AGENT_PATH") == null) downloadPath
else System.getenv("AGENT_PATH")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
package com.solarwinds.netty;

import io.netty.util.NetUtil;
import com.solarwinds.api.ext.SolarwindsAgent;

import java.util.concurrent.TimeUnit;

public class NettyApp {
public static void main(String[] args){
SolarwindsAgent.setTransactionName("hello world!");
System.out.printf("Number of interfaces: %d%n",NetUtil.NETWORK_INTERFACES.size());
try {
TimeUnit.MINUTES.sleep(1);
Expand Down
12 changes: 9 additions & 3 deletions solarwinds-otel-sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,27 @@ publishing {
name = 'Apache License, Version 2.0'
}
}

groupId = 'io.github.appoptics'
artifactId = "${archivesBaseName}"
version = "${versions.agent}"
def sdkVersion = System.getenv("AGENT_VERSION") ?: "2.6.0"
version = Boolean.parseBoolean(System.getenv("SNAPSHOT_BUILD")) ? "$sdkVersion-SNAPSHOT" : "${versions.agent}"

from components.java
artifact sourcesJar
artifact javadocJar
}
}
publishToMavenLocal
}

repositories {
maven {
name = "OSSRH"
url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"

url = Boolean.parseBoolean(System.getenv("SNAPSHOT_BUILD")) ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username = System.getenv("SONATYPE_USERNAME")
password = System.getenv("SONATYPE_TOKEN")
Expand All @@ -115,7 +122,6 @@ signing {
sign publishing.publications.mavenJava
}


test {
useJUnitPlatform()
testLogging {
Expand Down

0 comments on commit de36002

Please sign in to comment.