firebase / firebase-tools

The Firebase Command Line Tools
MIT License
4.01k stars 929 forks source link

split of undefined in firepit-log.txt when using binary within js Github Actions #2427

Closed prescottprue closed 3 years ago

prescottprue commented 4 years ago

[REQUIRED] Environment info

firebase-tools: 8.4.3

Platform: Ubuntu

[REQUIRED] Test case

Downloading the firebase-tools binary as per the instructions in the docs and trying to call within a custom js Github Action:

import * as core from '@actions/core';
import * as exec from '@actions/exec';

/**
 * Run deploy command by downloading firebase-tools binary
 */
async function run() {
  const firebaseBinaryPath = `${process.env.GITHUB_WORKSPACE}/firebase_bin`;
  // Download firebase-tools binary
  await exec.exec('curl', [
    '-Lo',
    firebaseBinaryPath,
    'https://firebase.tools/bin/linux/v8.4.3',
  ]);
  core.info(`Downloaded firebase binary, making executable`);

  // Make binary executable
  await exec('chmod', ['+x', firebaseBinaryPath]);
  core.info(`Chmod successful, adding to cache dir`);

  // Use firebase-tools binary to trigger deploy
  await exec.exec(firebaseBinaryPath, [
    'deploy',
    '--only',
    'functions',
    '--project',
    'some-project',
  ]);
}

run().catch((err) => {
  console.error('Error:', err);
  core.setFailed(err.message);
});

