From b93cfb99b61cb8ba44e002dc1d293d07229ea54b Mon Sep 17 00:00:00 2001 From: Zac Spitzer Date: Wed, 14 Dec 2022 10:50:41 +0100 Subject: [PATCH 1/3] add gha build and test --- .github/workflows/main.yml | 71 +++++++++++++++++++++++++++ build/index.cfm | 8 +++ build/task.cfc | 9 +++- test/{suite.cfc => tests/mariaDb.cfc} | 46 ++++++++++++++++- 4 files changed, 130 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/main.yml create mode 100644 build/index.cfm rename test/{suite.cfc => tests/mariaDb.cfc} (77%) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..b12e29c --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,71 @@ +# This workflow will build a Java project with Ant +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-ant + +name: Java CI + +on: [push, pull_request,workflow_dispatch] + +jobs: + build: + + runs-on: ubuntu-latest + env: + luceeVersion: 5.3.9.166 #5.3.10.97 + + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 11 + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'adopt' + - name: Shutdown Ubuntu MySQL (SUDO) + run: sudo service mysql stop + - name: Setup MariaDB + uses: getong/mariadb-action@v1.1 + with: + mysql user: lucee + mysql password: pass + mysql database: tests + env: + INPUT_MYSQL_USER: lucee + INPUT_MYSQL_PASSWORD: pass + INPUT_MYSQL_DATABASE: tests + - name: Cache Maven packages + uses: actions/cache@v3 + with: + path: ~/.m2 + key: lucee-script-runner-maven-cache + - name: Cache Lucee files + uses: actions/cache@v3 + with: + path: _actions/lucee/script-runner/main/lucee-download-cache + key: lucee-downloads-${{ env.luceeVersion }} + restore-keys: | + lucee-downloads + - name: Build with script runner + uses: lucee/script-runner@main + with: + webroot: ${{ github.workspace }}/build + execute: /index.cfm + luceeVersion: ${{ env.luceeVersion }} + - name: Upload Artifact + uses: actions/upload-artifact@v3 + with: + name: mariadb-lex + path: ./*.lex + - name: Checkout Lucee + uses: actions/checkout@v3 + with: + repository: lucee/lucee + path: lucee + - name: Run Lucee Test Suite (testLabels="mariaDb") + uses: lucee/script-runner@main + with: + webroot: ${{ github.workspace }}/lucee/test + execute: /bootstrap-tests.cfm + luceeVersion: ${{ env.luceeVersion }} + extensionDir: ${{ github.workspace }}/ + env: + testLabels: mariaDb + testAdditional: ${{ github.workspace }}/test diff --git a/build/index.cfm b/build/index.cfm new file mode 100644 index 0000000..fff3946 --- /dev/null +++ b/build/index.cfm @@ -0,0 +1,8 @@ + + systemOutput("Building MariaDB extension", true); + task = new Task(); + //new task().run( getDirectoryFromPath( getDirectoryFromPath( getDirectoryFromPath( getCurrentTemplatePath() ) ) ) ); + task.run( expandPath("../" ) ); + + systemOutput("Finished building extension", true); + \ No newline at end of file diff --git a/build/task.cfc b/build/task.cfc index a849444..33d3d85 100644 --- a/build/task.cfc +++ b/build/task.cfc @@ -2,8 +2,13 @@ component{ property name="rootPath"; - void function run(){ - variables.rootPath = fileSystemUtil.resolvePath( "../" ); + void function run(rootPath=""){ + if ( isEmpty( arguments.rootPath ) ) + variables.rootPath = fileSystemUtil.resolvePath( "../" ); + else { + variables.rootPath = arguments.rootPath; + } + systemOutput("Build root path: [#variables.rootPath#]", true); generateLexFile(); } diff --git a/test/suite.cfc b/test/tests/mariaDb.cfc similarity index 77% rename from test/suite.cfc rename to test/tests/mariaDb.cfc index 99c220f..f40a8b0 100644 --- a/test/suite.cfc +++ b/test/tests/mariaDb.cfc @@ -1,4 +1,4 @@ -component extends="testbox.system.BaseSpec"{ +component extends="org.lucee.cfml.test.LuceeTestCase" labels="mariaDb" { private string function getClassName( required object object ){ return GetMetaData( arguments.object ).getCanonicalName() @@ -11,7 +11,26 @@ component extends="testbox.system.BaseSpec"{ } function beforeAll(){ - include "sql/setup.cfm" + variables.database = { + host: server.system.environment.MARIADB_HOST?:"localhost" + ,port: server.system.environment.MARIADB_PORT?:3306 + ,username: server.system.environment.MARIADB_LUCEE_USER?:"lucee" + ,password: server.system.environment.MARIADB_LUCEE_PASSWORD?:"pass" + } + + systemOutput(database, true); + + application action="update" datasource={ + class: "org.mariadb.jdbc.Driver" + ,connectionString: "jdbc:mariadb://#database.host#:#database.port#/tests?allowMultiQueries=true" + ,username: database.username + ,password: database.password + }; + + dbinfo type="Version" name="verify"; + systemOutput(verify, true); + + include "../sql/setup.cfm" insertBlankRow() variables.testValues = { bit: 0 @@ -28,6 +47,7 @@ component extends="testbox.system.BaseSpec"{ function afterAll(){ QueryExecute( "DROP TABLE IF EXISTS `datatypes`" ) + QueryExecute( "DROP TABLE IF EXISTS `testnotes`" ) } function run( testResults, testBox ){ @@ -103,6 +123,28 @@ component extends="testbox.system.BaseSpec"{ expect( getClassName( result.varcharField ) ).toBe( "java.lang.String" ) }) + it( "can add and retrieve a clob value correctly", ()=> { + QueryExecute(" CREATE TABLE `testnotes` ( + `id` INT(11) NOT NULL AUTO_INCREMENT, + `notes` MEDIUMTEXT NOT NULL COLLATE utf16_bin, + PRIMARY KEY (`id`) USING BTREE + ) COLLATE=latin1_swedish_ci ENGINE=InnoDB + "); + + local.notes = ExtensionList().toJson(); + + QueryExecute( + sql="INSERT INTO `testnotes` ( notes ) VALUES ( :notes )", + params={ + notes: { value: notes, type: "clob" } + } + ); + + local.qry = QueryExecute("SELECT notes from `testnotes`"); + + expect( qry.notes ).toBe( notes ); + }) + }) } From 1d81423bbf51b768949b80d812ea8d000c5b93e1 Mon Sep 17 00:00:00 2001 From: Zac Spitzer Date: Mon, 19 Dec 2022 10:37:13 +0100 Subject: [PATCH 2/3] revert test spec extends, switch back to 5.3.10.97 --- .github/workflows/main.yml | 3 ++- test/tests/mariaDb.cfc | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b12e29c..90afcb0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest env: - luceeVersion: 5.3.9.166 #5.3.10.97 + luceeVersion: 5.3.10.97 steps: - uses: actions/checkout@v3 @@ -69,3 +69,4 @@ jobs: env: testLabels: mariaDb testAdditional: ${{ github.workspace }}/test + testSuiteExtend: org.lucee.cfml.test.LuceeTestCase,testbox.system.BaseSpec diff --git a/test/tests/mariaDb.cfc b/test/tests/mariaDb.cfc index f40a8b0..2c205e3 100644 --- a/test/tests/mariaDb.cfc +++ b/test/tests/mariaDb.cfc @@ -1,4 +1,4 @@ -component extends="org.lucee.cfml.test.LuceeTestCase" labels="mariaDb" { +component extends="testbox.system.BaseSpec" labels="mariaDb" { private string function getClassName( required object object ){ return GetMetaData( arguments.object ).getCanonicalName() From 1a8107ced0170fe4325b4ac934a5f67920b06e87 Mon Sep 17 00:00:00 2001 From: Zac Spitzer Date: Mon, 19 Dec 2022 10:39:14 +0100 Subject: [PATCH 3/3] back again --- test/tests/mariaDb.cfc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/tests/mariaDb.cfc b/test/tests/mariaDb.cfc index 2c205e3..f40a8b0 100644 --- a/test/tests/mariaDb.cfc +++ b/test/tests/mariaDb.cfc @@ -1,4 +1,4 @@ -component extends="testbox.system.BaseSpec" labels="mariaDb" { +component extends="org.lucee.cfml.test.LuceeTestCase" labels="mariaDb" { private string function getClassName( required object object ){ return GetMetaData( arguments.object ).getCanonicalName()