From 18952798f273ba99fc06d8ec02a70ccf4f3249d3 Mon Sep 17 00:00:00 2001 From: Github Actions Date: Tue, 25 Jun 2024 15:47:53 +0000 Subject: [PATCH 01/17] Version bump --- box.json | 8 ++++---- changelog.md | 7 +++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/box.json b/box.json index 0304813..001cb44 100644 --- a/box.json +++ b/box.json @@ -1,6 +1,6 @@ { "name":"ColdBox ORM Extensions", - "version":"4.5.0", + "version":"4.6.0", "location":"https://downloads.ortussolutions.com/ortussolutions/coldbox-modules/cborm/@build.version@/cborm-@build.version@.zip", "author":"Ortus Solutions Date: Sun, 29 Sep 2024 14:53:15 -0700 Subject: [PATCH 02/17] trying to add flow delegates to active entity --- models/ActiveEntity.cfc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/models/ActiveEntity.cfc b/models/ActiveEntity.cfc index 1230357..dbe7862 100644 --- a/models/ActiveEntity.cfc +++ b/models/ActiveEntity.cfc @@ -18,7 +18,12 @@ * * These methods are only active if WireBox entity injection is available. */ -component extends="cborm.models.VirtualEntityService" accessors="true" { +component + extends="cborm.models.VirtualEntityService" + accessors="true" + transientCache = false + delegates = "Flow@coreDelegates" +{ /** * If populated, it will be from the last cbValidation made on the entity From 2f2c30035b7ce5fa4ab8b1313d76de588c2c31dd Mon Sep 17 00:00:00 2001 From: lmajano Date: Sun, 29 Sep 2024 21:53:52 +0000 Subject: [PATCH 03/17] Apply cfformat changes --- models/ActiveEntity.cfc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/models/ActiveEntity.cfc b/models/ActiveEntity.cfc index dbe7862..72e80a3 100644 --- a/models/ActiveEntity.cfc +++ b/models/ActiveEntity.cfc @@ -19,10 +19,10 @@ * These methods are only active if WireBox entity injection is available. */ component - extends="cborm.models.VirtualEntityService" - accessors="true" - transientCache = false - delegates = "Flow@coreDelegates" + extends ="cborm.models.VirtualEntityService" + accessors ="true" + transientCache=false + delegates ="Flow@coreDelegates" { /** From ecb6c2d9bc2ee040d05a87fa814fa055ad1db844 Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Sun, 29 Sep 2024 15:05:01 -0700 Subject: [PATCH 04/17] testing flows --- test-harness/tests/specs/ActiveEntityTest.cfc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test-harness/tests/specs/ActiveEntityTest.cfc b/test-harness/tests/specs/ActiveEntityTest.cfc index b3f46e9..60e07e7 100755 --- a/test-harness/tests/specs/ActiveEntityTest.cfc +++ b/test-harness/tests/specs/ActiveEntityTest.cfc @@ -104,7 +104,7 @@ t = activeUser.findByLastName(); } - function testIsValid(){ + function testIsValidWithFlow(){ r = activeUser.isValid(); assertFalse( r ); @@ -112,6 +112,11 @@ activeUser.setLastName( "Majano" ); activeUser.setUsername( "LuisMajano" ); activeUser.setPassword( "LuisMajano" ); + + activeUser.peek( ( user ) => { + debug( "In Peek" ); + } ); + r = activeUser.isValid(); assertTrue( r ); } From 665d4ed26d7e8c903a3cd7caf9c64d685fd49962 Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Sun, 29 Sep 2024 16:26:02 -0700 Subject: [PATCH 05/17] adding a few flow helpers --- models/ActiveEntity.cfc | 121 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 119 insertions(+), 2 deletions(-) diff --git a/models/ActiveEntity.cfc b/models/ActiveEntity.cfc index 72e80a3..d28635c 100644 --- a/models/ActiveEntity.cfc +++ b/models/ActiveEntity.cfc @@ -21,8 +21,6 @@ component extends ="cborm.models.VirtualEntityService" accessors ="true" - transientCache=false - delegates ="Flow@coreDelegates" { /** @@ -389,4 +387,123 @@ component return this; } + /** + * This function will execute the target closure and return the delegated object so you + * can continue chaining. + *
+	 *  // Example Flow
+	 *  user
+	 * 	.setName( "Luis" )
+	 *  .setAge( 21 )
+	 *  .peek( user => println( user.getName() ) )
+	 *  .setEmail( "lmajano@ortus.com" )
+	 * 
+ * + * @target The closure to execute with the delegate. We pass the target of the delegate as the first argument. + * + * @return Returns itself + */ + function peek( required target ){ + arguments.target( this ); + return this; + } + + /** + * This function evaluates the target boolean expression and if `true` it will execute the `success` closure + * else, if the `failure` closure is passed, it will execute it. + * + * @target The boolean evaluator, this can be a boolean value + * @success The closure/lambda to execute if the boolean value is true + * @failure The closure/lambda to execute if the boolean value is false + * + * @return Returns itself + */ + function when( + required boolean target, + required success, + failure + ){ + if ( arguments.target ) { + arguments.success(); + } else if ( !isNull( arguments.failure ) ) { + arguments.failure(); + } + return this; + } + + /** + * This function evaluates the target boolean expression and if `false` it will execute the `success` closure + * else, if the `failure` closure is passed, it will execute it. + * + * @target The boolean evaluator, this can be a boolean value + * @success The closure/lambda to execute if the boolean value is true + * @failure The closure/lambda to execute if the boolean value is false + * + * @return Returns itself + */ + function unless( + required boolean target, + required success, + failure + ){ + if ( !arguments.target ) { + arguments.success(); + } else if ( !isNull( arguments.failure ) ) { + arguments.failure(); + } + return this; + } + + /** + * This function evaluates the target boolean expression and if `true` it will throw the controlled exception + * + * @target The boolean evaluator, this can be a boolean value + * @type The exception type + * @message The exception message + * @detail The exception detail + * + * @return Returns itself + */ + function throwIf( + required boolean target, + required type, + message = "", + detail = "" + ) { + if ( arguments.target ) { + throw( + type = arguments.type, + message = arguments.message, + detail = arguments.detail + ); + } + return this; + } + + /** + * This function evaluates the target boolean expression and if `false` it will throw the controlled exception + * + * @target The boolean evaluator, this can be a boolean value + * @type The exception type + * @message The exception message + * @detail The exception detail + * + * @return Returns itself + */ + function throwUnless( + required boolean target, + required type, + message = "", + detail = "" + ) { + if ( !arguments.target ) { + throw( + type = arguments.type, + message = arguments.message, + detail = arguments.detail + ); + } + return this; + } + } From 17098d6837deff25629626ac7314aadb443d4a92 Mon Sep 17 00:00:00 2001 From: lmajano Date: Sun, 29 Sep 2024 23:26:38 +0000 Subject: [PATCH 06/17] Apply cfformat changes --- models/ActiveEntity.cfc | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/models/ActiveEntity.cfc b/models/ActiveEntity.cfc index d28635c..c30c7a9 100644 --- a/models/ActiveEntity.cfc +++ b/models/ActiveEntity.cfc @@ -18,10 +18,7 @@ * * These methods are only active if WireBox entity injection is available. */ -component - extends ="cborm.models.VirtualEntityService" - accessors ="true" -{ +component extends="cborm.models.VirtualEntityService" accessors="true" { /** * If populated, it will be from the last cbValidation made on the entity @@ -469,7 +466,7 @@ component required type, message = "", detail = "" - ) { + ){ if ( arguments.target ) { throw( type = arguments.type, @@ -495,7 +492,7 @@ component required type, message = "", detail = "" - ) { + ){ if ( !arguments.target ) { throw( type = arguments.type, From 33f095f5c16d936781dcbd269f6af958df0524a6 Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Tue, 19 Nov 2024 11:24:02 +0100 Subject: [PATCH 07/17] docs --- changelog.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/changelog.md b/changelog.md index 905a382..abec654 100644 --- a/changelog.md +++ b/changelog.md @@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Added several flow helpers to `ActiveEntity`: + - `peek( closure )` to allow for peeking into the building process. Pass in your closure that receives the entity and interact with it. + - `when( boolean, successClosure, failureClosure )` that you can use to build functional entities without the use of if statements. + - `unless( boolean, successClosure, failureClosure )` that you can use to build functional entities without the use of if statements. The opposite of `when()`. + - `throwIf( boolean, type, [message], [detail] )` that you can use to throw an exception if a condition is met. + - `throwUnless( boolean, type, [message], [detail] )` that you can use to throw an exception if a condition is not met. + ## [4.5.0] - 2024-06-25 ### Added From 11e45abd90848c98280c12fb714a8a74773457b7 Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Tue, 19 Nov 2024 11:35:38 +0100 Subject: [PATCH 08/17] updated github actions --- .github/workflows/pr.yml | 2 +- .github/workflows/snapshot.yml | 2 +- .github/workflows/tests.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index d78c2d7..a48c550 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -22,7 +22,7 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Checkout Repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - uses: Ortus-Solutions/commandbox-action@v1.0.2 with: diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index 45d7dd1..63aca2e 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -20,7 +20,7 @@ jobs: name: Code Auto-Formatting runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Auto-format uses: Ortus-Solutions/commandbox-action@v1.0.2 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7b8eaab..d0750e1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -39,7 +39,7 @@ jobs: uses: actions/checkout@v4 - name: Setup Java - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: "temurin" java-version: "11" From 6ff96ec31b6d675145682ee383d3605c38357220 Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Tue, 19 Nov 2024 11:48:13 +0100 Subject: [PATCH 09/17] CBORM-37 #resolved --- changelog.md | 4 +++ models/BaseORMService.cfc | 20 ++--------- models/EventHandler.cfc | 48 ++++++++++++++------------ models/util/support/ORMUtilSupport.cfc | 25 ++++++++++++++ 4 files changed, 57 insertions(+), 40 deletions(-) diff --git a/changelog.md b/changelog.md index abec654..1bcf946 100644 --- a/changelog.md +++ b/changelog.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- [CBORM-37](https://ortussolutions.atlassian.net/browse/CBORM-37) - Fixed issue on `PostLoad` event handler for multi-datasource entities + ### Added - Added several flow helpers to `ActiveEntity`: diff --git a/models/BaseORMService.cfc b/models/BaseORMService.cfc index f5b73b3..21e3c54 100644 --- a/models/BaseORMService.cfc +++ b/models/BaseORMService.cfc @@ -1201,25 +1201,11 @@ component accessors="true" { * Returns the entity name from a given entity object via session lookup or if new object via metadata lookup * * @entity The entity to get it's name from + * + * @return The entity name */ function getEntityGivenName( required entity ){ - // Short-cut discovery via ActiveEntity - if ( structKeyExists( arguments.entity, "getEntityName" ) ) { - return arguments.entity.getEntityName(); - } - - // Hibernate Discovery - try { - var entityName = getOrm() - .getSession( getOrm().getEntityDatasource( arguments.entity ) ) - .getEntityName( arguments.entity ); - } catch ( org.hibernate.TransientObjectException e ) { - // ignore it, it is not in session, go for long-discovery - } - - // Long Discovery - var md = getMetadata( arguments.entity ); - return ( md.keyExists( "entityName" ) ? md.entityName : listLast( md.name, "." ) ); + return getOrm().getEntityGivenName( arguments.entity ); } /*****************************************************************************************/ diff --git a/models/EventHandler.cfc b/models/EventHandler.cfc index 5bb0ebd..3724452 100644 --- a/models/EventHandler.cfc +++ b/models/EventHandler.cfc @@ -17,25 +17,15 @@ component extends="coldbox.system.remote.ColdboxProxy" implements="CFIDE.orm.IEv * preLoad called by hibernate which in turn announces a coldbox interception: ORMPreLoad */ public void function preLoad( any entity ){ - announce( "ORMPreLoad", { entity : arguments.entity } ); + announce( "ORMPreLoad", { "entity" : arguments.entity } ); } /** * postLoad called by hibernate which in turn announces a coldbox interception: ORMPostLoad */ public void function postLoad( any entity ){ - var args = { entity : arguments.entity, entityName : "" }; - - // Short-cut discovery via ActiveEntity - if ( structKeyExists( arguments.entity, "getEntityName" ) ) { - args.entityName = arguments.entity.getEntityName(); - } else { - // it must be in session. - args.entityName = ormGetSession().getEntityName( arguments.entity ); - } - + var args = { "entity" : arguments.entity, "entityName" : getOrm().getEntityGivenName( arguments.entity ) }; processEntityInjection( args.entityName, args.entity ); - announce( "ORMPostLoad", args ); } @@ -43,77 +33,77 @@ component extends="coldbox.system.remote.ColdboxProxy" implements="CFIDE.orm.IEv * postDelete called by hibernate which in turn announces a coldbox interception: ORMPostDelete */ public void function postDelete( any entity ){ - announce( "ORMPostDelete", { entity : arguments.entity } ); + announce( "ORMPostDelete", { "entity" : arguments.entity } ); } /** * preDelete called by hibernate which in turn announces a coldbox interception: ORMPreDelete */ public void function preDelete( any entity ){ - announce( "ORMPreDelete", { entity : arguments.entity } ); + announce( "ORMPreDelete", { "entity" : arguments.entity } ); } /** * preUpdate called by hibernate which in turn announces a coldbox interception: ORMPreUpdate */ public void function preUpdate( any entity, Struct oldData = {} ){ - announce( "ORMPreUpdate", { entity : arguments.entity, oldData : arguments.oldData } ); + announce( "ORMPreUpdate", { "entity" : arguments.entity, "oldData" : arguments.oldData } ); } /** * postUpdate called by hibernate which in turn announces a coldbox interception: ORMPostUpdate */ public void function postUpdate( any entity ){ - announce( "ORMPostUpdate", { entity : arguments.entity } ); + announce( "ORMPostUpdate", { "entity" : arguments.entity } ); } /** * preInsert called by hibernate which in turn announces a coldbox interception: ORMPreInsert */ public void function preInsert( any entity ){ - announce( "ORMPreInsert", { entity : arguments.entity } ); + announce( "ORMPreInsert", { "entity" : arguments.entity } ); } /** * postInsert called by hibernate which in turn announces a coldbox interception: ORMPostInsert */ public void function postInsert( any entity ){ - announce( "ORMPostInsert", { entity : arguments.entity } ); + announce( "ORMPostInsert", { "entity" : arguments.entity } ); } /** * preSave called by ColdBox Base service before save() calls */ public void function preSave( any entity ){ - announce( "ORMPreSave", { entity : arguments.entity } ); + announce( "ORMPreSave", { "entity" : arguments.entity } ); } /** * postSave called by ColdBox Base service after transaction commit or rollback via the save() method */ public void function postSave( any entity ){ - announce( "ORMPostSave", { entity : arguments.entity } ); + announce( "ORMPostSave", { "entity" : arguments.entity } ); } /** * Called before the session is flushed. */ public void function preFlush( any entities ){ - announce( "ORMPreFlush", { entities : arguments.entities } ); + announce( "ORMPreFlush", { "entities" : arguments.entities } ); } /** * Called after the session is flushed. */ public void function postFlush( any entities ){ - announce( "ORMPostFlush", { entities : arguments.entities } ); + announce( "ORMPostFlush", { "entities" : arguments.entities } ); } /** * postNew called by ColdBox which in turn announces a coldbox interception: ORMPostNew */ public void function postNew( any entity, any entityName ){ - var args = { entity : arguments.entity, entityName : "" }; + var args = { "entity" : arguments.entity, "entityName" : "" }; // Do we have an incoming name if ( !isNull( arguments.entityName ) && len( arguments.entityName ) ) { @@ -176,4 +166,16 @@ component extends="coldbox.system.remote.ColdboxProxy" implements="CFIDE.orm.IEv return arguments.entity; } + /** + * Lazy loading of the ORM utility according to the CFML engine you are on + * + * @return cborm.models.util.IORMUtil + */ + private function getOrm(){ + if ( isNull( variables.orm ) ) { + variables.orm = new cborm.models.util.ORMUtilFactory().getORMUtil(); + } + return variables.orm; + } + } diff --git a/models/util/support/ORMUtilSupport.cfc b/models/util/support/ORMUtilSupport.cfc index 38703d0..ed96bd9 100644 --- a/models/util/support/ORMUtilSupport.cfc +++ b/models/util/support/ORMUtilSupport.cfc @@ -186,4 +186,29 @@ component singleton { .getEntityMode(); } + /** + * Returns the entity name from a given entity object via session lookup or if new object via metadata lookup + * + * @entity The entity to get it's name from + * + * @return The entity name + */ + function getEntityGivenName( required entity ){ + // Short-cut discovery via ActiveEntity + if ( structKeyExists( arguments.entity, "getEntityName" ) ) { + return arguments.entity.getEntityName(); + } + + // Hibernate Discovery + try { + var entityName = getSession( getEntityDatasource( arguments.entity ) ).getEntityName( arguments.entity ); + } catch ( org.hibernate.TransientObjectException e ) { + // ignore it, it is not in session, go for long-discovery + } + + // Long Discovery + var md = getMetadata( arguments.entity ); + return ( md.keyExists( "entityName" ) ? md.entityName : listLast( md.name, "." ) ); + } + } From c53ae774f20433bcbd5a531f4010c5383471eff6 Mon Sep 17 00:00:00 2001 From: lmajano Date: Tue, 19 Nov 2024 10:48:51 +0000 Subject: [PATCH 10/17] Apply cfformat changes --- models/EventHandler.cfc | 13 +++++++++++-- models/util/support/ORMUtilSupport.cfc | 4 +++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/models/EventHandler.cfc b/models/EventHandler.cfc index 3724452..06a31fe 100644 --- a/models/EventHandler.cfc +++ b/models/EventHandler.cfc @@ -24,7 +24,10 @@ component extends="coldbox.system.remote.ColdboxProxy" implements="CFIDE.orm.IEv * postLoad called by hibernate which in turn announces a coldbox interception: ORMPostLoad */ public void function postLoad( any entity ){ - var args = { "entity" : arguments.entity, "entityName" : getOrm().getEntityGivenName( arguments.entity ) }; + var args = { + "entity" : arguments.entity, + "entityName" : getOrm().getEntityGivenName( arguments.entity ) + }; processEntityInjection( args.entityName, args.entity ); announce( "ORMPostLoad", args ); } @@ -47,7 +50,13 @@ component extends="coldbox.system.remote.ColdboxProxy" implements="CFIDE.orm.IEv * preUpdate called by hibernate which in turn announces a coldbox interception: ORMPreUpdate */ public void function preUpdate( any entity, Struct oldData = {} ){ - announce( "ORMPreUpdate", { "entity" : arguments.entity, "oldData" : arguments.oldData } ); + announce( + "ORMPreUpdate", + { + "entity" : arguments.entity, + "oldData" : arguments.oldData + } + ); } /** diff --git a/models/util/support/ORMUtilSupport.cfc b/models/util/support/ORMUtilSupport.cfc index ed96bd9..4288e49 100644 --- a/models/util/support/ORMUtilSupport.cfc +++ b/models/util/support/ORMUtilSupport.cfc @@ -201,7 +201,9 @@ component singleton { // Hibernate Discovery try { - var entityName = getSession( getEntityDatasource( arguments.entity ) ).getEntityName( arguments.entity ); + var entityName = getSession( getEntityDatasource( arguments.entity ) ).getEntityName( + arguments.entity + ); } catch ( org.hibernate.TransientObjectException e ) { // ignore it, it is not in session, go for long-discovery } From bc640a107879e74db8db737054a7cf14ce07fa5d Mon Sep 17 00:00:00 2001 From: Oscar Tisnado <68830577+otisnado@users.noreply.github.com> Date: Thu, 5 Dec 2024 11:41:26 -0600 Subject: [PATCH 11/17] add boxlang to matrix --- .github/workflows/tests.yml | 3 +++ server-boxlang@1.json | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 server-boxlang@1.json diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d0750e1..7d43f34 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -34,6 +34,9 @@ jobs: - coldboxVersion: "be" cfengine: "adobe@2021" experimental: true + - coldboxVersion: "be" + cfengine: "boxlang@1" + experimental: true steps: - name: Checkout Repository uses: actions/checkout@v4 diff --git a/server-boxlang@1.json b/server-boxlang@1.json new file mode 100644 index 0000000..afa9e4f --- /dev/null +++ b/server-boxlang@1.json @@ -0,0 +1,36 @@ +{ + "app":{ + "cfengine":"boxlang@be", + "serverHomeDirectory":".engine/boxlang" + }, + "name":"cbsecurity-boxlang@1", + "force":true, + "openBrowser":false, + "web":{ + "directoryBrowsing":true, + "http":{ + "port":"60299" + }, + "rewrites":{ + "enable":"true" + }, + "webroot":"test-harness", + "aliases":{ + "/moduleroot/cbsecurity":"./" + } + }, + "JVM":{ + "heapSize":"1024", + "javaVersion":"openjdk21_jdk", + "args":"-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=9999" + }, + "cfconfig":{ + "file":".cfconfig.json" + }, + "env":{ + "BOXLANG_DEBUG":true + }, + "scripts":{ + "onServerInitialInstall":"install bx-mail,bx-mysql,bx-derby,bx-compat-cfml@be,bx-unsafe-evaluate,bx-esapi --noSave" + } +} From 9274a7a7668f0fc0cc9d1b0da0898ea9557e6002 Mon Sep 17 00:00:00 2001 From: Oscar Tisnado <68830577+otisnado@users.noreply.github.com> Date: Thu, 5 Dec 2024 13:35:24 -0600 Subject: [PATCH 12/17] update misspelled module name --- server-boxlang@1.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server-boxlang@1.json b/server-boxlang@1.json index afa9e4f..c585865 100644 --- a/server-boxlang@1.json +++ b/server-boxlang@1.json @@ -3,7 +3,7 @@ "cfengine":"boxlang@be", "serverHomeDirectory":".engine/boxlang" }, - "name":"cbsecurity-boxlang@1", + "name":"cborm-boxlang@1", "force":true, "openBrowser":false, "web":{ @@ -16,7 +16,7 @@ }, "webroot":"test-harness", "aliases":{ - "/moduleroot/cbsecurity":"./" + "/moduleroot/cborm":"./" } }, "JVM":{ From 20d66015cf3bf4fb53c6216af3b7859c1fe480e4 Mon Sep 17 00:00:00 2001 From: Oscar Tisnado <68830577+otisnado@users.noreply.github.com> Date: Mon, 3 Feb 2025 22:21:37 -0600 Subject: [PATCH 13/17] ci: enable workflow dispatch for triggering boxlang tests and reinstall commandbox-boxlang --- .github/workflows/snapshot.yml | 1 + .github/workflows/tests.yml | 5 +++++ server-boxlang@1.json | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index 63aca2e..93b278d 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -4,6 +4,7 @@ on: push: branches: - 'development' + workflow_dispatch: jobs: ########################################################################################## diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7d43f34..a13f450 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -71,6 +71,11 @@ jobs: - name: Setup CommandBox CLI uses: Ortus-Solutions/setup-commandbox@v2.0.1 + - name: Update Commandbox Boxlang Module + if: ${{ matrix.cfengine == 'boxlang@1' }} + run: + box install --force commandbox-boxlang + - name: Install Dependencies run: | box install diff --git a/server-boxlang@1.json b/server-boxlang@1.json index c585865..7bd8b44 100644 --- a/server-boxlang@1.json +++ b/server-boxlang@1.json @@ -22,7 +22,7 @@ "JVM":{ "heapSize":"1024", "javaVersion":"openjdk21_jdk", - "args":"-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=9999" + "args":"-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=9999 -Dboxlang.debugMode=true" }, "cfconfig":{ "file":".cfconfig.json" From babf09bf608f5f5addf04f886b60e68e818b8ca7 Mon Sep 17 00:00:00 2001 From: Oscar Tisnado <68830577+otisnado@users.noreply.github.com> Date: Tue, 4 Feb 2025 22:46:52 -0600 Subject: [PATCH 14/17] ci: use ubuntu-24.04 runner --- .github/workflows/pr.yml | 2 +- .github/workflows/release.yml | 4 ++-- .github/workflows/snapshot.yml | 2 +- .github/workflows/tests.yml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index a48c550..355726a 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -19,7 +19,7 @@ jobs: formatCheck: name: Checks Source Code Formatting - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 steps: - name: Checkout Repository uses: actions/checkout@v4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 883457c..c9bd85a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,7 +26,7 @@ jobs: ########################################################################################## build: name: Build & Publish - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 steps: - name: Checkout Repository uses: actions/checkout@v4 @@ -133,7 +133,7 @@ jobs: prep_next_release: name: Prep Next Release if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 needs: [ build ] steps: # Checkout development diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index 93b278d..4855d83 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -19,7 +19,7 @@ jobs: ########################################################################################## format: name: Code Auto-Formatting - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a13f450..1ff257c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,7 +10,7 @@ on: jobs: tests: name: Tests - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 env: DB_USER: root DB_PASSWORD: root From ec79453075018a2d9ac0bf9132210bd9ce1d828a Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Wed, 19 Feb 2025 16:04:37 +0100 Subject: [PATCH 15/17] lots of githubactions updates and boxlang testing --- .github/workflows/pr.yml | 5 +-- .github/workflows/release.yml | 40 +++++++++++++++++-- .github/workflows/snapshot.yml | 16 +++++++- .github/workflows/tests.yml | 28 ++++++------- box.json | 7 ++-- changelog.md | 2 + server-adobe@2018.json | 26 ------------ ...xlang@1.json => server-boxlang-cfml@1.json | 6 +-- 8 files changed, 74 insertions(+), 56 deletions(-) delete mode 100644 server-adobe@2018.json rename server-boxlang@1.json => server-boxlang-cfml@1.json (76%) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 355726a..b0bf721 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -6,10 +6,8 @@ on: - "main" - "master" - "development" - - "releases/v*" pull_request: branches: - - "releases/v*" - development jobs: @@ -17,7 +15,8 @@ jobs: uses: ./.github/workflows/tests.yml secrets: inherit - formatCheck: + # Format PR + format_check: name: Checks Source Code Formatting runs-on: ubuntu-24.04 steps: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c9bd85a..c9069d6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,9 +16,13 @@ on: default: false type: boolean + # Manual Trigger + workflow_dispatch: env: - MODULE_ID: cborm + MODULE_ID: ${{ github.event.repository.name }} + JDK: 21 SNAPSHOT: ${{ inputs.snapshot || false }} + BUILD_ID: ${{ github.run_number }} jobs: ########################################################################################## @@ -27,6 +31,11 @@ jobs: build: name: Build & Publish runs-on: ubuntu-24.04 + permissions: + checks: write + pull-requests: write + contents: write + issues: write steps: - name: Checkout Repository uses: actions/checkout@v4 @@ -36,6 +45,12 @@ jobs: with: forgeboxAPIKey: ${{ secrets.FORGEBOX_TOKEN }} + - name: Setup Java + uses: actions/setup-java@v4 + with: + distribution: "temurin" + java-version: ${{ env.JDK }} + - name: "Setup Environment Variables For Build Process" id: current_version run: | @@ -50,7 +65,7 @@ jobs: fi - name: Update changelog [unreleased] with latest version - uses: thomaseizinger/keep-a-changelog-new-release@3.0.0 + uses: thomaseizinger/keep-a-changelog-new-release@3.1.0 if: env.SNAPSHOT == 'false' with: changelogPath: ./changelog.md @@ -61,9 +76,9 @@ jobs: npm install -g markdownlint-cli markdownlint changelog.md --fix box install commandbox-docbox - box task run taskfile=build/Build target=run :version=${{ env.VERSION }} :projectName=${{ env.MODULE_ID }} :buildID=${{ github.run_number }} :branch=${{ env.BRANCH }} + box task run taskfile=build/Build target=run :version=${{ env.VERSION }} :projectName=${{ env.MODULE_ID }} :buildID=${{ env.BUILD_ID }} :branch=${{ env.BRANCH }} - - name: Commit Changelog To Master + - name: Commit Changelog [unreleased] with latest version uses: EndBug/add-and-commit@v9.1.4 if: env.SNAPSHOT == 'false' with: @@ -127,6 +142,18 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} ref: refs/tags/v${{ env.VERSION }} + - name: Inform Slack + if: ${{ always() }} + uses: rtCamp/action-slack-notify@v2 + env: + SLACK_CHANNEL: coding + SLACK_COLOR: ${{ job.status }} # or a specific color like 'green' or '#ff00ff' + SLACK_ICON_EMOJI: ":bell:" + SLACK_MESSAGE: "Module ${{ env.MODULE_ID }} v${{ env.VERSION }} Built with ${{ job.status }}!" + SLACK_TITLE: "ColdBox Module ${{ env.MODULE_ID }}" + SLACK_USERNAME: CI + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} + ########################################################################################## # Prep Next Release ########################################################################################## @@ -135,6 +162,11 @@ jobs: if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' runs-on: ubuntu-24.04 needs: [ build ] + permissions: + checks: write + pull-requests: write + contents: write + issues: write steps: # Checkout development - name: Checkout Repository diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index 4855d83..50c8392 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -4,8 +4,14 @@ on: push: branches: - 'development' + workflow_dispatch: +# Unique group name per workflow-branch/tag combo +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: ########################################################################################## # Module Tests @@ -20,6 +26,9 @@ jobs: format: name: Code Auto-Formatting runs-on: ubuntu-24.04 + permissions: + contents: write + checks: write steps: - uses: actions/checkout@v4 @@ -29,7 +38,7 @@ jobs: cmd: run-script format - name: Commit Format Changes - uses: stefanzweifel/git-auto-commit-action@v4 + uses: stefanzweifel/git-auto-commit-action@v5 with: commit_message: Apply cfformat changes @@ -40,5 +49,10 @@ jobs: uses: ./.github/workflows/release.yml needs: [ tests, format ] secrets: inherit + permissions: + checks: write + pull-requests: write + contents: write + issues: write with: snapshot: true diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1ff257c..bc94ed1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -18,9 +18,10 @@ jobs: strategy: fail-fast: false matrix: - cfengine: [ "lucee@5", "adobe@2018", "adobe@2021", "adobe@2023" ] - coldboxVersion: [ "^6.0.0", "^7.0.0" ] + cfengine: [ "lucee@5", "lucee@6", "adobe@2021", "adobe@2023" ] + coldboxVersion: [ "^7.0.0" ] experimental: [ false ] + # Experimental: ColdBox BE vs All Engines include: - coldboxVersion: "be" cfengine: "lucee@5" @@ -29,13 +30,13 @@ jobs: cfengine: "lucee@6" experimental: true - coldboxVersion: "be" - cfengine: "adobe@2023" + cfengine: "adobe@2021" experimental: true - coldboxVersion: "be" - cfengine: "adobe@2021" + cfengine: "adobe@2023" experimental: true - coldboxVersion: "be" - cfengine: "boxlang@1" + cfengine: "boxlang-cfml@1" experimental: true steps: - name: Checkout Repository @@ -45,15 +46,15 @@ jobs: uses: actions/setup-java@v4 with: distribution: "temurin" - java-version: "11" + java-version: "21" - name: Setup Database and Fixtures run: | - sudo systemctl start mysql.service - # Create Database - mysql -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }} -e 'CREATE DATABASE coolblog;' - # Import Database - mysql -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }} < test-harness/tests/resources/coolblog.sql + sudo systemctl start mysql.service + # Create Database + mysql -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }} -e 'CREATE DATABASE coolblog;' + # Import Database + mysql -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }} < test-harness/tests/resources/coolblog.sql - name: Setup Environment For Testing Process run: | @@ -71,11 +72,6 @@ jobs: - name: Setup CommandBox CLI uses: Ortus-Solutions/setup-commandbox@v2.0.1 - - name: Update Commandbox Boxlang Module - if: ${{ matrix.cfengine == 'boxlang@1' }} - run: - box install --force commandbox-boxlang - - name: Install Dependencies run: | box install diff --git a/box.json b/box.json index 001cb44..7832e9c 100644 --- a/box.json +++ b/box.json @@ -32,6 +32,7 @@ "cbpaginator":"^2.0.0" }, "devDependencies":{ + "commandbox-boxlang":"*", "commandbox-cfformat":"*", "commandbox-docbox":"*", "commandbox-dotenv":"*", @@ -54,16 +55,16 @@ "format:check":"cfformat check aop,dsl,interceptors,models,test-harness/tests/,ModuleConfig.cfc ./.cfformat.json", "install:dependencies":"install && cd test-harness && install", "startdbs":"!docker-compose -f docker-compose.yml up", + "start:boxlang":"server start serverConfigFile=server-boxlang-cfml@1.json", "start:lucee":"server start serverConfigFile=server-lucee@5.json", - "start:2018":"server start serverConfigFile=server-adobe@2018.json", "start:2021":"server start serverConfigFile=server-adobe@2021.json", "start:2023":"server start serverConfigFile=server-adobe@2023.json", + "stop:boxlang":"server stop serverConfigFile=server-boxlang-cfml@1.json", "stop:lucee":"server stop serverConfigFile=server-lucee@5.json", - "stop:2018":"server stop serverConfigFile=server-adobe@2018.json", "stop:2021":"server stop serverConfigFile=server-adobe@2021.json", "stop:2023":"server stop serverConfigFile=server-adobe@2023.json", + "logs:boxlang":"server log serverConfigFile=server-boxlang-cfml@1.json --follow", "logs:lucee":"server log serverConfigFile=server-lucee@5.json --follow", - "logs:2018":"server log serverConfigFile=server-adobe@2018.json --follow", "logs:2021":"server log serverConfigFile=server-adobe@2021.json --follow", "logs:2023":"server log serverConfigFile=server-adobe@2023.json --follow" }, diff --git a/changelog.md b/changelog.md index 1bcf946..8434d15 100644 --- a/changelog.md +++ b/changelog.md @@ -10,9 +10,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - [CBORM-37](https://ortussolutions.atlassian.net/browse/CBORM-37) - Fixed issue on `PostLoad` event handler for multi-datasource entities +- Removal of old deprecated engines ### Added +- BoxLang auto-testing - Added several flow helpers to `ActiveEntity`: - `peek( closure )` to allow for peeking into the building process. Pass in your closure that receives the entity and interact with it. - `when( boolean, successClosure, failureClosure )` that you can use to build functional entities without the use of if statements. diff --git a/server-adobe@2018.json b/server-adobe@2018.json deleted file mode 100644 index e9a3901..0000000 --- a/server-adobe@2018.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name":"cborm-adobe@2018", - "app":{ - "serverHomeDirectory":".engine/adobe2018", - "cfengine":"adobe@2018" - }, - "web":{ - "http":{ - "port":"60299" - }, - "rewrites":{ - "enable":"true" - }, - "webroot":"test-harness", - "aliases":{ - "/moduleroot/cborm":"./" - } - }, - "jvm":{ - "heapSize":"1024" - }, - "openBrowser":"false", - "cfconfig":{ - "file":".cfconfig.json" - } -} diff --git a/server-boxlang@1.json b/server-boxlang-cfml@1.json similarity index 76% rename from server-boxlang@1.json rename to server-boxlang-cfml@1.json index 7bd8b44..8931e4b 100644 --- a/server-boxlang@1.json +++ b/server-boxlang-cfml@1.json @@ -21,8 +21,8 @@ }, "JVM":{ "heapSize":"1024", - "javaVersion":"openjdk21_jdk", - "args":"-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=9999 -Dboxlang.debugMode=true" + "javaVersion":"openjdk21_jre", + "args":"-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8888 -Dboxlang.debugMode=true" }, "cfconfig":{ "file":".cfconfig.json" @@ -31,6 +31,6 @@ "BOXLANG_DEBUG":true }, "scripts":{ - "onServerInitialInstall":"install bx-mail,bx-mysql,bx-derby,bx-compat-cfml@be,bx-unsafe-evaluate,bx-esapi --noSave" + "onServerInitialInstall":"install bx-mysql,bx-derby,bx-compat-cfml,bx-orm --noSave" } } From 47dc7c85bdc52ae8035f9e3ec2631a48b052ee97 Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Wed, 19 Feb 2025 16:15:16 +0100 Subject: [PATCH 16/17] lucee 6 regression --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index bc94ed1..29b6459 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -18,7 +18,7 @@ jobs: strategy: fail-fast: false matrix: - cfengine: [ "lucee@5", "lucee@6", "adobe@2021", "adobe@2023" ] + cfengine: [ "lucee@5", "adobe@2021", "adobe@2023" ] coldboxVersion: [ "^7.0.0" ] experimental: [ false ] # Experimental: ColdBox BE vs All Engines From c1a26207d973ed26d2217149bd538da7e292f148 Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Wed, 19 Feb 2025 16:18:40 +0100 Subject: [PATCH 17/17] daily cron jobs --- .github/workflows/cron.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .github/workflows/cron.yml diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml new file mode 100644 index 0000000..b47207b --- /dev/null +++ b/.github/workflows/cron.yml @@ -0,0 +1,10 @@ +name: Daily Tests + +on: + schedule: + - cron: '0 0 * * *' # Runs at 00:00 UTC every day + +jobs: + tests: + uses: ./.github/workflows/tests.yml + secrets: inherit