-
Notifications
You must be signed in to change notification settings - Fork 2
feat(cli): compile plugin to native CLI #15
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| * @Monforton @thestuckster |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| name: Create new release | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| tag: | ||
| description: 'Tag for the release (e.g., 1.0.0)' | ||
| required: true | ||
| default: '0.0.0' | ||
| draft-release: | ||
| description: 'Should this release be a draft?' | ||
| type: boolean | ||
| required: false | ||
| default: true | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| matrix: | ||
| os: [ ubuntu-latest, windows-latest, macos-latest ] | ||
| include: | ||
| - os: ubuntu-latest | ||
| graalvm-home: /usr/lib/graalvm | ||
| - os: windows-latest | ||
| graalvm-home: C:\graalvm | ||
| - os: macos-latest | ||
| graalvm-home: /Library/Java/JavaVirtualMachines/graalvm | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup GraalVM | ||
| uses: graalvm/setup-graalvm@v1 | ||
|
Monforton marked this conversation as resolved.
|
||
| with: | ||
| java-version: '17.0.12' | ||
| distribution: 'graalvm' | ||
| #github-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Build native executable | ||
| env: | ||
| VERSION_TAG: ${{ github.event.inputs.tag }} | ||
| run: ./gradlew nativeImage -Pversion="$VERSION_TAG" | ||
|
|
||
| - name: Upload native executable | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: native-executable-${{ matrix.os }} | ||
| path: build/native-image/fern-junit-client* | ||
|
|
||
| release: | ||
| needs: build | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Download all artifacts | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| path: artifacts | ||
|
Monforton marked this conversation as resolved.
|
||
|
|
||
| - name: Make artifacts executable | ||
| run: chmod +x artifacts/native-executable-* | ||
|
|
||
| - name: Create GitHub Release | ||
| id: create_release | ||
| uses: ncipollo/release-action@v1 | ||
|
Monforton marked this conversation as resolved.
|
||
| with: | ||
| allowUpdates: true | ||
| draft: "${{ github.event.inputs.draft-release }}" | ||
| generateReleaseNotes: true | ||
| artifacts: artifacts/** | ||
| #token: ${{ secrets.GITHUB_TOKEN }} | ||
| tag: 'v${{ github.event.inputs.tag }}' | ||
| name: 'v${{ github.event.inputs.tag }}' | ||
|
|
||
| - name: Add release URL to job summary | ||
| if: success() | ||
| run: | | ||
| echo "Release URL: ${{ steps.create_release.outputs.html_url }}" | ||
| echo "Release URL: ${{ steps.create_release.outputs.html_url }}" >> $GITHUB_STEP_SUMMARY | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,64 +1,164 @@ | ||
| import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform | ||
|
|
||
| plugins { | ||
| id 'org.jetbrains.kotlin.jvm' version '2.1.20' | ||
| id 'org.jetbrains.kotlin.plugin.serialization' version '2.1.20' | ||
| id 'java-gradle-plugin' | ||
| id 'com.gradle.plugin-publish' version '1.2.1' | ||
| id 'com.gradleup.shadow' version "8.3.6" | ||
| id 'maven-publish' // Add this plugin to use publishing block | ||
| id 'org.jetbrains.kotlin.jvm' version '2.1.20' | ||
| id 'org.jetbrains.kotlin.plugin.serialization' version '2.1.20' | ||
| id 'java-gradle-plugin' | ||
| id "org.graalvm.buildtools.native" version "0.10.6" // GraalVM plugin | ||
| id 'application' | ||
| id 'com.gradle.plugin-publish' version '1.2.1' | ||
| id 'com.gradleup.shadow' version "8.3.6" | ||
| id 'maven-publish' // Add this plugin to use publishing block | ||
| } | ||
|
|
||
| group = 'io.github.guidewire-oss' | ||
| version = '1.0.0' | ||
| version = project.hasProperty('version') ? project.version : '1.0.0' | ||
|
|
||
| def os = DefaultNativePlatform.currentOperatingSystem | ||
| def arch = DefaultNativePlatform.currentArchitecture | ||
|
|
||
| gradlePlugin { | ||
| website = "https://github.com/guidewire-oss/fern-junit-gradle-plugin" | ||
| vcsUrl = "https://github.com/guidewire-oss/fern-junit-gradle-plugin" | ||
| plugins { | ||
| create("fernPublisher") { | ||
| id = "io.github.guidewire-oss.fern-publisher" | ||
| displayName = 'fern-publisher' | ||
| description = 'This plugin simplifies the process of collecting JUnit XML test reports and publishing them to a Fern test reporting service. It parses JUnit XML reports, converts them to Fern\'s data model, and sends them to your Fern instance through its API. To learn more about Fern, check out its repository: https://github.com/guidewire-oss/fern-reporter' | ||
| tags = ['testing', 'testing-tools', 'reporter', 'fern', 'test-reporter'] | ||
| implementationClass = "io.github.guidewire.oss.plugin.FernPublisherPlugin" | ||
| } | ||
| website = "https://github.com/guidewire-oss/fern-junit-gradle-plugin" | ||
| vcsUrl = "https://github.com/guidewire-oss/fern-junit-gradle-plugin" | ||
| plugins { | ||
| create("fernPublisher") { | ||
| id = "io.github.guidewire-oss.fern-publisher" | ||
| displayName = 'fern-publisher' | ||
| description = 'This plugin simplifies the process of collecting JUnit XML test reports and publishing them to a Fern test reporting service. It parses JUnit XML reports, converts them to Fern\'s data model, and sends them to your Fern instance through its API. To learn more about Fern, check out its repository: https://github.com/guidewire-oss/fern-reporter' | ||
| tags = ['testing', 'testing-tools', 'reporter', 'fern', 'test-reporter'] | ||
| implementationClass = "io.github.guidewire.oss.plugin.FernPublisherPlugin" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| publishing { | ||
| repositories { | ||
| mavenLocal() | ||
| } | ||
| repositories { | ||
| mavenLocal() | ||
| } | ||
| } | ||
|
|
||
| repositories { | ||
| mavenLocal() | ||
| mavenCentral() | ||
| mavenLocal() | ||
| mavenCentral() | ||
| } | ||
|
|
||
| shadowJar { | ||
| archiveClassifier.set('') // This removes the default 'all' classifier | ||
| archiveClassifier.set('') // This removes the default 'all' classifier | ||
| } | ||
|
|
||
| dependencies { | ||
| implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0' | ||
| implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0" | ||
| implementation "com.github.ajalt.clikt:clikt:5.0.1" | ||
|
|
||
| testImplementation "org.jetbrains.kotlin:kotlin-test" | ||
| testImplementation "org.assertj:assertj-core:3.27.3" | ||
| testImplementation "org.junit.jupiter:junit-jupiter:5.9.2" | ||
| testImplementation "org.wiremock:wiremock:3.12.1" | ||
| testImplementation gradleTestKit() | ||
|
|
||
| testRuntimeOnly "org.junit.platform:junit-platform-launcher" | ||
| } | ||
|
|
||
| application { | ||
| mainClass = "io.github.guidewire.oss.MainKt" | ||
| } | ||
|
|
||
| jar { | ||
| manifest { | ||
| attributes 'Main-Class': 'io.github.guidewire.oss.MainKt' | ||
| } | ||
| exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA' // NECESSARY TO BUILD JAR | ||
|
|
||
| // Include all dependencies in the jar (fat jar) | ||
| from { | ||
| configurations.runtimeClasspath.collect { | ||
| it.isDirectory() ? it : zipTree(it) | ||
| } | ||
| } | ||
| duplicatesStrategy = DuplicatesStrategy.EXCLUDE | ||
| } | ||
|
|
||
| // Currently just used to pass the version. If you can find a better way of doing this, then go for it | ||
| task generateProps { | ||
| def propsFile = layout.buildDirectory.file("resources/main/app.properties") | ||
|
|
||
| doLast { | ||
| file(propsFile.get().asFile).write("appVersion=$version") | ||
| } | ||
| } | ||
|
|
||
| task nativeImage(type: Exec) { | ||
| group = 'build' | ||
| description = 'Builds a native image using GraalVM' | ||
|
|
||
| def outputName = "fern-junit-client-${version}-${os.toFamilyName()}-${arch.name}" | ||
| def graalVmHome = System.getenv('GRAALVM_HOME') | ||
|
|
||
| dependsOn("generateProps") | ||
| dependsOn tasks.jar | ||
|
|
||
| doFirst { | ||
| if (graalVmHome == null) { | ||
| throw new GradleException('GRAALVM_HOME environment variable not set') | ||
| } | ||
|
|
||
| def nativeImageCmd = "${graalVmHome}/bin/native-image${os.isWindows() ? '.cmd' : ''}" | ||
| if (!new File(nativeImageCmd).exists()) { | ||
| throw new GradleException("Native image command not found at: $nativeImageCmd") | ||
| } | ||
|
|
||
| // Create a special jar for native image building, excluding Gradle plugin classes | ||
|
Monforton marked this conversation as resolved.
|
||
| copy { | ||
| from jar.outputs | ||
| into "${buildDir}/native-image" | ||
| rename {fileName -> | ||
| fileName.replace(jar.archiveFileName.get(), "native-${jar.archiveFileName.get()}") | ||
| } | ||
| } | ||
|
|
||
| // Remove Gradle plugin classes from the jar | ||
| fileTree("${buildDir}/native-image").matching { | ||
| include "native-${jar.archiveFileName.get()}" | ||
| }.each {jarFile -> | ||
| ant.zip(destfile: "${buildDir}/native-image/temp.jar") { | ||
| zipfileset(src: jarFile) { | ||
| exclude(name: "org/gradle/internal/impldep/org/bouncycastle/jcajce/provider/drbg/**") | ||
| exclude(name: "com/guidewire/plugin/**") | ||
| exclude(name: "META-INF/gradle-plugins/**") | ||
| } | ||
| } | ||
| delete jarFile | ||
| file("${buildDir}/native-image/temp.jar").renameTo(jarFile) | ||
| } | ||
| } | ||
|
|
||
| testImplementation 'org.jetbrains.kotlin:kotlin-test' | ||
| testImplementation("org.assertj:assertj-core:3.27.3") | ||
| testImplementation "org.junit.jupiter:junit-jupiter:5.9.2" | ||
| testImplementation "org.wiremock:wiremock:3.12.1" | ||
| testImplementation(gradleTestKit()) | ||
| workingDir = "${buildDir}/native-image" | ||
| def jarName = "native-${project.name}-${project.version}-main.jar" | ||
|
Monforton marked this conversation as resolved.
|
||
|
|
||
| testRuntimeOnly "org.junit.platform:junit-platform-launcher" | ||
| commandLine = [ | ||
| "${graalVmHome}/bin/native-image${os.isWindows() ? '.cmd' : ''}", | ||
| '--no-fallback', | ||
| '--enable-url-protocols=https', | ||
| '-H:+ReportExceptionStackTraces', | ||
| '-H:ReflectionConfigurationFiles=../../src/main/resources/reflect-config.json', | ||
|
Monforton marked this conversation as resolved.
|
||
| '--initialize-at-build-time=kotlin', | ||
| '--initialize-at-build-time=kotlinx', | ||
| '--initialize-at-build-time=io.github.guidewire.oss', | ||
| '--initialize-at-build-time=org.slf4j', | ||
| '--initialize-at-build-time=org.gradle.internal', | ||
| '-jar', jarName, | ||
| outputName | ||
| ] | ||
| } | ||
|
|
||
| tasks.test { | ||
| useJUnitPlatform() | ||
| useJUnitPlatform() | ||
| } | ||
|
|
||
| test { | ||
| useJUnitPlatform() | ||
| useJUnitPlatform() | ||
| } | ||
|
|
||
| kotlin { | ||
| jvmToolchain(17) | ||
| jvmToolchain(17) | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.