From 648022d5168c2ac48989285ab3a3499d89e262da Mon Sep 17 00:00:00 2001 From: Cheryl King Date: Tue, 23 Jul 2024 12:31:19 -0500 Subject: [PATCH 1/2] Add config parameter to change default key binding for on demand tests in dev mode --- .github/workflows/gradle.yml | 5 +++-- docs/libertyDev.md | 19 ++++++++++--------- .../tools/gradle/tasks/DevTask.groovy | 18 +++++++++++++++--- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 6bef8a39..4e293eb3 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -39,7 +39,8 @@ jobs: - name: Checkout ci.common uses: actions/checkout@v3 with: - repository: OpenLiberty/ci.common + repository: cherylking/ci.common + ref: changeOnDemandTestsHotKey path: ci.common - name: Checkout ci.ant uses: actions/checkout@v3 @@ -124,7 +125,7 @@ jobs: - name: Clone ci.ant, ci.common, ci.gradle repos to C drive run: | cp -r D:/a/ci.gradle/ci.gradle C:/ci.gradle - git clone https://github.com/OpenLiberty/ci.common.git C:/ci.common + git clone https://github.com/cherylking/ci.common.git --branch changeOnDemandTestsHotKey --single-branch C:/ci.common git clone https://github.com/OpenLiberty/ci.ant.git C:/ci.ant # Cache mvn/gradle packages - name: Cache Maven packages diff --git a/docs/libertyDev.md b/docs/libertyDev.md index f5c10408..fb1502e2 100644 --- a/docs/libertyDev.md +++ b/docs/libertyDev.md @@ -17,7 +17,7 @@ While dev mode is running, perform the following in the command terminal to run * g - To toggle the automatic generation of features, type g and press Enter. A new server configuration file will be generated in the SOURCE configDropins/overrides configuration directory. * o - To optimize the list of generated features, type o and press Enter. A new server configuration file will be generated in the SOURCE configDropins/overrides configuration directory. -* Enter - To run tests on demand, press Enter. +* t or Enter - If `changeOnDemandTestAction` is enabled, type t and press Enter to run tests on demand. Otherwise, press Enter. * r - To restart the server, type r and press Enter. * h - To see the help menu for available actions, type h and press Enter. * q - stop the server and quit dev mode, press Ctrl-C, or type q and press Enter. @@ -62,15 +62,16 @@ The following are optional command line parameters supported by this task. | Parameter | Description | Required | | -------- | ----------- | ------- | +| changeOnDemandTestsAction | If this option is enabled, change the action for running on demand tests from `Enter` to type `t` and press `Enter`. The default value is `false`. This parameter is introduced in version 3.8.4. | No | +| compileWait | Time in seconds to wait before processing Java changes. If you encounter compile errors while refactoring, increase this value to allow all files to be saved before compilation occurs. The default value is `0.5` seconds. | No | +| generateFeatures | If set to `true`, when a Java file, server configuration file, or build file is changed, generate features required by the application in the source configuration directory. The default value is `false`. | No | | hotTests | If this option is enabled, run tests automatically after every change. The default value is `false`. | No | -| skipTests | If this option is enabled, do not run any tests in dev mode, even when the `Enter` key is pressed or when `hotTests` is set to `true`. The default value is `false`. | No | | libertyDebug | Whether to allow attaching a debugger to the running server. The default value is `true`. | No | | libertyDebugPort | The debug port that you can attach a debugger to. The default value is `7777`. | No | -| compileWait | Time in seconds to wait before processing Java changes. If you encounter compile errors while refactoring, increase this value to allow all files to be saved before compilation occurs. The default value is `0.5` seconds. | No | | serverStartTimeout | Maximum time to wait (in seconds) to verify that the server has started. The value must be an integer greater than or equal to 0. The default value is `90` seconds. | No | -| verifyAppStartTimeout | Maximum time to wait (in seconds) to verify that the application has started or updated before running tests. The value must be an integer greater than or equal to 0. The default value is `30` seconds. | No | -| generateFeatures | If set to `true`, when a Java file, server configuration file, or build file is changed, generate features required by the application in the source configuration directory. The default value is `false`. | No | | skipInstallFeature | If set to `true`, the `installFeature` task will be skipped when `dev` mode is started on an already existing Liberty runtime installation. It will also be skipped when `dev` mode is running and a restart of the server is triggered either directly by the user or by application changes. The `installFeature` task will be invoked though when `dev` mode is running and a change to the configured features is detected. The default value is `false`. | No | +| skipTests | If this option is enabled, do not run any tests in dev mode, even when the on demand test action is entered or when `hotTests` is set to `true`. The default value is `false`. | No | +| verifyAppStartTimeout | Maximum time to wait (in seconds) to verify that the application has started or updated before running tests. The value must be an integer greater than or equal to 0. The default value is `30` seconds. | No | ### Properties @@ -164,7 +165,7 @@ While dev mode is running in container mode, perform the following in the comman * g - To toggle the automatic generation of features, type g and press Enter. A new server configuration file will be generated in the SOURCE configDropins/overrides configuration directory. * o - To optimize the list of generated features, type o and press Enter. A new server configuration file will be generated in the SOURCE configDropins/overrides configuration directory. -* Enter - To run tests on demand, press Enter. +* t or Enter - If `changeOnDemandTestAction` is enabled, type t and press Enter to run tests on demand. Otherwise, press Enter. * r - To rebuild the container image and restart the container, type r and press Enter. * h - To see the help menu for available actions, type h and press Enter. * q - stop the server and quit dev mode, press Ctrl-C, or type q and press Enter. @@ -247,9 +248,9 @@ These can also be specified as command line parameters in addition to the ones i | Attribute | Type | Since | Description | Required | | --------- | ----- | ----- | ----------- | -------- | | container | boolean | 3.1-M1 | If set to `true`, run the server in the container specified by the `containerfile` parameter. Setting this to `true` and using the `libertyDev` task is equivalent to using the `libertyDevc` task. The default value is `false` when the `libertyDev` task is used, and `true` when the `libertyDevc` task is used. | No | -| containerRunOpts | String | 3.7 | Specifies options to add to the container `run` command when using dev mode to launch your server in a container. For example, `-e key=value` is recognized by `docker run` to define an environment variable with the name `key` and value `value`. This attribute replaces the deprecated `dockerRunOpts` attribute and will take precedence. | No | -| containerfile | File | 3.7 | Location of a Containerfile or Dockerfile to be used by dev mode to build the image for the container that will run your Liberty server. The default location is `Containerfile` or `Dockerfile` in the project root. This attribute replaces the deprecated `dockerfile` attribute and will take precedence. | No | | containerBuildContext | File | 3.7 | The container build context directory to be used by dev mode for the container `build` command. The default location is the directory of the Containerfile/Dockerfile. This attribute replaces the deprecated `dockerBuildContext` attribute and will take precedence. | No | | containerBuildTimeout | integer | 3.7 | Maximum time to wait (in seconds) for the completion of the container operation to build the image. The value must be an integer greater than 0. The default value is `600` seconds. This attribute replaces the deprecated `dockerBuildTimeout` attribute and will take precedence. | No | -| skipDefaultPorts | boolean | 3.1-M3 | If set to `true`, dev mode will not publish the default container port mappings of `9080:9080` (HTTP) and `9443:9443` (HTTPS). Use this option if you would like to specify alternative local ports to map to the exposed container ports for HTTP and HTTPS using the `containerRunOpts` parameter. | No | +| containerfile | File | 3.7 | Location of a Containerfile or Dockerfile to be used by dev mode to build the image for the container that will run your Liberty server. The default location is `Containerfile` or `Dockerfile` in the project root. This attribute replaces the deprecated `dockerfile` attribute and will take precedence. | No | +| containerRunOpts | String | 3.7 | Specifies options to add to the container `run` command when using dev mode to launch your server in a container. For example, `-e key=value` is recognized by `docker run` to define an environment variable with the name `key` and value `value`. This attribute replaces the deprecated `dockerRunOpts` attribute and will take precedence. | No | | keepTempContainerfile | boolean | 3.7 | If set to `true`, dev mode will not delete the temporary modified copy of your Containerfile/Dockerfile used to build the container image. This file is handy in case you need to debug the process of building the container image. The path of the temporary Containerfile/Dockerfile can be seen when dev mode displays the container `build` command. The default value is `false`. This attribute replaces the deprecated `keepTempDockerfile` attribute and will take precedence. | No | +| skipDefaultPorts | boolean | 3.1-M3 | If set to `true`, dev mode will not publish the default container port mappings of `9080:9080` (HTTP) and `9443:9443` (HTTPS). Use this option if you would like to specify alternative local ports to map to the exposed container ports for HTTP and HTTPS using the `containerRunOpts` parameter. | No | diff --git a/src/main/groovy/io/openliberty/tools/gradle/tasks/DevTask.groovy b/src/main/groovy/io/openliberty/tools/gradle/tasks/DevTask.groovy index 4fdeddb0..bdf94f2f 100644 --- a/src/main/groovy/io/openliberty/tools/gradle/tasks/DevTask.groovy +++ b/src/main/groovy/io/openliberty/tools/gradle/tasks/DevTask.groovy @@ -89,6 +89,7 @@ class DevTask extends AbstractFeatureTask { private static final boolean DEFAULT_KEEP_TEMP_CONTAINERFILE = false; private static final boolean DEFAULT_GENERATE_FEATURES = false; private static final boolean DEFAULT_SKIP_INSTALL_FEATURE = false; + private static final boolean DEFAULT_CHANGE_ON_DEMAND_TESTS_ACTION = false; // Debug port for BuildLauncher tasks launched from DevTask as parent JVM // (parent defaults to '5005') @@ -97,6 +98,13 @@ class DevTask extends AbstractFeatureTask { protected final String CONTAINER_PROPERTY_ARG = '-P'+CONTAINER_PROPERTY+'=true'; + private Boolean changeOnDemandTestsAction; + + @Option(option = 'changeOnDemandTestsAction', description = 'If this option is enabled, change the action for running on demand tests from Enter to type t and press Enter. The default value is false.') + void setChangeOnDemandTestsAction(boolean changeOnDemandTestsAction) { + this.changeOnDemandTestsAction = changeOnDemandTestsAction; + } + private Boolean hotTests; @Option(option = 'hotTests', description = 'If this option is enabled, run tests automatically after every change. The default value is false.') @@ -361,7 +369,7 @@ class DevTask extends AbstractFeatureTask { private ServerTask serverTask = null; DevTaskUtil(File buildDir, File installDirectory, File userDirectory, File serverDirectory, File sourceDirectory, File testSourceDirectory, - File configDirectory, File projectDirectory, List resourceDirs, + File configDirectory, File projectDirectory, List resourceDirs, boolean changeOnDemandTestsAction, boolean hotTests, boolean skipTests, boolean skipInstallFeature, String artifactId, int serverStartTimeout, int verifyAppStartTimeout, int appUpdateTimeout, double compileWait, boolean libertyDebug, boolean pollingTest, boolean container, File containerfile, File containerBuildContext, @@ -369,7 +377,7 @@ class DevTask extends AbstractFeatureTask { String mavenCacheLocation, String packagingType, File buildFile, boolean generateFeatures ) throws IOException, PluginExecutionException { super(buildDir, serverDirectory, sourceDirectory, testSourceDirectory, configDirectory, projectDirectory, /* multi module project directory */ projectDirectory, - resourceDirs, hotTests, skipTests, false /* skipUTs */, false /* skipITs */, skipInstallFeature, artifactId, serverStartTimeout, + resourceDirs, changeOnDemandTestsAction, hotTests, skipTests, false /* skipUTs */, false /* skipITs */, skipInstallFeature, artifactId, serverStartTimeout, verifyAppStartTimeout, appUpdateTimeout, ((long) (compileWait * 1000L)), libertyDebug, true /* useBuildRecompile */, true /* gradle */, pollingTest, container, containerfile, containerBuildContext, containerRunOpts, containerBuildTimeout, skipDefaultPorts, null /* compileOptions not needed since useBuildRecompile is true */, keepTempContainerfile, mavenCacheLocation, null /* multi module upstream projects */, @@ -1166,6 +1174,10 @@ class DevTask extends AbstractFeatureTask { libertyDebugPort = DEFAULT_DEBUG_PORT; } + if (changeOnDemandTestsAction == null) { + changeOnDemandTestsAction = DEFAULT_CHANGE_ON_DEMAND_TESTS_ACTION; + } + if (hotTests == null) { hotTests = DEFAULT_HOT_TESTS; } @@ -1246,7 +1258,7 @@ class DevTask extends AbstractFeatureTask { try { this.util = new DevTaskUtil(project.buildDir, serverInstallDir, getUserDir(project, serverInstallDir), serverDirectory, sourceDirectory, testSourceDirectory, configDirectory, project.getRootDir(), - resourceDirs, hotTests.booleanValue(), skipTests.booleanValue(), skipInstallFeature.booleanValue(), artifactId, serverStartTimeout.intValue(), + resourceDirs, changeOnDemandTestsAction.booleanValue(), hotTests.booleanValue(), skipTests.booleanValue(), skipInstallFeature.booleanValue(), artifactId, serverStartTimeout.intValue(), verifyAppStartTimeout.intValue(), verifyAppStartTimeout.intValue(), compileWait.doubleValue(), libertyDebug.booleanValue(), pollingTest.booleanValue(), container.booleanValue(), containerfile, containerBuildContext, containerRunOpts, containerBuildTimeout, skipDefaultPorts.booleanValue(), keepTempContainerfile.booleanValue(), localMavenRepoForFeatureUtility, From a8eccd77b353643483f20816a4ca4d813e34cf64 Mon Sep 17 00:00:00 2001 From: Cheryl King Date: Wed, 24 Jul 2024 17:42:37 -0500 Subject: [PATCH 2/2] remove yaml change for using my ci.common branch --- .github/workflows/gradle.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 4e293eb3..6bef8a39 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -39,8 +39,7 @@ jobs: - name: Checkout ci.common uses: actions/checkout@v3 with: - repository: cherylking/ci.common - ref: changeOnDemandTestsHotKey + repository: OpenLiberty/ci.common path: ci.common - name: Checkout ci.ant uses: actions/checkout@v3 @@ -125,7 +124,7 @@ jobs: - name: Clone ci.ant, ci.common, ci.gradle repos to C drive run: | cp -r D:/a/ci.gradle/ci.gradle C:/ci.gradle - git clone https://github.com/cherylking/ci.common.git --branch changeOnDemandTestsHotKey --single-branch C:/ci.common + git clone https://github.com/OpenLiberty/ci.common.git C:/ci.common git clone https://github.com/OpenLiberty/ci.ant.git C:/ci.ant # Cache mvn/gradle packages - name: Cache Maven packages