Produces: This tool has encountered an error. Please file a bug on Github (https://github.com/firebase/firebase-tools/) and include firepit-log.txt

[REQUIRED] Steps to reproduce

Use the above logic in a custom github action attempts to run the following command:

/home/runner/work/fireadmin/fireadmin/firebase_bin deploy --only functions --project fireadmin-stage

NOTE that /home/runner/work/fireadmin/fireadmin is the GITHUB_WORKSPACE for a project named fireadmin (apologies for confusing name)

This also happens when calling without the --only flag

[REQUIRED] Expected behavior

I would expect that calling the binary works in all environments - this same logic works when running on my mac and downloading the binary from https://firebase.tools/bin/macos/v8.4.3.

I also would expect to be able to get a debug log if passing --debug, but it seems like that logic is never being run since no debug logs trigger, and there is no firebase-debug.log file created

[REQUIRED] Actual behavior

Welcome to firepit v1.1.0!
Doing JSON parses for version checks at /snapshot/firepit/vendor/node_modules/firebase-tools/package.json
JSONStream,abort-controller,accepts,agent-base,ajv,ansi-align,ansi-escapes,ansi-regex,ansi-styles,ansicolors,anymatch,archiver,archiver-utils,argparse,array-flatten,arrify,as-array,asn1,assert-plus,async,async-each,asynckit,aws-sign2,aws4,balanced-match,base64-js,basic-auth,basic-auth-connect,bcrypt-pbkdf,big-integer,bignumber.js,binary,binary-extensions,bl,bluebird,body-parser,boxen,brace-expansion,braces,buffer,buffer-crc32,buffer-equal-constant-time,buffer-indexof-polyfill,buffers,bytes,camelcase,capture-stack-trace,cardinal,caseless,chainsaw,chalk,char-spinner,chardet,chokidar,chownr,ci-info,cjson,cli-boxes,cli-color,cli-cursor,cli-spinners,cli-table,cli-width,clone,color,color-convert,color-name,color-string,colornames,colors,colorspace,combined-stream,commander,compare-semver,compress-commons,compressible,compression,concat-map,configstore,connect,connect-query,content-disposition,content-type,cookie,cookie-signature,core-util-is,crc,crc32-stream,create-error-class,cross-env,cross-spawn,crypto-random-string,csv-streamify,d,dashdash,debug,deep-extend,deep-is,defaults,delayed-stream,depd,destroy,diagnostics,dot-prop,dotenv,duplexer2,duplexer3,duplexify,ecc-jsbn,ecdsa-sig-formatter,ee-first,enabled,encodeurl,end-of-stream,env-variable,es5-ext,es6-iterator,es6-symbol,es6-weak-map,escape-html,escape-string-regexp,esprima,etag,event-emitter,event-target-shim,execa,exit-code,express,ext,extend,external-editor,extsprintf,fast-deep-equal,fast-json-stable-stringify,fast-safe-stringify,fast-text-encoding,fast-url-parser,fecha,figures,filesize,fill-range,finalhandler,firebase-tools,flat-arguments,forever-agent,form-data,forwarded,fresh,fs-constants,fs-extra,fs-minipass,fs.realpath,fstream,gaxios,gcp-metadata,get-stream,getpass,glob,glob-parent,glob-slash,glob-slasher,global-dirs,google-auth-library,google-gax,google-p12-pem,got,graceful-fs,gtoken,har-schema,har-validator,has-ansi,has-flag,home-dir,http-errors,http-signature,https-proxy-agent,iconv-lite,ieee754,import-lazy,imurmurhash,inflight,inherits,ini,inquirer,ip-regex,ipaddr.js,is-arrayish,is-binary-path,is-ci,is-extglob,is-fullwidth-code-point,is-glob,is-installed-globally,is-npm,is-number,is-obj,is-path-inside,is-promise,is-redirect,is-retry-allowed,is-stream,is-stream-ended,is-typedarray,is-url,is-wsl,is2,isarray,isexe,isstream,jju,join-path,js-yaml,jsbn,json-bigint,json-parse-helpfulerror,json-schema,json-schema-traverse,json-stringify-safe,jsonfile,jsonparse,jsonschema,jsonwebtoken,jsprim,jwa,jws,klaw,kuler,latest-version,lazystream,leven,listenercount,lodash,lodash._isnative,lodash._objecttypes,lodash._shimkeys,lodash.at,lodash.camelcase,lodash.defaults,lodash.difference,lodash.flatten,lodash.has,lodash.includes,lodash.isarguments,lodash.isboolean,lodash.isinteger,lodash.isnumber,lodash.isobject,lodash.isplainobject,lodash.isstring,lodash.keys,lodash.once,lodash.snakecase,lodash.toarray,lodash.union,lodash.values,log-symbols,logform,long,lowercase-keys,lru-cache,lru-queue,make-dir,marked,marked-terminal,media-typer,memoizee,merge-descriptors,methods,mime,mime-db,mime-types,mimic-fn,minimatch,minimist,minipass,minizlib,mkdirp,morgan,ms,mute-stream,nash,negotiator,next-tick,nice-try,node-emoji,node-fetch,node-forge,normalize-path,npm-run-path,oauth-sign,on-finished,on-headers,once,one-time,onetime,open,ora,os-tmpdir,p-defer,p-finally,package-json,parseurl,path-is-absolute,path-is-inside,path-key,path-to-regexp,performance-now,picomatch,pify,plist,portfinder,prepend-http,process-nextick-args,progress,protobufjs,proxy-addr,pseudomap,psl,punycode,qs,range-parser,raw-body,rc,readable-stream,readdirp,redeyed,registry-auth-token,registry-url,request,restore-cursor,retry-request,rimraf,router,rsvp,run-async,rxjs,safe-buffer,safer-buffer,semver,semver-diff,send,serve-static,setimmediate,setprototypeof,shebang-command,shebang-regex,signal-exit,simple-swizzle,sprintf-js,sshpk,stack-trace,statuses,stream-shift,string-length,string-width,string_decoder,strip-ansi,strip-eof,strip-json-comments,superstatic,supports-color,supports-hyperlinks,tar,tar-stream,tcp-port-used,term-size,text-hex,through,through2,timed-out,timers-ext,tmp,to-regex-range,toidentifier,tough-cookie,toxic,traverse,triple-beam,try-require,tslib,tunnel-agent,tweetnacl,type,type-is,typedarray-to-buffer,unique-string,universal-analytics,unpipe,unzip-response,unzipper,update-notifier,uri-js,url-join,url-parse-lax,util-deprecate,utils-merge,uuid,valid-url,vary,verror,walkdir,wcwidth,which,widest-line,winston,winston-transport,wrappy,write-file-atomic,ws,xdg-basedir,xmlbuilder,xmldom,xtend,yallist,zip-stream,@google-cloud,@grpc,@protobufjs,@types
No existing firebase-tools install found.
Installed ft@none and packaged ft@8.4.3
Legacy firepit / firebase-tools detected, clearing it out...

Checking for npm/bin/npm-cli install at /home/runner/.cache/firebase/tools/lib/node_modules/npm/bin/npm-cli
Checking for npm/bin/npm-cli install at /home/runner/.cache/firebase/tools/node_modules/npm/bin/npm-cli
Checking for npm/bin/npm-cli install at /snapshot/firepit/node_modules/npm/bin/npm-cli
Found npm/bin/npm-cli install.
Checking for npm/bin/npm-cli install at /home/runner/.cache/firebase/tools/lib/node_modules/npm/bin/npm-cli
Checking for npm/bin/npm-cli install at /home/runner/.cache/firebase/tools/node_modules/npm/bin/npm-cli
Checking for npm/bin/npm-cli install at /snapshot/firepit/node_modules/npm/bin/npm-cli
Found npm/bin/npm-cli install.
Runtime binaries created.
/home/runner/work/fireadmin/fireadmin/firebase_bin
/home/runner/work/fireadmin/fireadmin/firebase_bin,/snapshot/firepit/firepit.js,deploy,--only,functions:indexUser,--project,fireadmin-stage
Checking for npm/bin/npm-cli install at /home/runner/.cache/firebase/tools/lib/node_modules/npm/bin/npm-cli
Checking for npm/bin/npm-cli install at /home/runner/.cache/firebase/tools/node_modules/npm/bin/npm-cli
Checking for npm/bin/npm-cli install at /snapshot/firepit/node_modules/npm/bin/npm-cli
Found npm/bin/npm-cli install.
Checking for npm/bin/npm-cli install at /home/runner/.cache/firebase/tools/lib/node_modules/npm/bin/npm-cli
Checking for npm/bin/npm-cli install at /home/runner/.cache/firebase/tools/node_modules/npm/bin/npm-cli
Checking for npm/bin/npm-cli install at /snapshot/firepit/node_modules/npm/bin/npm-cli
Found npm/bin/npm-cli install.
Runtime binaries created.
TypeError: Cannot read property 'split' of undefined

The only two places I saw split in firepit was

samtstern commented 4 years ago

@prescottprue thanks for the detailed bug! Assigning to @abeisgoat who does all things Firepit

prescottprue commented 4 years ago

@abeisgoat Let me know if there is anything else I can provide to help debug - would really love to get the binary working in actions

abeisgoat commented 4 years ago

Hmm thanks for the report, I'll dig into it and see what's up. We've had bad luck with the CLI in actions for awhile, so I'll see

prescottprue commented 4 years ago

@abeisgoat Yup, np. Thanks for the update

Interesting to hear you have had other issues with cli in actions, I have not really had any issues even doing relatively complex stuff with it inline (loaded from npm bin since it is a dev dependency of our codebase), it is just when putting it into a custom js action that I have the above listed issue.

prescottprue commented 4 years ago

Ping

abeisgoat commented 3 years ago

This should have been resolved awhile ago with a bunch of other installer fixes, please reopen if it still exists.