Skip to content

Need error reporting that doesn't dump entire script into my log #40

@XLTechie

Description

@XLTechie

Currently, I am having an issue wherein invoking the action as follows:

      - name: Create installer
      uses: joncloud/makensis-action@v5.0

Is resulting in the following difficult to parse error text being dumped into my job log:

##[group]Run joncloud/makensis-action@v5.0
with:
  script-file: install.nsi
env:
  pythonLocation: C:\hostedtoolcache\windows\Python\3.13.11\x64
  PKG_CONFIG_PATH: C:\hostedtoolcache\windows\Python\3.13.11\x64/lib/pkgconfig
  Python_ROOT_DIR: C:\hostedtoolcache\windows\Python\3.13.11\x64
  Python2_ROOT_DIR: C:\hostedtoolcache\windows\Python\3.13.11\x64
  Python3_ROOT_DIR: C:\hostedtoolcache\windows\Python\3.13.11\x64
##[endgroup]
file:///D:/a/_actions/joncloud/makensis-action/v5.0/dist/index.js:1
import{constants as e,existsSync as t}from"fs";import{access as n,copyFile as r,mkdir as i,readdir as a,stat as o}from"fs/promises";import{basename as s,join as c,resolve as l}from"path";import{promisify as u}from"util";import{exec as d}from"child_process";import{env as f,platform as p}from"process";const m=()=>{let e=m.coreGetInput(`arguments`),t=m.coreGetInput(`additional-plugin-paths`).split(/\n|\r/).map(e=>e.trim()).filter(e=>!!e),n=m.coreGetInput(`script-file`);return{customArguments:e,additionalPluginPaths:t,scriptFile:n}};m.coreGetInput=function(e){return(process.env[`INPUT_${e.replace(/ /g,`_`).toUpperCase()}`]||``).trim()};const h=e=>{h.setFailed(e||h.genericErrorMessage)};h.setFailed=function(e){e instanceof Error&&(e=e.toString()),process.exitCode=1,process.stdout.write(`error${g(e)}${os.EOL}`)};function g(e){return toCommandValue(e).replace(/%/g,`%25`).replace(/\r/g,`%0D`).replace(/\n/g,`%0A`)}h.genericErrorMessage=`Unexpected error occurred`;const _=u(d),v=e=>{let n=e.filter(t);return n.length?n[0]:``},y=()=>{let e=f.PATH.split(`;`).concat([c(`C:`,`Program Files (x86)`,`NSIS`)]).map(e=>c(e,`makensis.exe`));return v(e)},b=()=>{let e=f.PATH.split(`:`).concat([`/usr/local/bin`,`/usr/bin`,`/opt/local/bin`]).map(e=>c(e,`makensis`));return v(e)};var x=class{constructor(e){if(!e||!t(e))throw Error(`Unable to find makensis executable`);this.path=e}async execAsync(e){return(await _(`"${this.path}" ${e}`)).stdout}async getSymbolsAsync(){let e=await this.execAsync(`-HDRINFO`),t=/Defined symbols: (.*)/g.exec(e.toString(`utf-8`));if(!t||!t.length||t.length<2)throw Error(`Unable to get symbols`);let n={};return t[1].split(`,`).forEach(e=>{let t=e.indexOf(`=`);if(t===-1)n[e]=``;else{let r=e.substr(0,t);n[r]=e.substr(t+1)}}),n}};const S=p===`win32`?y():b();var C=new x(S);const{F_OK:w}=e,T=async e=>(await o(e)).isDirectory(),E=async e=>{try{await n(e,w)}catch(e){return!1}return!0},D=async(e,t)=>{console.log(`copyDirectory`,e,t),await E(t)||await i(t);let n=(await a(e)).map(async n=>{let i=s(n),a=c(e,i);await T(a)?await D(a,c(t,i)):(console.log(`copying`,a,c(t,i)),await r(a,c(t,i)))});await Promise.all(n)};var O=class{constructor(e){this.debugMode=e,this.pluginPaths=[],this.customArguments=``}debugLog(e){this.debugMode&&console.log(e)}getCustomArguments(){return this.customArguments}setCustomArguments(e){this.debugLog(`Settings arguments: ${e}`),this.customArguments=e}addPluginPath(e){this.debugLog(`Adding plugin path: ${e}`),this.pluginPaths.push(e)}getProcessArguments(e){let t=[];return this.customArguments.indexOf(`/V`)===-1&&this.customArguments.indexOf(`-V`)===-1&&(this.debugMode?t.push(`-V4`):t.push(`-V1`)),t.push(this.customArguments),t.push(`"${l(e)}"`),t}async createInstallerAsync(e){if(console.log(`Creating installer for: ${e}`),this.pluginPaths.length){let e=(await C.getSymbolsAsync()).NSISDIR;if(!e)throw Error(`Unable to determine NSISDIR. Check makensis -HDRINFO output`);let t=c(e,`Plugins`);this.debugLog(`Using system Plugins path ${t}`);let n=this.pluginPaths.map(e=>(console.log(`Including plugin path`,e),D(e,t)));await Promise.all(n)}let t=this.getProcessArguments(e).join(` `);this.debugLog(`Running ${t}`),await C.execAsync(t)}};const k=e=>{if(!e)return!1;if(e!==`true`&&e!==`false`)throw Error(`Input must be boolean value 'true' or 'false' but got '${e}'`);return e===`true`};(async()=>{try{let e=k(process.env.debug),{customArguments:t,additionalPluginPaths:n,scriptFile:r}=m(),i=new O(e);i.setCustomArguments(t),n.forEach(e=>i.addPluginPath(e.trim())),await i.createInstallerAsync(r)}catch(e){h(e.message)}})().then(()=>process.exit(0)).catch(()=>process.exit(1));export{};

[A line containing 1,021 spaces has been removed.]

Error: Unable to find makensis executable
    at new x (file:///D:/a/_actions/joncloud/makensis-action/v5.0/dist/index.js:1:1320)
    at file:///D:/a/_actions/joncloud/makensis-action/v5.0/dist/index.js:1:1791
    at ModuleJob.run (node:internal/modules/esm/module_job:413:25)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:660:26)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:101:5)

Node.js v24.12.0

If this output is in your control (I've never written an action, but having seen some fail, it's usually prettier than that), please consider making this into a simple one-line error message or the like.

For what it's worth, the underlying difficulty here is issue #39, though the 5,000 plus character error report doesn't lend itself to clear parsing.
In part because I use a screen reader, and so can't as easily find the visually relevant part of the text, and initially had to read through this a couple times to find where the actual error was. But even so, dumping the entire script back as a log entry is just irregular.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions