From e35786a47273d7e881270c70a4660b0f3f5fddd7 Mon Sep 17 00:00:00 2001 From: svartalf Date: Wed, 25 Sep 2019 10:08:33 +0300 Subject: [PATCH] Use @actions-rs/core for cargo/cross execution. Add problem matcher for cargo output --- .github/workflows/ci.yml | 5 +++ .matchers/rust.json | 21 ++++++++++ .npmrc | 1 + CHANGELOG.md | 21 ++++++++++ __tests__/input.test.ts | 4 +- dist/.matchers/rust.json | 21 ++++++++++ dist/index.js | 2 +- package-lock.json | 16 ++++++-- package.json | 3 +- src/input.ts | 39 +++---------------- src/main.ts | 82 ++++++---------------------------------- tsconfig.json | 10 ++--- 12 files changed, 109 insertions(+), 116 deletions(-) create mode 100644 .matchers/rust.json create mode 100644 .npmrc create mode 100644 CHANGELOG.md create mode 100644 dist/.matchers/rust.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index db004f1..b6952e2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,11 @@ jobs: check_pr: runs-on: ubuntu-latest steps: + - name: Create npm configuration + run: echo "//npm.pkg.github.com/:_authToken=${token}" >> ~/.npmrc + env: + token: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/checkout@v1 - name: "npm ci" diff --git a/.matchers/rust.json b/.matchers/rust.json new file mode 100644 index 0000000..9813de8 --- /dev/null +++ b/.matchers/rust.json @@ -0,0 +1,21 @@ +{ + "problemMatcher": [ + { + "owner": "rust", + "pattern": [ + { + "regexp": "^(warning|warn|error)(\\[(.*)\\])?: (.*)$", + "severity": 1, + "message": 4, + "code": 3 + }, + { + "regexp": "^([\\s->=]*(.*):(\\d*):(\\d*)|.*)$", + "file": 2, + "line": 3, + "column": 4 + } + ] + } + ] +} diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..6b6062d --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +@actions-rs:registry=https://npm.pkg.github.com diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..b0c7662 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,21 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +### Added + +- Problem matcher which will highlight warnings and errors in the cargo output + +### Changed + +- Use `@action-rs/core` package for cargo/cross execution + +## [1.0.1] - 2019-09-15 + +### Added + +- First public version diff --git a/__tests__/input.test.ts b/__tests__/input.test.ts index bf763e9..cc00fd4 100644 --- a/__tests__/input.test.ts +++ b/__tests__/input.test.ts @@ -8,14 +8,14 @@ const testEnvVars = { INPUT_TOOLCHAIN: '+nightly' } -describe('actions-rs/check', () => { +describe('actions-rs/cargo/input', () => { beforeEach(() => { for (const key in testEnvVars) process.env[key] = testEnvVars[key as keyof typeof testEnvVars] }) it('Parses action input into cargo input', async () => { - const result = input.parse(); + const result = input.get(); expect(result.command).toBe('build'); expect(result.args).toStrictEqual([ diff --git a/dist/.matchers/rust.json b/dist/.matchers/rust.json new file mode 100644 index 0000000..9813de8 --- /dev/null +++ b/dist/.matchers/rust.json @@ -0,0 +1,21 @@ +{ + "problemMatcher": [ + { + "owner": "rust", + "pattern": [ + { + "regexp": "^(warning|warn|error)(\\[(.*)\\])?: (.*)$", + "severity": 1, + "message": 4, + "code": 3 + }, + { + "regexp": "^([\\s->=]*(.*):(\\d*):(\\d*)|.*)$", + "file": 2, + "line": 3, + "column": 4 + } + ] + } + ] +} diff --git a/dist/index.js b/dist/index.js index b932124..8f47d02 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1 +1 @@ -module.exports=function(e,t){"use strict";var i={};function __webpack_require__(t){if(i[t]){return i[t].exports}var r=i[t]={i:t,l:false,exports:{}};e[t].call(r.exports,r,r.exports,__webpack_require__);r.l=true;return r.exports}__webpack_require__.ab=__dirname+"/";function startup(){return __webpack_require__(131)}return startup()}({1:function(e,t,i){"use strict";var r=this&&this.__awaiter||function(e,t,i,r){function adopt(e){return e instanceof i?e:new i(function(t){t(e)})}return new(i||(i=Promise))(function(i,n){function fulfilled(e){try{step(r.next(e))}catch(e){n(e)}}function rejected(e){try{step(r["throw"](e))}catch(e){n(e)}}function step(e){e.done?i(e.value):adopt(e.value).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:true});const n=i(129);const s=i(622);const o=i(669);const c=i(672);const u=o.promisify(n.exec);function cp(e,t,i={}){return r(this,void 0,void 0,function*(){const{force:r,recursive:n}=readCopyOptions(i);const o=(yield c.exists(t))?yield c.stat(t):null;if(o&&o.isFile()&&!r){return}const u=o&&o.isDirectory()?s.join(t,s.basename(e)):t;if(!(yield c.exists(e))){throw new Error(`no such file or directory: ${e}`)}const l=yield c.stat(e);if(l.isDirectory()){if(!n){throw new Error(`Failed to copy. ${e} is a directory, but tried to copy without recursive flag.`)}else{yield cpDirRecursive(e,u,0,r)}}else{if(s.relative(e,u)===""){throw new Error(`'${u}' and '${e}' are the same file`)}yield copyFile(e,u,r)}})}t.cp=cp;function mv(e,t,i={}){return r(this,void 0,void 0,function*(){if(yield c.exists(t)){let r=true;if(yield c.isDirectory(t)){t=s.join(t,s.basename(e));r=yield c.exists(t)}if(r){if(i.force==null||i.force){yield rmRF(t)}else{throw new Error("Destination already exists")}}}yield mkdirP(s.dirname(t));yield c.rename(e,t)})}t.mv=mv;function rmRF(e){return r(this,void 0,void 0,function*(){if(c.IS_WINDOWS){try{if(yield c.isDirectory(e,true)){yield u(`rd /s /q "${e}"`)}else{yield u(`del /f /a "${e}"`)}}catch(e){if(e.code!=="ENOENT")throw e}try{yield c.unlink(e)}catch(e){if(e.code!=="ENOENT")throw e}}else{let t=false;try{t=yield c.isDirectory(e)}catch(e){if(e.code!=="ENOENT")throw e;return}if(t){yield u(`rm -rf "${e}"`)}else{yield c.unlink(e)}}})}t.rmRF=rmRF;function mkdirP(e){return r(this,void 0,void 0,function*(){yield c.mkdirP(e)})}t.mkdirP=mkdirP;function which(e,t){return r(this,void 0,void 0,function*(){if(!e){throw new Error("parameter 'tool' is required")}if(t){const t=yield which(e,false);if(!t){if(c.IS_WINDOWS){throw new Error(`Unable to locate executable file: ${e}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.`)}else{throw new Error(`Unable to locate executable file: ${e}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`)}}}try{const t=[];if(c.IS_WINDOWS&&process.env.PATHEXT){for(const e of process.env.PATHEXT.split(s.delimiter)){if(e){t.push(e)}}}if(c.isRooted(e)){const i=yield c.tryGetExecutablePath(e,t);if(i){return i}return""}if(e.includes("/")||c.IS_WINDOWS&&e.includes("\\")){return""}const i=[];if(process.env.PATH){for(const e of process.env.PATH.split(s.delimiter)){if(e){i.push(e)}}}for(const r of i){const i=yield c.tryGetExecutablePath(r+s.sep+e,t);if(i){return i}}return""}catch(e){throw new Error(`which failed with message ${e.message}`)}})}t.which=which;function readCopyOptions(e){const t=e.force==null?true:e.force;const i=Boolean(e.recursive);return{force:t,recursive:i}}function cpDirRecursive(e,t,i,n){return r(this,void 0,void 0,function*(){if(i>=255)return;i++;yield mkdirP(t);const r=yield c.readdir(e);for(const s of r){const r=`${e}/${s}`;const o=`${t}/${s}`;const u=yield c.lstat(r);if(u.isDirectory()){yield cpDirRecursive(r,o,i,n)}else{yield copyFile(r,o,n)}}yield c.chmod(t,(yield c.stat(e)).mode)})}function copyFile(e,t,i){return r(this,void 0,void 0,function*(){if((yield c.lstat(e)).isSymbolicLink()){try{yield c.lstat(t);yield c.unlink(t)}catch(e){if(e.code==="EPERM"){yield c.chmod(t,"0666");yield c.unlink(t)}}const i=yield c.readlink(e);yield c.symlink(i,t,c.IS_WINDOWS?"junction":null)}else if(!(yield c.exists(t))||i){yield c.copyFile(e,t)}})}},9:function(e,t,i){"use strict";var r=this&&this.__awaiter||function(e,t,i,r){function adopt(e){return e instanceof i?e:new i(function(t){t(e)})}return new(i||(i=Promise))(function(i,n){function fulfilled(e){try{step(r.next(e))}catch(e){n(e)}}function rejected(e){try{step(r["throw"](e))}catch(e){n(e)}}function step(e){e.done?i(e.value):adopt(e.value).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:true});const n=i(87);const s=i(614);const o=i(129);const c=process.platform==="win32";class ToolRunner extends s.EventEmitter{constructor(e,t,i){super();if(!e){throw new Error("Parameter 'toolPath' cannot be null or empty.")}this.toolPath=e;this.args=t||[];this.options=i||{}}_debug(e){if(this.options.listeners&&this.options.listeners.debug){this.options.listeners.debug(e)}}_getCommandString(e,t){const i=this._getSpawnFileName();const r=this._getSpawnArgs(e);let n=t?"":"[command]";if(c){if(this._isCmdFile()){n+=i;for(const e of r){n+=` ${e}`}}else if(e.windowsVerbatimArguments){n+=`"${i}"`;for(const e of r){n+=` ${e}`}}else{n+=this._windowsQuoteCmdArg(i);for(const e of r){n+=` ${this._windowsQuoteCmdArg(e)}`}}}else{n+=i;for(const e of r){n+=` ${e}`}}return n}_processLineBuffer(e,t,i){try{let r=t+e.toString();let s=r.indexOf(n.EOL);while(s>-1){const e=r.substring(0,s);i(e);r=r.substring(s+n.EOL.length);s=r.indexOf(n.EOL)}t=r}catch(e){this._debug(`error processing line. Failed with error ${e}`)}}_getSpawnFileName(){if(c){if(this._isCmdFile()){return process.env["COMSPEC"]||"cmd.exe"}}return this.toolPath}_getSpawnArgs(e){if(c){if(this._isCmdFile()){let t=`/D /S /C "${this._windowsQuoteCmdArg(this.toolPath)}`;for(const i of this.args){t+=" ";t+=e.windowsVerbatimArguments?i:this._windowsQuoteCmdArg(i)}t+='"';return[t]}}return this.args}_endsWith(e,t){return e.endsWith(t)}_isCmdFile(){const e=this.toolPath.toUpperCase();return this._endsWith(e,".CMD")||this._endsWith(e,".BAT")}_windowsQuoteCmdArg(e){if(!this._isCmdFile()){return this._uvQuoteCmdArg(e)}if(!e){return'""'}const t=[" ","\t","&","(",")","[","]","{","}","^","=",";","!","'","+",",","`","~","|","<",">",'"'];let i=false;for(const r of e){if(t.some(e=>e===r)){i=true;break}}if(!i){return e}let r='"';let n=true;for(let t=e.length;t>0;t--){r+=e[t-1];if(n&&e[t-1]==="\\"){r+="\\"}else if(e[t-1]==='"'){n=true;r+='"'}else{n=false}}r+='"';return r.split("").reverse().join("")}_uvQuoteCmdArg(e){if(!e){return'""'}if(!e.includes(" ")&&!e.includes("\t")&&!e.includes('"')){return e}if(!e.includes('"')&&!e.includes("\\")){return`"${e}"`}let t='"';let i=true;for(let r=e.length;r>0;r--){t+=e[r-1];if(i&&e[r-1]==="\\"){t+="\\"}else if(e[r-1]==='"'){i=true;t+="\\"}else{i=false}}t+='"';return t.split("").reverse().join("")}_cloneExecOptions(e){e=e||{};const t={cwd:e.cwd||process.cwd(),env:e.env||process.env,silent:e.silent||false,windowsVerbatimArguments:e.windowsVerbatimArguments||false,failOnStdErr:e.failOnStdErr||false,ignoreReturnCode:e.ignoreReturnCode||false,delay:e.delay||1e4};t.outStream=e.outStream||process.stdout;t.errStream=e.errStream||process.stderr;return t}_getSpawnOptions(e,t){e=e||{};const i={};i.cwd=e.cwd;i.env=e.env;i["windowsVerbatimArguments"]=e.windowsVerbatimArguments||this._isCmdFile();if(e.windowsVerbatimArguments){i.argv0=`"${t}"`}return i}exec(){return r(this,void 0,void 0,function*(){return new Promise((e,t)=>{this._debug(`exec tool: ${this.toolPath}`);this._debug("arguments:");for(const e of this.args){this._debug(` ${e}`)}const i=this._cloneExecOptions(this.options);if(!i.silent&&i.outStream){i.outStream.write(this._getCommandString(i)+n.EOL)}const r=new ExecState(i,this.toolPath);r.on("debug",e=>{this._debug(e)});const s=this._getSpawnFileName();const c=o.spawn(s,this._getSpawnArgs(i),this._getSpawnOptions(this.options,s));const u="";if(c.stdout){c.stdout.on("data",e=>{if(this.options.listeners&&this.options.listeners.stdout){this.options.listeners.stdout(e)}if(!i.silent&&i.outStream){i.outStream.write(e)}this._processLineBuffer(e,u,e=>{if(this.options.listeners&&this.options.listeners.stdline){this.options.listeners.stdline(e)}})})}const l="";if(c.stderr){c.stderr.on("data",e=>{r.processStderr=true;if(this.options.listeners&&this.options.listeners.stderr){this.options.listeners.stderr(e)}if(!i.silent&&i.errStream&&i.outStream){const t=i.failOnStdErr?i.errStream:i.outStream;t.write(e)}this._processLineBuffer(e,l,e=>{if(this.options.listeners&&this.options.listeners.errline){this.options.listeners.errline(e)}})})}c.on("error",e=>{r.processError=e.message;r.processExited=true;r.processClosed=true;r.CheckComplete()});c.on("exit",e=>{r.processExitCode=e;r.processExited=true;this._debug(`Exit code ${e} received from tool '${this.toolPath}'`);r.CheckComplete()});c.on("close",e=>{r.processExitCode=e;r.processExited=true;r.processClosed=true;this._debug(`STDIO streams have closed for tool '${this.toolPath}'`);r.CheckComplete()});r.on("done",(i,r)=>{if(u.length>0){this.emit("stdline",u)}if(l.length>0){this.emit("errline",l)}c.removeAllListeners();if(i){t(i)}else{e(r)}})})})}}t.ToolRunner=ToolRunner;function argStringToArray(e){const t=[];let i=false;let r=false;let n="";function append(e){if(r&&e!=='"'){n+="\\"}n+=e;r=false}for(let s=0;s0){t.push(n);n=""}continue}append(o)}if(n.length>0){t.push(n.trim())}return t}t.argStringToArray=argStringToArray;class ExecState extends s.EventEmitter{constructor(e,t){super();this.processClosed=false;this.processError="";this.processExitCode=0;this.processExited=false;this.processStderr=false;this.delay=1e4;this.done=false;this.timeout=null;if(!t){throw new Error("toolPath must not be empty")}this.options=e;this.toolPath=t;if(e.delay){this.delay=e.delay}}CheckComplete(){if(this.done){return}if(this.processClosed){this._setResult()}else if(this.processExited){this.timeout=setTimeout(ExecState.HandleTimeout,this.delay,this)}}_debug(e){this.emit("debug",e)}_setResult(){let e;if(this.processExited){if(this.processError){e=new Error(`There was an error when attempting to execute the process '${this.toolPath}'. This may indicate the process failed to start. Error: ${this.processError}`)}else if(this.processExitCode!==0&&!this.options.ignoreReturnCode){e=new Error(`The process '${this.toolPath}' failed with exit code ${this.processExitCode}`)}else if(this.processStderr&&this.options.failOnStdErr){e=new Error(`The process '${this.toolPath}' failed because one or more lines were written to the STDERR stream`)}}if(this.timeout){clearTimeout(this.timeout);this.timeout=null}this.done=true;this.emit("done",e,this.processExitCode)}static HandleTimeout(e){if(e.done){return}if(!e.processClosed&&e.processExited){const t=`The STDIO streams did not close within ${e.delay/1e3} seconds of the exit event from process '${e.toolPath}'. This may indicate a child process inherited the STDIO streams and has not yet exited.`;e._debug(t)}e._setResult()}}},87:function(e){e.exports=require("os")},129:function(e){e.exports=require("child_process")},131:function(e,t,i){"use strict";var r=this&&this.__awaiter||function(e,t,i,r){function adopt(e){return e instanceof i?e:new i(function(t){t(e)})}return new(i||(i=Promise))(function(i,n){function fulfilled(e){try{step(r.next(e))}catch(e){n(e)}}function rejected(e){try{step(r["throw"](e))}catch(e){n(e)}}function step(e){e.done?i(e.value):adopt(e.value).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())})};var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var i in e)if(Object.hasOwnProperty.call(e,i))t[i]=e[i];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const s=i(87);const o=i(765);const c=n(i(470));const u=n(i(986));const l=n(i(1));const f=n(i(265));const d="69b8da7da287055127812c9e4b071756c2b98545";function getCargo(){return r(this,void 0,void 0,function*(){try{return yield l.which("cargo",true)}catch(e){c.info("cargo is not installed by default for some virtual environments, see https://help.github.com/en/articles/software-in-virtual-environments-for-github-actions");c.info("To install it, use this action: https://github.com/actions-rs/toolchain");throw e}})}function getCross(e){return r(this,void 0,void 0,function*(){try{return yield l.which("cross",true)}catch(e){c.debug("Unable to find cross, installing it now")}const t=o.cwd();o.chdir(s.tmpdir());try{c.startGroup("Install cross");c.warning("Git version of cross will be installed, see https://github.com/actions-rs/cargo/issues/1");yield u.exec(e,["install","--rev",d,"--git","https://github.com/rust-embedded/cross.git"])}catch(e){throw e}finally{o.chdir(t);c.endGroup()}return"cross"})}function run(){return r(this,void 0,void 0,function*(){const e=f.parse();const t=yield getCargo();let i;if(e.useCross){i=yield getCross(t)}else{i=t}let r=[];if(e.toolchain){r.push(`+${e.toolchain}`)}r.push(e.command);r=r.concat(e.args);yield u.exec(i,r)})}function main(){return r(this,void 0,void 0,function*(){try{yield run()}catch(e){c.setFailed(e.message)}})}main()},265:function(e,t,i){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var i in e)if(Object.hasOwnProperty.call(e,i))t[i]=e[i];t["default"]=e;return t};var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});const s=r(i(470));const o=n(i(982));function getInput(e){const t=e.replace(/-/g,"_");let i=s.getInput(t);if(i.length>0){return i}return s.getInput(e)}function getInputBool(e){const t=getInput(e);if(t&&(t=="true"||t=="1")){return true}else{return false}}function parse(){const e=getInput("command");const t=o.default(getInput("args"));let i=getInput("toolchain");if(i.startsWith("+")){i=i.slice(1)}const r=getInputBool("use-cross");return{command:e,args:t,useCross:r,toolchain:i||undefined}}t.parse=parse},357:function(e){e.exports=require("assert")},431:function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:true});const r=i(87);function issueCommand(e,t,i){const n=new Command(e,t,i);process.stdout.write(n.toString()+r.EOL)}t.issueCommand=issueCommand;function issue(e,t=""){issueCommand(e,{},t)}t.issue=issue;const n="::";class Command{constructor(e,t,i){if(!e){e="missing.command"}this.command=e;this.properties=t;this.message=i}toString(){let e=n+this.command;if(this.properties&&Object.keys(this.properties).length>0){e+=" ";for(const t in this.properties){if(this.properties.hasOwnProperty(t)){const i=this.properties[t];if(i){e+=`${t}=${escape(`${i||""}`)},`}}}}e+=n;const t=`${this.message||""}`;e+=escapeData(t);return e}}function escapeData(e){return e.replace(/\r/g,"%0D").replace(/\n/g,"%0A")}function escape(e){return e.replace(/\r/g,"%0D").replace(/\n/g,"%0A").replace(/]/g,"%5D").replace(/;/g,"%3B")}},470:function(e,t,i){"use strict";var r=this&&this.__awaiter||function(e,t,i,r){function adopt(e){return e instanceof i?e:new i(function(t){t(e)})}return new(i||(i=Promise))(function(i,n){function fulfilled(e){try{step(r.next(e))}catch(e){n(e)}}function rejected(e){try{step(r["throw"](e))}catch(e){n(e)}}function step(e){e.done?i(e.value):adopt(e.value).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:true});const n=i(431);const s=i(87);const o=i(622);var c;(function(e){e[e["Success"]=0]="Success";e[e["Failure"]=1]="Failure"})(c=t.ExitCode||(t.ExitCode={}));function exportVariable(e,t){process.env[e]=t;n.issueCommand("set-env",{name:e},t)}t.exportVariable=exportVariable;function exportSecret(e,t){exportVariable(e,t);n.issueCommand("set-secret",{},t);throw new Error("Not implemented.")}t.exportSecret=exportSecret;function addPath(e){n.issueCommand("add-path",{},e);process.env["PATH"]=`${e}${o.delimiter}${process.env["PATH"]}`}t.addPath=addPath;function getInput(e,t){const i=process.env[`INPUT_${e.replace(/ /g,"_").toUpperCase()}`]||"";if(t&&t.required&&!i){throw new Error(`Input required and not supplied: ${e}`)}return i.trim()}t.getInput=getInput;function setOutput(e,t){n.issueCommand("set-output",{name:e},t)}t.setOutput=setOutput;function setFailed(e){process.exitCode=c.Failure;error(e)}t.setFailed=setFailed;function debug(e){n.issueCommand("debug",{},e)}t.debug=debug;function error(e){n.issue("error",e)}t.error=error;function warning(e){n.issue("warning",e)}t.warning=warning;function info(e){process.stdout.write(e+s.EOL)}t.info=info;function startGroup(e){n.issue("group",e)}t.startGroup=startGroup;function endGroup(){n.issue("endgroup")}t.endGroup=endGroup;function group(e,t){return r(this,void 0,void 0,function*(){startGroup(e);let i;try{i=yield t()}finally{endGroup()}return i})}t.group=group},614:function(e){e.exports=require("events")},622:function(e){e.exports=require("path")},669:function(e){e.exports=require("util")},672:function(e,t,i){"use strict";var r=this&&this.__awaiter||function(e,t,i,r){function adopt(e){return e instanceof i?e:new i(function(t){t(e)})}return new(i||(i=Promise))(function(i,n){function fulfilled(e){try{step(r.next(e))}catch(e){n(e)}}function rejected(e){try{step(r["throw"](e))}catch(e){n(e)}}function step(e){e.done?i(e.value):adopt(e.value).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())})};var n;Object.defineProperty(t,"__esModule",{value:true});const s=i(357);const o=i(747);const c=i(622);n=o.promises,t.chmod=n.chmod,t.copyFile=n.copyFile,t.lstat=n.lstat,t.mkdir=n.mkdir,t.readdir=n.readdir,t.readlink=n.readlink,t.rename=n.rename,t.rmdir=n.rmdir,t.stat=n.stat,t.symlink=n.symlink,t.unlink=n.unlink;t.IS_WINDOWS=process.platform==="win32";function exists(e){return r(this,void 0,void 0,function*(){try{yield t.stat(e)}catch(e){if(e.code==="ENOENT"){return false}throw e}return true})}t.exists=exists;function isDirectory(e,i=false){return r(this,void 0,void 0,function*(){const r=i?yield t.stat(e):yield t.lstat(e);return r.isDirectory()})}t.isDirectory=isDirectory;function isRooted(e){e=normalizeSeparators(e);if(!e){throw new Error('isRooted() parameter "p" cannot be empty')}if(t.IS_WINDOWS){return e.startsWith("\\")||/^[A-Z]:/i.test(e)}return e.startsWith("/")}t.isRooted=isRooted;function mkdirP(e,i=1e3,n=1){return r(this,void 0,void 0,function*(){s.ok(e,"a path argument must be provided");e=c.resolve(e);if(n>=i)return t.mkdir(e);try{yield t.mkdir(e);return}catch(r){switch(r.code){case"ENOENT":{yield mkdirP(c.dirname(e),i,n+1);yield t.mkdir(e);return}default:{let i;try{i=yield t.stat(e)}catch(e){throw r}if(!i.isDirectory())throw r}}}})}t.mkdirP=mkdirP;function tryGetExecutablePath(e,i){return r(this,void 0,void 0,function*(){let r=undefined;try{r=yield t.stat(e)}catch(t){if(t.code!=="ENOENT"){console.log(`Unexpected error attempting to determine if executable file exists '${e}': ${t}`)}}if(r&&r.isFile()){if(t.IS_WINDOWS){const t=c.extname(e).toUpperCase();if(i.some(e=>e.toUpperCase()===t)){return e}}else{if(isUnixExecutable(r)){return e}}}const n=e;for(const s of i){e=n+s;r=undefined;try{r=yield t.stat(e)}catch(t){if(t.code!=="ENOENT"){console.log(`Unexpected error attempting to determine if executable file exists '${e}': ${t}`)}}if(r&&r.isFile()){if(t.IS_WINDOWS){try{const i=c.dirname(e);const r=c.basename(e).toUpperCase();for(const n of yield t.readdir(i)){if(r===n.toUpperCase()){e=c.join(i,n);break}}}catch(t){console.log(`Unexpected error attempting to determine the actual case of the file '${e}': ${t}`)}return e}else{if(isUnixExecutable(r)){return e}}}}return""})}t.tryGetExecutablePath=tryGetExecutablePath;function normalizeSeparators(e){e=e||"";if(t.IS_WINDOWS){e=e.replace(/\//g,"\\");return e.replace(/\\\\+/g,"\\")}return e.replace(/\/\/+/g,"/")}function isUnixExecutable(e){return(e.mode&1)>0||(e.mode&8)>0&&e.gid===process.getgid()||(e.mode&64)>0&&e.uid===process.getuid()}},747:function(e){e.exports=require("fs")},765:function(e){e.exports=require("process")},982:function(e,t){"use strict";t.__esModule=true;function parseArgsStringToArgv(e,t,i){var r=/([^\s'"]([^\s'"]*(['"])([^\3]*?)\3)+[^\s'"]*)|[^\s'"]+|(['"])([^\5]*?)\5/gi;var n=e;var s=[];if(t){s.push(t)}if(i){s.push(i)}var o;do{o=r.exec(n);if(o!==null){s.push(firstString(o[1],o[6],o[0]))}}while(o!==null);return s}t["default"]=parseArgsStringToArgv;t.parseArgsStringToArgv=parseArgsStringToArgv;function firstString(){var e=[];for(var t=0;t=255)return;i++;yield mkdirP(t);const n=yield u.readdir(e);for(const s of n){const n=`${e}/${s}`;const o=`${t}/${s}`;const c=yield u.lstat(n);if(c.isDirectory()){yield cpDirRecursive(n,o,i,r)}else{yield copyFile(n,o,r)}}yield u.chmod(t,(yield u.stat(e)).mode)})}function copyFile(e,t,i){return n(this,void 0,void 0,function*(){if((yield u.lstat(e)).isSymbolicLink()){try{yield u.lstat(t);yield u.unlink(t)}catch(e){if(e.code==="EPERM"){yield u.chmod(t,"0666");yield u.unlink(t)}}const i=yield u.readlink(e);yield u.symlink(i,t,u.IS_WINDOWS?"junction":null)}else if(!(yield u.exists(t))||i){yield u.copyFile(e,t)}})}},9:function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){function adopt(e){return e instanceof i?e:new i(function(t){t(e)})}return new(i||(i=Promise))(function(i,r){function fulfilled(e){try{step(n.next(e))}catch(e){r(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){r(e)}}function step(e){e.done?i(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:true});const r=i(87);const s=i(614);const o=i(129);const u=process.platform==="win32";class ToolRunner extends s.EventEmitter{constructor(e,t,i){super();if(!e){throw new Error("Parameter 'toolPath' cannot be null or empty.")}this.toolPath=e;this.args=t||[];this.options=i||{}}_debug(e){if(this.options.listeners&&this.options.listeners.debug){this.options.listeners.debug(e)}}_getCommandString(e,t){const i=this._getSpawnFileName();const n=this._getSpawnArgs(e);let r=t?"":"[command]";if(u){if(this._isCmdFile()){r+=i;for(const e of n){r+=` ${e}`}}else if(e.windowsVerbatimArguments){r+=`"${i}"`;for(const e of n){r+=` ${e}`}}else{r+=this._windowsQuoteCmdArg(i);for(const e of n){r+=` ${this._windowsQuoteCmdArg(e)}`}}}else{r+=i;for(const e of n){r+=` ${e}`}}return r}_processLineBuffer(e,t,i){try{let n=t+e.toString();let s=n.indexOf(r.EOL);while(s>-1){const e=n.substring(0,s);i(e);n=n.substring(s+r.EOL.length);s=n.indexOf(r.EOL)}t=n}catch(e){this._debug(`error processing line. Failed with error ${e}`)}}_getSpawnFileName(){if(u){if(this._isCmdFile()){return process.env["COMSPEC"]||"cmd.exe"}}return this.toolPath}_getSpawnArgs(e){if(u){if(this._isCmdFile()){let t=`/D /S /C "${this._windowsQuoteCmdArg(this.toolPath)}`;for(const i of this.args){t+=" ";t+=e.windowsVerbatimArguments?i:this._windowsQuoteCmdArg(i)}t+='"';return[t]}}return this.args}_endsWith(e,t){return e.endsWith(t)}_isCmdFile(){const e=this.toolPath.toUpperCase();return this._endsWith(e,".CMD")||this._endsWith(e,".BAT")}_windowsQuoteCmdArg(e){if(!this._isCmdFile()){return this._uvQuoteCmdArg(e)}if(!e){return'""'}const t=[" ","\t","&","(",")","[","]","{","}","^","=",";","!","'","+",",","`","~","|","<",">",'"'];let i=false;for(const n of e){if(t.some(e=>e===n)){i=true;break}}if(!i){return e}let n='"';let r=true;for(let t=e.length;t>0;t--){n+=e[t-1];if(r&&e[t-1]==="\\"){n+="\\"}else if(e[t-1]==='"'){r=true;n+='"'}else{r=false}}n+='"';return n.split("").reverse().join("")}_uvQuoteCmdArg(e){if(!e){return'""'}if(!e.includes(" ")&&!e.includes("\t")&&!e.includes('"')){return e}if(!e.includes('"')&&!e.includes("\\")){return`"${e}"`}let t='"';let i=true;for(let n=e.length;n>0;n--){t+=e[n-1];if(i&&e[n-1]==="\\"){t+="\\"}else if(e[n-1]==='"'){i=true;t+="\\"}else{i=false}}t+='"';return t.split("").reverse().join("")}_cloneExecOptions(e){e=e||{};const t={cwd:e.cwd||process.cwd(),env:e.env||process.env,silent:e.silent||false,windowsVerbatimArguments:e.windowsVerbatimArguments||false,failOnStdErr:e.failOnStdErr||false,ignoreReturnCode:e.ignoreReturnCode||false,delay:e.delay||1e4};t.outStream=e.outStream||process.stdout;t.errStream=e.errStream||process.stderr;return t}_getSpawnOptions(e,t){e=e||{};const i={};i.cwd=e.cwd;i.env=e.env;i["windowsVerbatimArguments"]=e.windowsVerbatimArguments||this._isCmdFile();if(e.windowsVerbatimArguments){i.argv0=`"${t}"`}return i}exec(){return n(this,void 0,void 0,function*(){return new Promise((e,t)=>{this._debug(`exec tool: ${this.toolPath}`);this._debug("arguments:");for(const e of this.args){this._debug(` ${e}`)}const i=this._cloneExecOptions(this.options);if(!i.silent&&i.outStream){i.outStream.write(this._getCommandString(i)+r.EOL)}const n=new ExecState(i,this.toolPath);n.on("debug",e=>{this._debug(e)});const s=this._getSpawnFileName();const u=o.spawn(s,this._getSpawnArgs(i),this._getSpawnOptions(this.options,s));const c="";if(u.stdout){u.stdout.on("data",e=>{if(this.options.listeners&&this.options.listeners.stdout){this.options.listeners.stdout(e)}if(!i.silent&&i.outStream){i.outStream.write(e)}this._processLineBuffer(e,c,e=>{if(this.options.listeners&&this.options.listeners.stdline){this.options.listeners.stdline(e)}})})}const l="";if(u.stderr){u.stderr.on("data",e=>{n.processStderr=true;if(this.options.listeners&&this.options.listeners.stderr){this.options.listeners.stderr(e)}if(!i.silent&&i.errStream&&i.outStream){const t=i.failOnStdErr?i.errStream:i.outStream;t.write(e)}this._processLineBuffer(e,l,e=>{if(this.options.listeners&&this.options.listeners.errline){this.options.listeners.errline(e)}})})}u.on("error",e=>{n.processError=e.message;n.processExited=true;n.processClosed=true;n.CheckComplete()});u.on("exit",e=>{n.processExitCode=e;n.processExited=true;this._debug(`Exit code ${e} received from tool '${this.toolPath}'`);n.CheckComplete()});u.on("close",e=>{n.processExitCode=e;n.processExited=true;n.processClosed=true;this._debug(`STDIO streams have closed for tool '${this.toolPath}'`);n.CheckComplete()});n.on("done",(i,n)=>{if(c.length>0){this.emit("stdline",c)}if(l.length>0){this.emit("errline",l)}u.removeAllListeners();if(i){t(i)}else{e(n)}})})})}}t.ToolRunner=ToolRunner;function argStringToArray(e){const t=[];let i=false;let n=false;let r="";function append(e){if(n&&e!=='"'){r+="\\"}r+=e;n=false}for(let s=0;s0){t.push(r);r=""}continue}append(o)}if(r.length>0){t.push(r.trim())}return t}t.argStringToArray=argStringToArray;class ExecState extends s.EventEmitter{constructor(e,t){super();this.processClosed=false;this.processError="";this.processExitCode=0;this.processExited=false;this.processStderr=false;this.delay=1e4;this.done=false;this.timeout=null;if(!t){throw new Error("toolPath must not be empty")}this.options=e;this.toolPath=t;if(e.delay){this.delay=e.delay}}CheckComplete(){if(this.done){return}if(this.processClosed){this._setResult()}else if(this.processExited){this.timeout=setTimeout(ExecState.HandleTimeout,this.delay,this)}}_debug(e){this.emit("debug",e)}_setResult(){let e;if(this.processExited){if(this.processError){e=new Error(`There was an error when attempting to execute the process '${this.toolPath}'. This may indicate the process failed to start. Error: ${this.processError}`)}else if(this.processExitCode!==0&&!this.options.ignoreReturnCode){e=new Error(`The process '${this.toolPath}' failed with exit code ${this.processExitCode}`)}else if(this.processStderr&&this.options.failOnStdErr){e=new Error(`The process '${this.toolPath}' failed because one or more lines were written to the STDERR stream`)}}if(this.timeout){clearTimeout(this.timeout);this.timeout=null}this.done=true;this.emit("done",e,this.processExitCode)}static HandleTimeout(e){if(e.done){return}if(!e.processClosed&&e.processExited){const t=`The STDIO streams did not close within ${e.delay/1e3} seconds of the exit event from process '${e.toolPath}'. This may indicate a child process inherited the STDIO streams and has not yet exited.`;e._debug(t)}e._setResult()}}},52:function(e,t,i){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var i in e)if(Object.hasOwnProperty.call(e,i))t[i]=e[i];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const r=n(i(470));function getInput(e,t){const i=e.replace(/-/g,"_");let n=r.getInput(i,t);if(n.length>0){return n}return r.getInput(e,t)}t.getInput=getInput;function getInputBool(e,t){const i=getInput(e,t);if(i&&(i==="true"||i==="1")){return true}else{return false}}t.getInputBool=getInputBool},87:function(e){e.exports=require("os")},129:function(e){e.exports=require("child_process")},131:function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){function adopt(e){return e instanceof i?e:new i(function(t){t(e)})}return new(i||(i=Promise))(function(i,r){function fulfilled(e){try{step(n.next(e))}catch(e){r(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){r(e)}}function step(e){e.done?i(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())})};var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var i in e)if(Object.hasOwnProperty.call(e,i))t[i]=e[i];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const s=i(622);const o=r(i(470));const u=r(i(265));const c=i(473);function run(e){return n(this,void 0,void 0,function*(){let t;if(e.useCross){t=yield c.Cross.getOrInstall()}else{t=yield c.Cargo.get()}let i=[];if(e.toolchain){i.push(`+${e.toolchain}`)}i.push(e.command);i=i.concat(e.args);yield t.call(i)})}t.run=run;function main(){return n(this,void 0,void 0,function*(){const e=s.join(__dirname,".matchers");console.log(`##[add-matcher]${s.join(e,"rust.json")}`);const t=u.get();try{yield run(t)}catch(e){o.setFailed(e.message)}})}main()},265:function(e,t,i){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});const r=i(473);const s=n(i(982));function get(){const e=r.input.getInput("command",{required:true});const t=s.default(r.input.getInput("args"));let i=r.input.getInput("toolchain");if(i.startsWith("+")){i=i.slice(1)}const n=r.input.getInputBool("use-cross");return{command:e,args:t,useCross:n,toolchain:i||undefined}}t.get=get},357:function(e){e.exports=require("assert")},396:function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){function adopt(e){return e instanceof i?e:new i(function(t){t(e)})}return new(i||(i=Promise))(function(i,r){function fulfilled(e){try{step(n.next(e))}catch(e){r(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){r(e)}}function step(e){e.done?i(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())})};var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var i in e)if(Object.hasOwnProperty.call(e,i))t[i]=e[i];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const s=r(i(1));const o=r(i(470));const u=r(i(986));class Cargo{constructor(e){this.path=e}static get(){return n(this,void 0,void 0,function*(){try{const e=yield s.which("cargo",true);return new Cargo(e)}catch(e){o.info("cargo is not installed by default for some virtual environments, see https://help.github.com/en/articles/software-in-virtual-environments-for-github-actions");o.info("To install it, use this action: https://github.com/actions-rs/toolchain");throw e}})}call(e,t){return n(this,void 0,void 0,function*(){return yield u.exec(this.path,e,t)})}}t.Cargo=Cargo},403:function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){function adopt(e){return e instanceof i?e:new i(function(t){t(e)})}return new(i||(i=Promise))(function(i,r){function fulfilled(e){try{step(n.next(e))}catch(e){r(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){r(e)}}function step(e){e.done?i(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())})};var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var i in e)if(Object.hasOwnProperty.call(e,i))t[i]=e[i];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const s=i(87);const o=r(i(1));const u=r(i(470));const c=r(i(986));const l=i(396);class Cross{constructor(e){this.path=e}static getOrInstall(){return n(this,void 0,void 0,function*(){try{return yield Cross.get()}catch(e){u.debug(`Unable to find "cross" executable, installing it now. Reason: ${e}`);return yield Cross.install()}})}static get(){return n(this,void 0,void 0,function*(){const e=yield o.which("cross",true);return new Cross(e)})}static install(e){return n(this,void 0,void 0,function*(){const t=yield l.Cargo.get();const i=process.cwd();process.chdir(s.tmpdir());try{u.startGroup("Installing cross");let n=["install"];if(e&&e!="latest"){n.push("--version");n.push(e)}n.push("cross");yield t.call(n);return new Cross("cross")}finally{process.chdir(i);u.endGroup()}})}call(e,t){return n(this,void 0,void 0,function*(){return yield c.exec(this.path,e,t)})}}t.Cross=Cross},431:function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:true});const n=i(87);function issueCommand(e,t,i){const r=new Command(e,t,i);process.stdout.write(r.toString()+n.EOL)}t.issueCommand=issueCommand;function issue(e,t=""){issueCommand(e,{},t)}t.issue=issue;const r="::";class Command{constructor(e,t,i){if(!e){e="missing.command"}this.command=e;this.properties=t;this.message=i}toString(){let e=r+this.command;if(this.properties&&Object.keys(this.properties).length>0){e+=" ";for(const t in this.properties){if(this.properties.hasOwnProperty(t)){const i=this.properties[t];if(i){e+=`${t}=${escape(`${i||""}`)},`}}}}e+=r;const t=`${this.message||""}`;e+=escapeData(t);return e}}function escapeData(e){return e.replace(/\r/g,"%0D").replace(/\n/g,"%0A")}function escape(e){return e.replace(/\r/g,"%0D").replace(/\n/g,"%0A").replace(/]/g,"%5D").replace(/;/g,"%3B")}},470:function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){function adopt(e){return e instanceof i?e:new i(function(t){t(e)})}return new(i||(i=Promise))(function(i,r){function fulfilled(e){try{step(n.next(e))}catch(e){r(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){r(e)}}function step(e){e.done?i(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:true});const r=i(431);const s=i(87);const o=i(622);var u;(function(e){e[e["Success"]=0]="Success";e[e["Failure"]=1]="Failure"})(u=t.ExitCode||(t.ExitCode={}));function exportVariable(e,t){process.env[e]=t;r.issueCommand("set-env",{name:e},t)}t.exportVariable=exportVariable;function exportSecret(e,t){exportVariable(e,t);r.issueCommand("set-secret",{},t);throw new Error("Not implemented.")}t.exportSecret=exportSecret;function addPath(e){r.issueCommand("add-path",{},e);process.env["PATH"]=`${e}${o.delimiter}${process.env["PATH"]}`}t.addPath=addPath;function getInput(e,t){const i=process.env[`INPUT_${e.replace(/ /g,"_").toUpperCase()}`]||"";if(t&&t.required&&!i){throw new Error(`Input required and not supplied: ${e}`)}return i.trim()}t.getInput=getInput;function setOutput(e,t){r.issueCommand("set-output",{name:e},t)}t.setOutput=setOutput;function setFailed(e){process.exitCode=u.Failure;error(e)}t.setFailed=setFailed;function debug(e){r.issueCommand("debug",{},e)}t.debug=debug;function error(e){r.issue("error",e)}t.error=error;function warning(e){r.issue("warning",e)}t.warning=warning;function info(e){process.stdout.write(e+s.EOL)}t.info=info;function startGroup(e){r.issue("group",e)}t.startGroup=startGroup;function endGroup(){r.issue("endgroup")}t.endGroup=endGroup;function group(e,t){return n(this,void 0,void 0,function*(){startGroup(e);let i;try{i=yield t()}finally{endGroup()}return i})}t.group=group},473:function(e,t,i){"use strict";function __export(e){for(var i in e)if(!t.hasOwnProperty(i))t[i]=e[i]}var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var i in e)if(Object.hasOwnProperty.call(e,i))t[i]=e[i];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});__export(i(396));__export(i(403));const r=n(i(52));t.input=r},614:function(e){e.exports=require("events")},622:function(e){e.exports=require("path")},669:function(e){e.exports=require("util")},672:function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){function adopt(e){return e instanceof i?e:new i(function(t){t(e)})}return new(i||(i=Promise))(function(i,r){function fulfilled(e){try{step(n.next(e))}catch(e){r(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){r(e)}}function step(e){e.done?i(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())})};var r;Object.defineProperty(t,"__esModule",{value:true});const s=i(357);const o=i(747);const u=i(622);r=o.promises,t.chmod=r.chmod,t.copyFile=r.copyFile,t.lstat=r.lstat,t.mkdir=r.mkdir,t.readdir=r.readdir,t.readlink=r.readlink,t.rename=r.rename,t.rmdir=r.rmdir,t.stat=r.stat,t.symlink=r.symlink,t.unlink=r.unlink;t.IS_WINDOWS=process.platform==="win32";function exists(e){return n(this,void 0,void 0,function*(){try{yield t.stat(e)}catch(e){if(e.code==="ENOENT"){return false}throw e}return true})}t.exists=exists;function isDirectory(e,i=false){return n(this,void 0,void 0,function*(){const n=i?yield t.stat(e):yield t.lstat(e);return n.isDirectory()})}t.isDirectory=isDirectory;function isRooted(e){e=normalizeSeparators(e);if(!e){throw new Error('isRooted() parameter "p" cannot be empty')}if(t.IS_WINDOWS){return e.startsWith("\\")||/^[A-Z]:/i.test(e)}return e.startsWith("/")}t.isRooted=isRooted;function mkdirP(e,i=1e3,r=1){return n(this,void 0,void 0,function*(){s.ok(e,"a path argument must be provided");e=u.resolve(e);if(r>=i)return t.mkdir(e);try{yield t.mkdir(e);return}catch(n){switch(n.code){case"ENOENT":{yield mkdirP(u.dirname(e),i,r+1);yield t.mkdir(e);return}default:{let i;try{i=yield t.stat(e)}catch(e){throw n}if(!i.isDirectory())throw n}}}})}t.mkdirP=mkdirP;function tryGetExecutablePath(e,i){return n(this,void 0,void 0,function*(){let n=undefined;try{n=yield t.stat(e)}catch(t){if(t.code!=="ENOENT"){console.log(`Unexpected error attempting to determine if executable file exists '${e}': ${t}`)}}if(n&&n.isFile()){if(t.IS_WINDOWS){const t=u.extname(e).toUpperCase();if(i.some(e=>e.toUpperCase()===t)){return e}}else{if(isUnixExecutable(n)){return e}}}const r=e;for(const s of i){e=r+s;n=undefined;try{n=yield t.stat(e)}catch(t){if(t.code!=="ENOENT"){console.log(`Unexpected error attempting to determine if executable file exists '${e}': ${t}`)}}if(n&&n.isFile()){if(t.IS_WINDOWS){try{const i=u.dirname(e);const n=u.basename(e).toUpperCase();for(const r of yield t.readdir(i)){if(n===r.toUpperCase()){e=u.join(i,r);break}}}catch(t){console.log(`Unexpected error attempting to determine the actual case of the file '${e}': ${t}`)}return e}else{if(isUnixExecutable(n)){return e}}}}return""})}t.tryGetExecutablePath=tryGetExecutablePath;function normalizeSeparators(e){e=e||"";if(t.IS_WINDOWS){e=e.replace(/\//g,"\\");return e.replace(/\\\\+/g,"\\")}return e.replace(/\/\/+/g,"/")}function isUnixExecutable(e){return(e.mode&1)>0||(e.mode&8)>0&&e.gid===process.getgid()||(e.mode&64)>0&&e.uid===process.getuid()}},747:function(e){e.exports=require("fs")},982:function(e,t){"use strict";t.__esModule=true;function parseArgsStringToArgv(e,t,i){var n=/([^\s'"]([^\s'"]*(['"])([^\3]*?)\3)+[^\s'"]*)|[^\s'"]+|(['"])([^\5]*?)\5/gi;var r=e;var s=[];if(t){s.push(t)}if(i){s.push(i)}var o;do{o=n.exec(r);if(o!==null){s.push(firstString(o[1],o[6],o[0]))}}while(o!==null);return s}t["default"]=parseArgsStringToArgv;t.parseArgsStringToArgv=parseArgsStringToArgv;function firstString(){var e=[];for(var t=0;t 0) { - return value - } - - return core.getInput(name) -} - -function getInputBool(name: string): boolean { - const value = getInput(name); - if (value && (value == 'true' || value == '1')) { - return true; - } else { - return false; - } -} - - // Parsed action input export interface Input { command: string, @@ -41,14 +14,14 @@ export interface Input { useCross: boolean, } -export function parse(): Input { - const command = getInput('command'); - const args = stringArgv(getInput('args')); - let toolchain = getInput('toolchain'); +export function get(): Input { + const command = input.getInput('command', {required: true}); + const args = stringArgv(input.getInput('args')); + let toolchain = input.getInput('toolchain'); if (toolchain.startsWith('+')) { toolchain = toolchain.slice(1); } - const useCross = getInputBool('use-cross'); + const useCross = input.getInputBool('use-cross'); return { command: command, diff --git a/src/main.ts b/src/main.ts index d83825f..a6b3eec 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,79 +1,16 @@ -const os = require('os'); -const process = require('process'); +const path = require('path'); import * as core from '@actions/core'; -import * as exec from '@actions/exec'; -import * as io from '@actions/io'; import * as input from './input'; +import {Cargo, Cross} from '@actions-rs/core'; -const CROSS_REV: string = '69b8da7da287055127812c9e4b071756c2b98545'; - -async function getCargo(): Promise { - try { - return await io.which('cargo', true); - } catch (error) { - core.info('cargo is not installed by default for some virtual environments, \ -see https://help.github.com/en/articles/software-in-virtual-environments-for-github-actions'); - core.info('To install it, use this action: https://github.com/actions-rs/toolchain'); - - throw error; - } -} - -async function getCross(cargoPath: string): Promise { - try { - return await io.which('cross', true); - } catch (error) { - core.debug('Unable to find cross, installing it now'); - } - - // Somewhat new Rust is required to compile `cross` - // (TODO: Not sure what version exactly, should clarify) - // but if some action will set an override toolchain before this action called - // (ex. `@actions-rs/toolchain` with `toolchain: 1.31.0`) - // `cross` compilation will fail. - // - // In order to skip this problem and install `cross` globally - // using the pre-installed system Rust, - // we are going to jump to the tmpdir (skipping directory override that way) - // install `cross` from there and then jump back. - - const cwd = process.cwd(); - process.chdir(os.tmpdir()); - - try { - core.startGroup('Install cross'); - core.warning('Git version of cross will be installed, \ -see https://github.com/actions-rs/cargo/issues/1'); - await exec.exec(cargoPath, [ - 'install', - '--rev', - CROSS_REV, - '--git', - 'https://github.com/rust-embedded/cross.git' - ]); - } catch (error) { - throw error; - } finally { - // It is important to chdir back! - process.chdir(cwd); - core.endGroup(); - } - - // Expecting it to be in PATH already - return 'cross'; -} - -async function run(): Promise { - const actionInput = input.parse(); - const cargo = await getCargo(); - +export async function run(actionInput: input.Input): Promise { let program; if (actionInput.useCross) { - program = await getCross(cargo); + program = await Cross.getOrInstall(); } else { - program = cargo; + program = await Cargo.get(); } let args: string[] = []; @@ -83,12 +20,17 @@ async function run(): Promise { args.push(actionInput.command); args = args.concat(actionInput.args); - await exec.exec(program, args); + await program.call(args); } async function main(): Promise { + const matchersPath = path.join(__dirname, '.matchers'); + console.log(`##[add-matcher]${path.join(matchersPath, 'rust.json')}`); + + const actionInput = input.get(); + try { - await run(); + await run(actionInput); } catch (error) { core.setFailed(error.message); } diff --git a/tsconfig.json b/tsconfig.json index 960dc9f..5ddd6b6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,7 +4,7 @@ // "incremental": true, /* Enable incremental compilation */ "target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ - // "allowJs": true, /* Allow javascript files to be compiled. */ + "allowJs": false, /* Allow javascript files to be compiled. */ // "checkJs": true, /* Report errors in .js files. */ // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ // "declaration": true, /* Generates corresponding '.d.ts' file. */ @@ -32,10 +32,10 @@ // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ /* Additional Checks */ - // "noUnusedLocals": true, /* Report errors on unused locals. */ - // "noUnusedParameters": true, /* Report errors on unused parameters. */ - // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ - // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + "noUnusedLocals": true, /* Report errors on unused locals. */ + "noUnusedParameters": true, /* Report errors on unused parameters. */ + "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ /* Module Resolution Options */ // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */