Skip to content

Commit

Permalink
Merge pull request #3 from lucee/version-query-compile
Browse files Browse the repository at this point in the history
Add support for Lucee Version query & compile
  • Loading branch information
zspitzer authored Aug 6, 2023
2 parents 5cf1c4e + 71e2dcc commit e52c6c5
Show file tree
Hide file tree
Showing 9 changed files with 216 additions and 51 deletions.
27 changes: 17 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the action will run.
on:
push:
pull_request:
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

steps:
Expand All @@ -33,11 +27,24 @@ jobs:
- name: Run default
run: ant

- name: Run Latest Lucee 6 (via version query)
run: ant -DluceeVersionQuery="6/all/jar" -Dexecute="/debug.cfm"

- name: Run Lucee 6
run: ant -DluceeVersion="6.0.0.492-SNAPSHOT" -Dexecute="/debug.cfm"
run: ant -DluceeVersion="6.0.0.523-SNAPSHOT" -Dexecute="/debug.cfm"

- name: Run Lucee 6 (using Lucee light, no extensions)
run: ant -DluceeVersion="light-6.0.0.492-SNAPSHOT" -Dexecute="/debug.cfm"
- name: Run Lucee 5 (using Lucee light, no extensions)
run: ant -DluceeVersion="light-5.4.2.17" -Dexecute="/debug.cfm"

- name: Run Lucee 6 (using Lucee zero, no extensions, no admin, no docs)
run: ant -DluceeVersion="zero-6.0.0.492-SNAPSHOT" -Dexecute="/debug.cfm"
run: ant -DluceeVersion="zero-6.0.0.523-SNAPSHOT" -Dexecute="/debug.cfm"

- name: Run Latest Lucee 5 RC Light
run: ant -DluceeVersionQuery="5/rc/light" -Dexecute="/debug.cfm"

- name: Run Latest Stable Lucee 5, compile webroot
run: ant -DluceeVersionQuery="5/stable/jar" -Dexecute="/index.cfm" -Dcompile="true"

- name: Run Latest Stable Lucee 5, compile webroot (invalid code)
continue-on-error: true
run: ant -DluceeVersionQuery="5/stable/jar" -Dexecute="/index.cfm" -Dcompile="true" -Dwebroot="${{ github.workspace }}/sampleBad/"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
lucee-download-cache
temp
bin
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ Default `ant` will run the `sample/index.cfm` file

You can specify:

- Lucee version `-DluceeVersion=` (default `5.3.8.206` )
- Lucee version `-DluceeVersion=` (default `5.4.2.17` )
- Lucee version by query `-DluceeVersionQuery="5.4/stable/light`
- Webroot `-Dwebroot=` (default `tests/`)
- CFML Script to run, `-Dexecute=` (default `index.cfm`)
- CFML Script to run, `-Dexecute=` (default `/index.cfm`)
- run script via include or _internalRequest (which runs the Application.cfc if present, default ) `-DexecuteScriptByInclude="true"`
- any extra extensions `-Dextensions=` (default ``)
- manual extension install (`*.lex`) from a directory `-DextensionDir=` (default ``)
- compile all cfml under webroot `-Dcompile="true"`

`ant -DluceeVersion="6.0.0.95-SNAPSHOT" -Dwebroot="C:\work\lucee-docs" -Dexecute="import.cfm" -Dlucee.extensions=""`

