Skip to content

Commit

Permalink
Merge branch 'release/5.2' into merge-release/5.1-release/5.2-2023-12…
Browse files Browse the repository at this point in the history
…-01-2
  • Loading branch information
ronanbrowne authored Dec 1, 2023
2 parents 564499e + d5dd750 commit 68eba87
Show file tree
Hide file tree
Showing 17 changed files with 113 additions and 17 deletions.
9 changes: 4 additions & 5 deletions .ci/JenkinsfileMergeAutomation
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#! groovy
@Library('corda-shared-build-pipeline-steps@5.1') _
@Library('corda-shared-build-pipeline-steps@5.2') _

/**
* Forward merge any changes in current branch to the branch with following version.
Expand All @@ -14,19 +14,18 @@
* the branch name of origin branch, it should match the current branch
* and it acts as a fail-safe inside {@code forwardMerger} pipeline
*/
String originBranch = 'release/5.1'
String originBranch = 'release/5.2'

/**
* the branch name of target branch, it should be the branch with the next version
* after the one in current branch.
*/
String targetBranch = 'release/5.2'
String targetBranch = 'release/5.3'

/**
* Forward merge any changes between {@code originBranch} and {@code targetBranch}
*/
forwardMerger(
targetBranch: targetBranch,
originBranch: originBranch,
slackChannel: '#c5-forward-merge-bot-notifications'
)
slackChannel: '#c5-forward-merge-bot-notifications')
2 changes: 1 addition & 1 deletion .ci/JenkinsfileSnykDelta
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@Library('corda-shared-build-pipeline-steps@5.1') _
@Library('corda-shared-build-pipeline-steps@5.2') _

snykDelta(
snykOrgId: 'corda5-snyk-org-id',
Expand Down
5 changes: 2 additions & 3 deletions .ci/nightly/JenkinsfileNightly
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
@Library('corda-shared-build-pipeline-steps@5.1') _
@Library('corda-shared-build-pipeline-steps@5.2') _

cordaPipelineKubernetesAgent(
runIntegrationTests: false,
dailyBuildCron: 'H 02 * * *',
publishOSGiImage: true,
gradleAdditionalArgs: '-Dscan.tag.Nightly-Build',
generateSbom: true,
javaVersion: '17',
workerBaseImageTag: '17.0.4.1-17.36.17'
javaVersion: '17'
)
2 changes: 1 addition & 1 deletion .ci/nightly/JenkinsfileSnykScan
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@Library('corda-shared-build-pipeline-steps@5.1') _
@Library('corda-shared-build-pipeline-steps@5.2') _

cordaSnykScanPipeline (
snykTokenId: 'r3-snyk-corda5',
Expand Down
2 changes: 1 addition & 1 deletion .ci/nightly/JenkinsfileWindowsCompatibility
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@Library('corda-shared-build-pipeline-steps@5.1') _
@Library('corda-shared-build-pipeline-steps@5.2') _

windowsCompatibility(
runIntegrationTests: false,
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/remove-stale-branches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
steps:
- uses: fpicalausa/[email protected]
with:
dry-run: true
dry-run: false
days-before-branch-stale: 30
days-before-branch-delete: 14
stale-branch-message: "@{author} The branch [{branchName}]({branchUrl}) hasn't been updated in the last 30 days and is marked as stale. It will be removed in 14 days.\r\nIf you want to keep this branch around, delete this comment or add new commits to this branch."
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/remove-stale-prs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: 'Close stale issues and PR'
on:
schedule:
- cron: '0 0 * * 1-5'

jobs:
remove-stale-prs:
name: Remove stale PRs
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
debug-only: false
exempt-pr-labels: 'DO_NOT_CLOSE'
stale-pr-message: 'This PR is stale because it has been open 7 days with no activity. Remove the `Stale` label or add a comment - otherwise this will be closed in 7 days.'
close-pr-message: 'This PR was closed because it has been stale for 7 days with no activity.'
days-before-issue-stale: -1
days-before-issue-close: -1
days-before-pr-stale: 7
days-before-pr-close: 7
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@Library('corda-shared-build-pipeline-steps@5.1') _
@Library('corda-shared-build-pipeline-steps@5.2') _

cordaPipelineKubernetesAgent(
runIntegrationTests: false,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package net.corda.cli.api

import picocli.CommandLine.IVersionProvider
import java.util.jar.Manifest

/**
* An abstract class that will read version information out of the plugin manifest.
*
* Builds version information using these attributes:
* - Plugin-Name
* - Plugin-Version
* - Plugin-Provider
* - Plugin-Git-Commit
*
* To apply, inherit from this class:
*
* class VersionProvider : AbstractCordaCliVersionProvider()
*
* Then add to your command annotation:
*
* versionProvider = VersionProvider::class
*/
abstract class AbstractCordaCliVersionProvider : IVersionProvider {
override fun getVersion(): Array<String> = this.javaClass
.getResourceAsStream("/META-INF/MANIFEST.MF")
?.use {
Manifest(it).mainAttributes.run {
arrayOf(
"${getValue("Plugin-Name")} ${getValue("Plugin-Version")}",
"Provider: ${getValue("Plugin-Provider")}",
"Commit ID: ${getValue("Plugin-Git-Commit")}"
)
}
} ?: emptyArray()
}
6 changes: 6 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,15 @@ def cordaCLi = tasks.named('jar', Jar) {
}
from(mergeLog4j2Plugins)

var cliHostCommitId = com.gradle.Utils.execAndGetStdOut "git", "rev-parse", "--verify", "HEAD"

manifest {
attributes["Main-Class"] = appMainClass
attributes["Multi-Release"] = true
attributes["Plugin-Name"] = "Corda CLI"
attributes["Plugin-Version"] = "${project.version}"
attributes["Plugin-Provider"] = "R3"
attributes["Plugin-Git-Commit"] = "$cliHostCommitId"
}

archiveBaseName = 'corda-cli'
Expand Down
9 changes: 8 additions & 1 deletion app/src/main/kotlin/net/corda/cli/application/Boot.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.corda.cli.application

import net.corda.cli.api.CordaCliPlugin
import net.corda.cli.api.AbstractCordaCliVersionProvider
import net.corda.cli.application.logger.LoggerStream
import org.pf4j.CompoundPluginDescriptorFinder
import org.pf4j.DefaultPluginManager
Expand All @@ -14,13 +15,19 @@ fun main(vararg args: String) {
Boot.run(*args)
}

class VersionProvider : AbstractCordaCliVersionProvider()

@CommandLine.Command(
name = "corda-cli"
name = "corda-cli",
versionProvider = VersionProvider::class
)
class App {
@CommandLine.Option(names = ["-h", "--help", "-?", "-help"], usageHelp = true, description = ["Display help and exit."])
@Suppress("unused")
var help = false

@CommandLine.Option(names = ["-V", "--version"], versionHelp = true, description = ["Display version and exit."])
var showVersion = false
}

/**
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/groovy/DeployableContainerBuilder.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ abstract class DeployableContainerBuilder extends DefaultTask {

@Input
final Property<String> baseImageTag =
getObjects().property(String).convention('17.0.4.1-17.36.17')
getObjects().property(String).convention('17.0.8.1-17.44.53')

@Input
final Property<String> subDir =
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
kotlin.stdlib.default.dependency=false

# The version of cli-host we will publish
cliHostVersion=5.1.0
cliHostVersion=5.2.0

# PF4J
pf4jVersion=3.10.0
Expand Down
4 changes: 4 additions & 0 deletions plugins/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@ subprojects { subProject ->

archiveBaseName = "plugin-${subProject.pluginId}"

var commitId = com.gradle.Utils.execAndGetStdOut "git", "rev-parse", "--verify", "HEAD"

manifest {
attributes['Plugin-Class'] = subProject.pluginClass
attributes["Plugin-Name"] = subProject.pluginId
attributes['Plugin-Id'] = subProject.pluginId
attributes['Plugin-Version'] = archiveVersion
attributes['Plugin-Provider'] = subProject.pluginProvider
attributes['Plugin-Description'] = subProject.pluginDescription
attributes["Plugin-Git-Commit"] = "$commitId"
}

from sourceSets.main.output
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package net.corda.cli.plugins.examples
import org.pf4j.Extension
import org.pf4j.Plugin
import net.corda.cli.api.CordaCliPlugin
import net.corda.cli.api.AbstractCordaCliVersionProvider
import picocli.CommandLine

/**
Expand All @@ -16,12 +17,15 @@ class ExamplePlugin : Plugin() {
override fun stop() {
}

class VersionProvider : AbstractCordaCliVersionProvider()

@Extension
@CommandLine.Command(
name = "example-plugin",
subcommands = [SubCommandOne::class],
description = ["Example plugin using class based subcommands"],
mixinStandardHelpOptions = true
mixinStandardHelpOptions = true,
versionProvider = VersionProvider::class
)
class ExamplePluginEntry : CordaCliPlugin
}
8 changes: 8 additions & 0 deletions plugins/example/src/main/resources/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Manifest-Version: 1.0
Main-Class: net.corda.cli.application.BootKt
Multi-Release: true
Plugin-Name: Corda CLI
Plugin-Version: 5.1.0-TEST
Plugin-Provider: R3
Plugin-Git-Commit: TEST

Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package net.corda.cli.plugins.examples

import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
import picocli.CommandLine
import java.io.ByteArrayOutputStream
Expand Down Expand Up @@ -61,6 +63,18 @@ class ExamplePluginTest {
) { outText }
}

@Test
fun testVersionOption() {

val app = ExamplePlugin.ExamplePluginEntry()

val outText = tapSystemOut {
CommandLine(app).execute("--version")
}

assertEquals("Corda CLI 5.1.0-TEST\nProvider: R3\nCommit ID: TEST\n", outText)
}

@Test
fun testSubCommand() {

Expand Down

0 comments on commit 68eba87

Please sign in to comment.