Skip to content

Commit e52c6c5

Browse files
authored
Merge pull request #3 from lucee/version-query-compile
Add support for Lucee Version query & compile
2 parents 5cf1c4e + 71e2dcc commit e52c6c5

9 files changed

Lines changed: 216 additions & 51 deletions

File tree

.github/workflows/main.yml

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
1-
# This is a basic workflow to help you get started with Actions
2-
31
name: CI
42

5-
# Controls when the action will run.
63
on:
74
push:
85
pull_request:
96
workflow_dispatch:
107

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

1812
steps:
@@ -33,11 +27,24 @@ jobs:
3327
- name: Run default
3428
run: ant
3529

30+
- name: Run Latest Lucee 6 (via version query)
31+
run: ant -DluceeVersionQuery="6/all/jar" -Dexecute="/debug.cfm"
32+
3633
- name: Run Lucee 6
37-
run: ant -DluceeVersion="6.0.0.492-SNAPSHOT" -Dexecute="/debug.cfm"
34+
run: ant -DluceeVersion="6.0.0.523-SNAPSHOT" -Dexecute="/debug.cfm"
3835

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

4239
- name: Run Lucee 6 (using Lucee zero, no extensions, no admin, no docs)
43-
run: ant -DluceeVersion="zero-6.0.0.492-SNAPSHOT" -Dexecute="/debug.cfm"
40+
run: ant -DluceeVersion="zero-6.0.0.523-SNAPSHOT" -Dexecute="/debug.cfm"
41+
42+
- name: Run Latest Lucee 5 RC Light
43+
run: ant -DluceeVersionQuery="5/rc/light" -Dexecute="/debug.cfm"
44+
45+
- name: Run Latest Stable Lucee 5, compile webroot
46+
run: ant -DluceeVersionQuery="5/stable/jar" -Dexecute="/index.cfm" -Dcompile="true"
47+
48+
- name: Run Latest Stable Lucee 5, compile webroot (invalid code)
49+
continue-on-error: true
50+
run: ant -DluceeVersionQuery="5/stable/jar" -Dexecute="/index.cfm" -Dcompile="true" -Dwebroot="${{ github.workspace }}/sampleBad/"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
lucee-download-cache
22
temp
3+
bin

README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ Default `ant` will run the `sample/index.cfm` file
1414

1515
You can specify:
1616

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

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

@@ -41,13 +43,27 @@ To use as a GitHub Action, to run the PDF tests after building the PDF Extension
4143
with:
4244
repository: lucee/lucee
4345
path: lucee
46+
- name: Cache Maven packages
47+
uses: actions/cache@v3
48+
with:
49+
path: ~/.m2
50+
key: lucee-script-runner-maven-cache
51+
- name: Cache Lucee files
52+
uses: actions/cache@v3
53+
with:
54+
path: _actions/lucee/script-runner/main/lucee-download-cache
55+
key: lucee-downloads
4456
- name: Run Lucee Test Suite
4557
uses: lucee/script-runner@main
4658
with:
4759
webroot: ${{ github.workspace }}/lucee/test
4860
execute: /bootstrap-tests.cfm
4961
luceeVersion: ${{ env.luceeVersion }}
62+
luceeVersionQuery: 5.4/stable/light (optional, overrides luceeVersion)
63+
extensions: (optional list of extension guids to install)
5064
extensionDir: ${{ github.workspace }}/dist
65+
antFlags: -d or -v etc (optional, good for debugging any ant issues)
66+
compile: true (optional, compiles all the cfml under the webroot)
5167
env:
5268
testLabels: pdf
5369
testAdditional: ${{ github.workspace }}/tests

action.yml

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@ name: 'Lucee Script Runner'
22
description: 'Run Lucee via the command line'
33
inputs:
44
luceeVersion:
5-
description: Lucee Version to run
5+
description: Lucee Version to run, i.e. "light-5.4.2.17"
66
required: true
7+
luceeVersionQuery:
8+
description: Lucee Version Query to run (overrides luceeVersion, i.e. "5.4/table/light" )
9+
default: ""
710
webroot:
811
description: cfml webroot
912
required: true
@@ -12,19 +15,53 @@ inputs:
1215
required: true
1316
extensions:
1417
description: any additional extensions to install
15-
required: true
18+
default: ""
1619
extensionDir:
1720
description: a directory containing any Lucee *.lex extentions to manually install
18-
required: true
21+
default: ""
22+
compile:
23+
description: compile the cfml code under the webroot
24+
default: "false"
25+
antFlags:
26+
description: additional flags to pass to ant
27+
default: ""
1928
runs:
2029
using: "composite"
2130
steps:
22-
- run: |
31+
- name: Cache Maven packages
32+
uses: actions/cache@v3
33+
with:
34+
path: ~/.m2
35+
key: lucee-script-runner-maven-cache
36+
- name: Cache Lucee files
37+
uses: actions/cache@v3
38+
with:
39+
path: ${{ github.action_path }}/lucee-download-cache
40+
key: lucee-downloads
41+
restore-keys: lucee-downloads
42+
- if: runner.os != 'Windows'
43+
run: |
2344
pwd
2445
echo luceeVersion ${{ inputs.luceeVersion }}
46+
echo luceeVersionQuery ${{ inputs.luceeVersionQuery }}
2547
echo webroot ${{ inputs.webroot }}
2648
echo execute ${{ inputs.execute }}
2749
echo extensions ${{ inputs.extensions }}
2850
echo extensionDir ${{ inputs.extensionDir }}
29-
ant -buildfile "${{ github.action_path }}/build.xml" -DluceeVersion="${{ inputs.luceeVersion }}" -Dwebroot="${{ inputs.webroot }}" -Dexecute="${{ inputs.execute }}" -Dextensions="${{ inputs.extensions }}" -DextensionDir="${{ inputs.extensionDir }}"
51+
echo compile ${{ inputs.compile }}
52+
ant -buildfile "${{ github.action_path }}/build.xml" ${{ inputs.antFlags }} -DluceeVersion="${{ inputs.luceeVersion }}" -DluceeVersionQuery="${{ inputs.luceeVersionQuery }}" \
53+
-Dwebroot="${{ inputs.webroot }}" -Dexecute="${{ inputs.execute }}" \
54+
-Dextensions="${{ inputs.extensions }}" -DextensionDir="${{ inputs.extensionDir }}" -Dcompile="${{ inputs.compile }}"
3055
shell: bash
56+
- if: runner.os == 'Windows'
57+
run: |
58+
pwd
59+
echo luceeVersion ${{ inputs.luceeVersion }}
60+
echo luceeVersionQuery ${{ inputs.luceeVersionQuery }}
61+
echo webroot ${{ inputs.webroot }}
62+
echo execute ${{ inputs.execute }}
63+
echo extensions ${{ inputs.extensions }}
64+
echo extensionDir ${{ inputs.extensionDir }}
65+
echo compile ${{ inputs.compile }}
66+
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 }}"
67+
shell: cmd

build-run-cfml.xml