Expand All @@ -41,13 +43,27 @@ To use as a GitHub Action, to run the PDF tests after building the PDF Extension
with:
repository: lucee/lucee
path: lucee
- 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
- name: Run Lucee Test Suite
uses: lucee/script-runner@main
with:
webroot: ${{ github.workspace }}/lucee/test
execute: /bootstrap-tests.cfm
luceeVersion: ${{ env.luceeVersion }}
luceeVersionQuery: 5.4/stable/light (optional, overrides luceeVersion)
extensions: (optional list of extension guids to install)
extensionDir: ${{ github.workspace }}/dist
antFlags: -d or -v etc (optional, good for debugging any ant issues)
compile: true (optional, compiles all the cfml under the webroot)
env:
testLabels: pdf
testAdditional: ${{ github.workspace }}/tests
Expand Down
47 changes: 42 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ name: 'Lucee Script Runner'
description: 'Run Lucee via the command line'
inputs:
luceeVersion:
description: Lucee Version to run
description: Lucee Version to run, i.e. "light-5.4.2.17"
required: true
luceeVersionQuery:
description: Lucee Version Query to run (overrides luceeVersion, i.e. "5.4/table/light" )
default: ""
webroot:
description: cfml webroot
required: true
Expand All @@ -12,19 +15,53 @@ inputs:
required: true
extensions:
description: any additional extensions to install
required: true
default: ""
extensionDir:
description: a directory containing any Lucee *.lex extentions to manually install
required: true
default: ""
compile:
description: compile the cfml code under the webroot
default: "false"
antFlags:
description: additional flags to pass to ant
default: ""
runs:
using: "composite"
steps:
- run: |
- 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: ${{ github.action_path }}/lucee-download-cache
key: lucee-downloads
restore-keys: lucee-downloads
- if: runner.os != 'Windows'
run: |
pwd
echo luceeVersion ${{ inputs.luceeVersion }}
echo luceeVersionQuery ${{ inputs.luceeVersionQuery }}
echo webroot ${{ inputs.webroot }}
echo execute ${{ inputs.execute }}
echo extensions ${{ inputs.extensions }}
echo extensionDir ${{ inputs.extensionDir }}
ant -buildfile "${{ github.action_path }}/build.xml" -DluceeVersion="${{ inputs.luceeVersion }}" -Dwebroot="${{ inputs.webroot }}" -Dexecute="${{ inputs.execute }}" -Dextensions="${{ inputs.extensions }}" -DextensionDir="${{ inputs.extensionDir }}"
echo compile ${{ inputs.compile }}
ant -buildfile "${{ github.action_path }}/build.xml" ${{ inputs.antFlags }} -DluceeVersion="${{ inputs.luceeVersion }}" -DluceeVersionQuery="${{ inputs.luceeVersionQuery }}" \
-Dwebroot="${{ inputs.webroot }}" -Dexecute="${{ inputs.execute }}" \
-Dextensions="${{ inputs.extensions }}" -DextensionDir="${{ inputs.extensionDir }}" -Dcompile="${{ inputs.compile }}"
shell: bash
- if: runner.os == 'Windows'
run: |
pwd
echo luceeVersion ${{ inputs.luceeVersion }}
echo luceeVersionQuery ${{ inputs.luceeVersionQuery }}
echo webroot ${{ inputs.webroot }}
echo execute ${{ inputs.execute }}
echo extensions ${{ inputs.extensions }}
echo extensionDir ${{ inputs.extensionDir }}
echo compile ${{ inputs.compile }}
ant -buildfile "${{ github.action_path }}/build.xml" ${{ inputs.antFlags }} -DluceeVersion="${{ inputs.luceeVersion }}" -DluceeVersionQuery="${{ inputs.luceeVersionQuery }}" -Dwebroot="${{ inputs.webroot }}" -Dexecute="${{ inputs.execute }}" -Dextensions="${{ inputs.extensions }}" -DextensionDir="${{ inputs.extensionDir }}" -Dcompile="${{ inputs.compile }}"
shell: cmd
94 changes: 76 additions & 18 deletions build-run-cfml.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,22 @@
param name="extensionDir" default="";
if ( len( extensionDir) ){
systemOutput( "-------------- Extensions --------------", true );
deployExtensions = DirectoryList( path=extensionDir, filter="*.lex" );
loop array="#deployExtensions#" item="lexFile" {
SystemOutput("Manually installing extension [#lexFile#]", true);
FileCopy( lexFile, getTempDirectory() ); // make a copy, so lucee doesn't delete it after installing
admin
action="updateRHExtension"
type="server"
password="#request.adminPassword#"
source="#getTempDirectory()##ListLast( lexFile, "\/")#";
function reportExtensions() localmode=true {
systemOutput( "-------------- Extensions --------------", true );
deployExtensions = DirectoryList( path=extensionDir, filter="*.lex" );
loop array="#deployExtensions#" item="lexFile" {
SystemOutput("Manually installing extension [#lexFile#]", true);
FileCopy( lexFile, getTempDirectory() ); // make a copy, so lucee doesn't delete it after installing
admin
action="updateRHExtension"
type="server"
password="#request.adminPassword#"
source="#getTempDirectory()##ListLast( lexFile, "\/")#";
}
if ( ArrayLen( deployExtensions ) eq 0)
SystemOutput( "No *.lex extension files found in directory [#extensionDir#], directory exists: [#DirectoryExists(extensionDir)#]", true );
}
if ( ArrayLen( deployExtensions ) eq 0)
SystemOutput( "No *.lex extension files found in directory [#extensionDir#], directory exists: [#DirectoryExists(extensionDir)#]", true );
reportExtensions();
}
Expand All @@ -97,16 +100,71 @@
param name="executeScriptByInclude" default="false";
function parseAntParams (str) localmode=true {
loopGuard=0;
pos = findNoCase(" -D", str);
params = {};
do {
vStart = findNoCase('"', str, pos+1 );
if (vStart gt 0){
name = mid(str, pos+3, (vStart-pos-4));
vEnd = findNoCase('"', str, vStart+1);
if (vEnd gt 0){
val = mid(str, vStart+1, vEnd-vStart-1);
pos = vEnd+1;
params[ name ]=val;
}
} else {
pos = 0; // bail
}
if (pos gt 0) {
pos = findNoCase(" -D", str, pos );
loopGuard++;
}
if (loopGuard gt 100)
throw "Error Loop protection @ #loopGuard#";
} while ( pos > 0);
return params;
}
function loadPassedVariables() localmode=true {
var params = parseAntParams( server.system.environment.ANT_CMD_LINE_ARGS?: "" );
StructAppend(params, variables);
var passedVariables = {};
loop collection=#params# key="key" value="value" {
if ( isSimpleValue( value ) )
passedVariables[ key ] = value;
}
if ( structcount( passedVariables ) ) {
systemOutput( "", true );
systemOutput( "Variables", true);
loop collection=passedVariables key="_k" value="_v" {
systemOutput( chr(9) & _k & ": " & _v , true);
}
systemOutput( "", true );
}
return passedVariables;
}
passedVariables = loadPassedVariables();
if ( compile eq "true" ){
systemOutput( "-------------- Start Compiling Webroot --------------", true );
admin
action="compileMapping"
type="web"
password=#request.adminPassword#
virtual="/"
stoponerror="false";
systemOutput( "-------------- Finished Compiling Webroot --------------", true );
}
try {
if ( executeScriptByInclude eq "true"){
include template="#execute#";
} else {
passedVariables = {};
loop collection=#variables# key="key" value="value" {
if ( isSimpleValue( value ) )
passedVariables[ key ] = value;
}
_internalRequest(
template = execute,
url = passedVariables
Expand Down
48 changes: 35 additions & 13 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,45 +13,65 @@
<property name="extensions" value=""/>
<!-- allow installing extensions from a directory, i.e. extension dist dir -->
<property name="extensionDir" value=""/>
<property name="compile" value=""/>

<!-- scripts can be run as an include, or via internalRequest (default) which picks up any Application.cfc -->
<property name="executeScriptByInclude" value=""/>

<property name="luceeCdnUrl" value="https://cdn.lucee.org"/>
<property name="luceeVersion" value="5.4.0.80"/>
<property name="luceeUpdateProvider" value="https://update.lucee.org/rest/update/provider/latest/"/>
<property name="luceeVersion" value="5.4.2.17"/>
<property name="luceeVersionQuery" value=""/> <!-- i.e. 5.4/stable/jar -->

<!--<target name="core" depends="setEnv,check-lucee-jar,check-lucee-lco,download-lucee-jar,download-lucee-lco,run-cfml">-->
<target name="core" depends="setEnv,check-lucee-jar,download-lucee-jar,run-cfml">
<target name="core" depends="setEnv,use-version,query-version,check-lucee-jar,download-lucee-jar,run-cfml">
</target>

<target name="setEnv">
<artifact:pom id="pom" file="pom.xml"/>
<artifact:dependencies filesetId="mydeps" pomRefId="pom" />
<pathconvert property="dependencies" refid="mydeps"/>
<property name="runtime_classpath" value="${java.class.path}:${dependencies}"/>
<echo message="${luceeVersionQuery}"/>
<condition property="no-query-version">
<length string="${luceeVersionQuery}" trim="true" length="0"/>
</condition>
</target>

<target name="check-lucee-jar">
<available file="${cache}/lucee-${luceeVersion}.jar" property="lucee.jar.present"/>
<target name="use-version" if="no-query-version">
<property name="useLuceeVersion" value="${luceeVersion}"/>
<property name="luceeVersionUrl" value="${luceeCdnUrl}/lucee-${useLuceeVersion}.jar"/>
<property name="luceeFilename" value="lucee-${useLuceeVersion}.jar"/>
</target>

<target name="check-lucee-lco">
<available file="${cache}/${luceeVersion}.lco" property="lucee.lco.present"/>
<target name="query-version" unless="no-query-version">
<echo message="Getting latest Lucee version for ${luceeVersionQuery}" />
<tempfile property="temp.file" suffix=".txt" prefix="lucee-version-query" deleteonexit="true"/>
<get src="${luceeUpdateProvider}${luceeVersionQuery}/filename" dest="${temp.file}" verbose="true"/>
<loadfile property="luceeFilename" srcFile="${temp.file}">
<filterchain>
<tokenfilter>
<replaceregex pattern='"' replace="" flags="g"/>
</tokenfilter>
</filterchain>
</loadfile>
<property name="luceeVersionUrl" value="${luceeCdnUrl}/${luceeFilename}"/>
<property name="useLuceeVersion" value="${luceeFilename}"/>
<echo message="Lucee version: ${useLuceeVersion}" />
</target>

<target name="download-lucee-jar" unless="lucee.jar.present">
<mkdir dir="${cache}"/>
<get src="${luceeCdnUrl}/lucee-${luceeVersion}.jar" dest="${cache}/lucee-${luceeVersion}.jar"/>
<target name="check-lucee-jar">
<available file="${cache}/${luceeFilename}" property="lucee.jar.present"/>
</target>

<target name="download-lucee-lco" unless="lucee.lco.present">
<target name="download-lucee-jar" unless="lucee.jar.present">
<mkdir dir="${cache}"/>
<get src="${luceeCdnUrl}/${luceeVersion}.lco" dest="${cache}/${luceeVersion}.lco"/>
<get src="${luceeVersionUrl}" dest="${cache}/${luceeFilename}" verbose="true"/>
</target>

<target name="run-cfml">
<echo message="Java: ${java.version}, ${java.home}" />
<echo message="Lucee: ${luceeVersion}" />
<echo message="Lucee: ${useLuceeVersion}" />
<echo message="Webroot: ${webroot}" />
<echo message="Execute: ${execute}" />
<echo message="ExtensionDir: ${extensionDir}" />
Expand All @@ -72,7 +92,7 @@

<java classname="org.apache.tools.ant.launch.Launcher" dir="${temp}/lucee" fork="true" failonerror="true" errorproperty="errorOut">
<classpath path="${java.class.path}">
<pathelement location="${cache}/lucee-${luceeVersion}.jar"/>
<pathelement location="${cache}/${luceeFilename}"/>
<pathelement path="${runtime_classpath}"/>
</classpath>
<arg value="-f"/>
Expand All @@ -85,6 +105,8 @@
<jvmarg value="-DextensionDir=${extensionDir}"/>
<jvmarg value="-Dlucee.extensions=${extensions}"/>
<jvmarg value="-Dlucee.mapping.first=true"/>
<jvmarg value="-Dcompile=${compile}"/>

<!--
<jvmarg value="-Xdebug"/>
<jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"/>
Expand Down
Loading

0 comments on commit e52c6c5

Please sign in to comment.