diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..90afcb0 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,72 @@ +# 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.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 + testSuiteExtend: org.lucee.cfml.test.LuceeTestCase,testbox.system.BaseSpec 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 ); + }) + }) }