Lines changed: 76 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,22 @@
7474
7575
param name="extensionDir" default="";
7676
if ( len( extensionDir) ){
77-
systemOutput( "-------------- Extensions --------------", true );
78-
deployExtensions = DirectoryList( path=extensionDir, filter="*.lex" );
79-
loop array="#deployExtensions#" item="lexFile" {
80-
SystemOutput("Manually installing extension [#lexFile#]", true);
81-
FileCopy( lexFile, getTempDirectory() ); // make a copy, so lucee doesn't delete it after installing
82-
admin
83-
action="updateRHExtension"
84-
type="server"
85-
password="#request.adminPassword#"
86-
source="#getTempDirectory()##ListLast( lexFile, "\/")#";
77+
function reportExtensions() localmode=true {
78+
systemOutput( "-------------- Extensions --------------", true );
79+
deployExtensions = DirectoryList( path=extensionDir, filter="*.lex" );
80+
loop array="#deployExtensions#" item="lexFile" {
81+
SystemOutput("Manually installing extension [#lexFile#]", true);
82+
FileCopy( lexFile, getTempDirectory() ); // make a copy, so lucee doesn't delete it after installing
83+
admin
84+
action="updateRHExtension"
85+
type="server"
86+
password="#request.adminPassword#"
87+
source="#getTempDirectory()##ListLast( lexFile, "\/")#";
88+
}
89+
if ( ArrayLen( deployExtensions ) eq 0)
90+
SystemOutput( "No *.lex extension files found in directory [#extensionDir#], directory exists: [#DirectoryExists(extensionDir)#]", true );
8791
}
88-
if ( ArrayLen( deployExtensions ) eq 0)
89-
SystemOutput( "No *.lex extension files found in directory [#extensionDir#], directory exists: [#DirectoryExists(extensionDir)#]", true );
92+
reportExtensions();
9093
}
9194
9295
@@ -97,16 +100,71 @@
97100
98101
param name="executeScriptByInclude" default="false";
99102
103+
function parseAntParams (str) localmode=true {
104+
loopGuard=0;
105+
pos = findNoCase(" -D", str);
106+
params = {};
107+
do {
108+
vStart = findNoCase('"', str, pos+1 );
109+
if (vStart gt 0){
110+
name = mid(str, pos+3, (vStart-pos-4));
111+
vEnd = findNoCase('"', str, vStart+1);
112+
if (vEnd gt 0){
113+
val = mid(str, vStart+1, vEnd-vStart-1);
114+
pos = vEnd+1;
115+
params[ name ]=val;
116+
}
117+
} else {
118+
pos = 0; // bail
119+
}
120+
if (pos gt 0) {
121+
pos = findNoCase(" -D", str, pos );
122+
loopGuard++;
123+
}
124+
if (loopGuard gt 100)
125+
throw "Error Loop protection @ #loopGuard#";
126+
} while ( pos > 0);
127+
return params;
128+
}
129+
130+
131+
function loadPassedVariables() localmode=true {
132+
133+
var params = parseAntParams( server.system.environment.ANT_CMD_LINE_ARGS?: "" );
134+
StructAppend(params, variables);
135+
var passedVariables = {};
136+
loop collection=#params# key="key" value="value" {
137+
if ( isSimpleValue( value ) )
138+
passedVariables[ key ] = value;
139+
}
140+
if ( structcount( passedVariables ) ) {
141+
systemOutput( "", true );
142+
systemOutput( "Variables", true);
143+
loop collection=passedVariables key="_k" value="_v" {
144+
systemOutput( chr(9) & _k & ": " & _v , true);
145+
}
146+
systemOutput( "", true );
147+
}
148+
return passedVariables;
149+
}
150+
151+
passedVariables = loadPassedVariables();
152+
153+
if ( compile eq "true" ){
154+
systemOutput( "-------------- Start Compiling Webroot --------------", true );
155+
admin
156+
action="compileMapping"
157+
type="web"
158+
password=#request.adminPassword#
159+
virtual="/"
160+
stoponerror="false";
161+
systemOutput( "-------------- Finished Compiling Webroot --------------", true );
162+
}
163+
100164
try {
101165
if ( executeScriptByInclude eq "true"){
102166
include template="#execute#";
103167
} else {
104-
passedVariables = {};
105-
loop collection=#variables# key="key" value="value" {
106-
if ( isSimpleValue( value ) )
107-
passedVariables[ key ] = value;
108-
}
109-
110168
_internalRequest(
111169
template = execute,
112170
url = passedVariables

build.xml

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,45 +13,65 @@
1313
<property name="extensions" value=""/>
1414
<!-- allow installing extensions from a directory, i.e. extension dist dir -->
1515
<property name="extensionDir" value=""/>
16+
<property name="compile" value=""/>
1617

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

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

2326
<!--<target name="core" depends="setEnv,check-lucee-jar,check-lucee-lco,download-lucee-jar,download-lucee-lco,run-cfml">-->
24-
<target name="core" depends="setEnv,check-lucee-jar,download-lucee-jar,run-cfml">
27+
<target name="core" depends="setEnv,use-version,query-version,check-lucee-jar,download-lucee-jar,run-cfml">
2528
</target>
2629

2730
<target name="setEnv">
2831
<artifact:pom id="pom" file="pom.xml"/>
2932
<artifact:dependencies filesetId="mydeps" pomRefId="pom" />
3033
<pathconvert property="dependencies" refid="mydeps"/>
3134
<property name="runtime_classpath" value="${java.class.path}:${dependencies}"/>
35+
<echo message="${luceeVersionQuery}"/>
36+
<condition property="no-query-version">
37+
<length string="${luceeVersionQuery}" trim="true" length="0"/>
38+
</condition>
3239
</target>
3340

34-
<target name="check-lucee-jar">
35-
<available file="${cache}/lucee-${luceeVersion}.jar" property="lucee.jar.present"/>
41+
<target name="use-version" if="no-query-version">
42+
<property name="useLuceeVersion" value="${luceeVersion}"/>
43+
<property name="luceeVersionUrl" value="${luceeCdnUrl}/lucee-${useLuceeVersion}.jar"/>
44+
<property name="luceeFilename" value="lucee-${useLuceeVersion}.jar"/>
3645
</target>
3746

38-
<target name="check-lucee-lco">
39-
<available file="${cache}/${luceeVersion}.lco" property="lucee.lco.present"/>
47+
<target name="query-version" unless="no-query-version">
48+
<echo message="Getting latest Lucee version for ${luceeVersionQuery}" />
49+
<tempfile property="temp.file" suffix=".txt" prefix="lucee-version-query" deleteonexit="true"/>
50+
<get src="${luceeUpdateProvider}${luceeVersionQuery}/filename" dest="${temp.file}" verbose="true"/>
51+
<loadfile property="luceeFilename" srcFile="${temp.file}">
52+
<filterchain>
53+
<tokenfilter>
54+
<replaceregex pattern='"' replace="" flags="g"/>
55+
</tokenfilter>
56+
</filterchain>
57+
</loadfile>
58+
<property name="luceeVersionUrl" value="${luceeCdnUrl}/${luceeFilename}"/>
59+
<property name="useLuceeVersion" value="${luceeFilename}"/>
60+
<echo message="Lucee version: ${useLuceeVersion}" />
4061
</target>
4162

42-
<target name="download-lucee-jar" unless="lucee.jar.present">
43-
<mkdir dir="${cache}"/>
44-
<get src="${luceeCdnUrl}/lucee-${luceeVersion}.jar" dest="${cache}/lucee-${luceeVersion}.jar"/>
63+
<target name="check-lucee-jar">
64+
<available file="${cache}/${luceeFilename}" property="lucee.jar.present"/>
4565
</target>
4666

47-
<target name="download-lucee-lco" unless="lucee.lco.present">
67+
<target name="download-lucee-jar" unless="lucee.jar.present">
4868
<mkdir dir="${cache}"/>
49-
<get src="${luceeCdnUrl}/${luceeVersion}.lco" dest="${cache}/${luceeVersion}.lco"/>
69+
<get src="${luceeVersionUrl}" dest="${cache}/${luceeFilename}" verbose="true"/>
5070
</target>
5171

5272
<target name="run-cfml">
5373
<echo message="Java: ${java.version}, ${java.home}" />
54-
<echo message="Lucee: ${luceeVersion}" />
74+
<echo message="Lucee: ${useLuceeVersion}" />
5575
<echo message="Webroot: ${webroot}" />
5676
<echo message="Execute: ${execute}" />
5777
<echo message="ExtensionDir: ${extensionDir}" />
@@ -72,7 +92,7 @@
7292

7393
<java classname="org.apache.tools.ant.launch.Launcher" dir="${temp}/lucee" fork="true" failonerror="true" errorproperty="errorOut">
7494
<classpath path="${java.class.path}">
75-
<pathelement location="${cache}/lucee-${luceeVersion}.jar"/>
95+
<pathelement location="${cache}/${luceeFilename}"/>
7696
<pathelement path="${runtime_classpath}"/>
7797
</classpath>
7898
<arg value="-f"/>
@@ -85,6 +105,8 @@
85105
<jvmarg value="-DextensionDir=${extensionDir}"/>
86106
<jvmarg value="-Dlucee.extensions=${extensions}"/>
87107
<jvmarg value="-Dlucee.mapping.first=true"/>
108+
<jvmarg value="-Dcompile=${compile}"/>
109+
88110
<!--
89111
<jvmarg value="-Xdebug"/>
90112
<jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"/>

0 commit comments

Comments
 (0)