Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add github action to build and test #10

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
72 changes: 72 additions & 0 deletions .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
8 changes: 8 additions & 0 deletions build/index.cfm
@@ -0,0 +1,8 @@
<cfscript>
systemOutput("Building MariaDB extension", true);
task = new Task();
//new task().run( getDirectoryFromPath( getDirectoryFromPath( getDirectoryFromPath( getCurrentTemplatePath() ) ) ) );
task.run( expandPath("../" ) );

systemOutput("Finished building extension", true);
</cfscript>
9 changes: 7 additions & 2 deletions build/task.cfc
Expand Up @@ -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();
}

Expand Down
46 changes: 44 additions & 2 deletions test/suite.cfc → 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()
Expand All @@ -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
Expand All @@ -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 ){
Expand Down Expand Up @@ -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 );
})

})

}
Expand Down