diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 868bffc..7e8e916 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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: @@ -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/" diff --git a/.gitignore b/.gitignore index af92264..4e0eaf7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ lucee-download-cache temp +bin diff --git a/README.md b/README.md index 8187a26..b1246e1 100644 --- a/README.md +++ b/README.md @@ -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=""` @@ -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 diff --git a/action.yml b/action.yml index b989f74..aeddc64 100644 --- a/action.yml +++ b/action.yml @@ -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 @@ -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 \ No newline at end of file diff --git a/build-run-cfml.xml b/build-run-cfml.xml index 5b3146b..2d37244 100644 --- a/build-run-cfml.xml +++ b/build-run-cfml.xml @@ -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(); } @@ -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 diff --git a/build.xml b/build.xml index ccb0727..b92bbee 100644 --- a/build.xml +++ b/build.xml @@ -13,15 +13,18 @@ + - + + + - + @@ -29,29 +32,46 @@ + + + + - - + + + + - - + + + + + + + + + + + + + + - - - + + - + - + - + @@ -72,7 +92,7 @@ - + @@ -85,6 +105,8 @@ + +