From 2d1ee0acb9c4f656ec9128fc7387d82ac4539816 Mon Sep 17 00:00:00 2001 From: Luca <681992+lukka@users.noreply.github.com> Date: Sat, 4 Feb 2023 17:07:17 -0800 Subject: [PATCH] cmake's workflow support (#103) --- README.md | 10 ++ __tests__/functional.test.ts | 14 +- __tests__/theAssets/CMakePresets.json | 17 +- __tests__/unit.test.ts | 2 +- action.yml | 12 +- dist/index.js | 223 ++++++++++++++++---------- package-lock.json | 124 +++++++------- package.json | 10 +- src/cmake-action.ts | 5 +- 9 files changed, 256 insertions(+), 161 deletions(-) diff --git a/README.md b/README.md index 678d775..25769f7 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,10 @@ jobs: # located elsewhere. # cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt' + # You could use CMake workflow presets defined in the CMakePresets.json + # with just this line below. + # workflowPreset: 'workflow-name' + # This is the name of the CMakePresets.json's configuration to use to generate # the project files. This configuration leverages the vcpkg.cmake toolchain file to # run vcpkg and install all dependencies specified in vcpkg.json. @@ -132,6 +136,12 @@ Flowchart with related input in [action.yml](https://github.com/lukka/run-cmake/ ``` ┌───────────────────────────┐ ┌───────────────────────────┐ +│ ├─────►│ and then exit │ - `cmakeListsTxtPath` +└─────────────┬─────────────┘ └─────────────┬─────────────┘ - `workflowPreset` + │ No ⬬ - `workflowPresetCmdString` + ▼ +┌───────────────────────────┐ ┌───────────────────────────┐ │ ├─────►│ and CC and CXX undefined> │ - `runVcpkgEnvFormatString` └─────────────┬─────────────┘ │ run `vcpkg env` to set │ - `configurePresetAdditionalArgs` diff --git a/__tests__/functional.test.ts b/__tests__/functional.test.ts index 17f2266..0af5428 100644 --- a/__tests__/functional.test.ts +++ b/__tests__/functional.test.ts @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2020-2021 Luca Cappa +// Copyright (c) 2019-2020-2021-2023 Luca Cappa // Released under the term specified in file LICENSE.txt // SPDX short identifier: MIT @@ -99,6 +99,18 @@ describe('run-cmake functional tests', () => { console.log(cp.execSync(`node ${testScript}`, options)?.toString()); }); + test('run workflow', () => { + process.env.INPUT_WORKFLOWPRESET = "default-workflow"; + process.env.INPUT_BUILDPRESET = "default-multi"; // Must be ignored + process.env.INPUT_TESTPRESET = "default-multi"; // Must be ignored + process.env.INPUT_CMAKELISTSTXTPATH = path.join(assetDirectory, 'CMakeLists.txt'); + const options: cp.ExecSyncOptions = { + env: process.env, + stdio: "inherit" + }; + console.log(cp.execSync(`node ${testScript}`, options)?.toString()); + }); + test('basic test for environment variables in input, no shell, it must throw', () => { // Building will use an environment variable that will not be // resolved since not being run inside a shell, and it will throw. diff --git a/__tests__/theAssets/CMakePresets.json b/__tests__/theAssets/CMakePresets.json index 26969a9..fe63ded 100644 --- a/__tests__/theAssets/CMakePresets.json +++ b/__tests__/theAssets/CMakePresets.json @@ -1,5 +1,5 @@ { - "version": 3, + "version": 6, "cmakeMinimumRequired": { "major": 3, "minor": 21, @@ -52,5 +52,20 @@ "name": "default-multi", "configurePreset": "default-multi" } + ], + "workflowPresets": [ + { + "name": "default-workflow", + "steps": [ + { + "type": "configure", + "name": "default-multi" + }, + { + "type": "build", + "name": "default-multi" + } + ] + } ] } \ No newline at end of file diff --git a/__tests__/unit.test.ts b/__tests__/unit.test.ts index b672b33..9604bfd 100644 --- a/__tests__/unit.test.ts +++ b/__tests__/unit.test.ts @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2020-2021 Luca Cappa +// Copyright (c) 2019-2020-2021-2022-2023 Luca Cappa // Released under the term specified in file LICENSE.txt // SPDX short identifier: MIT diff --git a/action.yml b/action.yml index 386818b..49a0df2 100644 --- a/action.yml +++ b/action.yml @@ -1,4 +1,4 @@ -# Copyright (c) 2019-2020-2021 Luca Cappa +# Copyright (c) 2019-2020-2021-2023 Luca Cappa # Released under the term specified in file LICENSE.txt # SPDX short identifier: MIT @@ -12,10 +12,14 @@ inputs: default: "${{ github.workspace }}/CMakeLists.txt" required: false description: "Path to CMakeLists.txt." + workflowPreset: + default: "" + required: false + description: "The name of the workflow preset. Optional. This value is stored in the WORKFLOW_PRESET_NAME environment variable, and used by the default value of 'workflowPresetCmdString' input." configurePreset: default: "" required: false - description: "The name of the configure preset. Required. This value is stored in the CONFIGURE_PRESET_NAME environment variable, and used by the default value of 'configurePresetCmdString' input." + description: "The name of the configure preset. Optional. This value is stored in the CONFIGURE_PRESET_NAME environment variable, and used by the default value of 'configurePresetCmdString' input." buildPreset: default: "" required: false @@ -46,6 +50,10 @@ inputs: default: "\\s*\"(.+CMakeOutput\\.log)\"\\.\\s*;\\s*\"(.+CMakeError\\.log)\"\\.\\s*;\\s*(.+out\\.log)\\s*;\\s+(.+err\\.log)\\s*;\\s*(.+vcpkg.+\\.log)\\s*" required: false description: "Specifies a semicolon separated list of regular expressions that are used to identify log file paths in the workflow output. A regular expression must have a single capturing group, that is a single pair of parenthesis such as 'See also (.+.log)'. When a match occurs, the content of the file is written into the workflow output for disclosing its content to the user. The default regular expressions are for CMake's and vcpkg's log files." + workflowPresetCmdString: + default: "[`--workflow`, `--preset`, `$[env.WORKFLOW_PRESET_NAME]`, `--fresh`]" + required: false + description: "The CMake command format string to run the workflow steps." configurePresetCmdString: default: "[`--preset`, `$[env.CONFIGURE_PRESET_NAME]`]" required: false diff --git a/dist/index.js b/dist/index.js index b7ac88d..9ed6b1f 100644 --- a/dist/index.js +++ b/dist/index.js @@ -6,7 +6,7 @@ "use strict"; -// Copyright (c) 2019-2020-2021-2022 Luca Cappa +// Copyright (c) 2019-2020-2021-2022-2023 Luca Cappa // Released under the term specified in file LICENSE.txt // SPDX short identifier: MIT var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { @@ -32,6 +32,8 @@ function main() { const configurePreset = actionLib.getInput(cmakeglobals.configurePreset, false); const buildPreset = actionLib.getInput(cmakeglobals.buildPreset, false); const testPreset = actionLib.getInput(cmakeglobals.testPreset, false); + const workflowPreset = actionLib.getInput(cmakeglobals.workflowPreset, false); + const workflowPresetCmdStringFormat = actionLib.getInput(cmakeglobals.workflowPresetFormat, false); const configurePresetCmdStringFormat = actionLib.getInput(cmakeglobals.configurePresetFormat, false); const buildPresetCmdStringFormat = actionLib.getInput(cmakeglobals.buildPresetFormat, false); const testPresetCmdStringFormat = actionLib.getInput(cmakeglobals.testPresetFormat, false); @@ -39,7 +41,7 @@ function main() { const buildPresetAdditionalArgs = actionLib.getInput(cmakeglobals.buildPresetAdditionalArgs, false); const testPresetAdditionalArgs = actionLib.getInput(cmakeglobals.testPresetAdditionalArgs, false); const runVcpkgEnvFormatString = actionLib.getInput(vcpkgglobals.runVcpkgEnvFormatStringInput, false); - yield runcmakelib.CMakeRunner.run(actionLib, configurePreset, configurePresetCmdStringFormat, configurePresetAdditionalArgs, buildPreset, buildPresetCmdStringFormat, buildPresetAdditionalArgs, testPreset, testPresetCmdStringFormat, testPresetAdditionalArgs, runVcpkgEnvFormatString); + yield runcmakelib.CMakeRunner.run(actionLib, workflowPreset, workflowPresetCmdStringFormat, configurePreset, configurePresetCmdStringFormat, configurePresetAdditionalArgs, buildPreset, buildPresetCmdStringFormat, buildPresetAdditionalArgs, testPreset, testPresetCmdStringFormat, testPresetAdditionalArgs, runVcpkgEnvFormatString); actionLib.info('run-cmake action execution succeeded'); process.exitCode = 0; } @@ -5131,18 +5133,20 @@ __exportStar(__nccwpck_require__(9604), exports); "use strict"; -// Copyright (c) 2019-2020-2021-2022 Luca Cappa +// Copyright (c) 2019-2020-2021-2022-2023 Luca Cappa // Released under the term specified in file LICENSE.txt // SPDX short identifier: MIT Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.logCollectionRegExps = exports.testPresetAdditionalArgs = exports.buildPresetAdditionalArgs = exports.configurePresetAdditionalArgs = exports.testPresetFormat = exports.buildPresetFormat = exports.configurePresetFormat = exports.testPreset = exports.buildPreset = exports.configurePreset = exports.cmakeListsTxtPath = void 0; +exports.logCollectionRegExps = exports.testPresetAdditionalArgs = exports.buildPresetAdditionalArgs = exports.configurePresetAdditionalArgs = exports.workflowPresetFormat = exports.testPresetFormat = exports.buildPresetFormat = exports.configurePresetFormat = exports.workflowPreset = exports.testPreset = exports.buildPreset = exports.configurePreset = exports.cmakeListsTxtPath = void 0; exports.cmakeListsTxtPath = 'cmakeListsTxtPath'; exports.configurePreset = 'configurePreset'; exports.buildPreset = 'buildPreset'; exports.testPreset = 'testPreset'; +exports.workflowPreset = 'workflowPreset'; exports.configurePresetFormat = 'configurePresetCmdString'; exports.buildPresetFormat = 'buildPresetCmdString'; exports.testPresetFormat = 'testPresetCmdString'; +exports.workflowPresetFormat = 'workflowPresetCmdString'; exports.configurePresetAdditionalArgs = 'configurePresetAdditionalArgs'; exports.buildPresetAdditionalArgs = 'buildPresetAdditionalArgs'; exports.testPresetAdditionalArgs = 'testPresetAdditionalArgs'; @@ -5156,7 +5160,7 @@ exports.logCollectionRegExps = 'logCollectionRegExps'; "use strict"; -// Copyright (c) 2019-2020-2021-2022 Luca Cappa +// Copyright (c) 2019-2020-2021-2022-2023 Luca Cappa // Released under the term specified in file LICENSE.txt // SPDX short identifier: MIT var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { @@ -5196,9 +5200,11 @@ const using_statement_1 = __nccwpck_require__(8515); const cmakeutil = __importStar(__nccwpck_require__(4067)); const runvcpkglib = __importStar(__nccwpck_require__(4393)); class CMakeRunner { - constructor(baseLib, configurePreset = null, configurePresetCmdStringFormat = CMakeRunner.configurePresetDefault, configurePresetCmdStringAddArgs = null, buildPreset = null, buildPresetCmdStringFormat = CMakeRunner.buildPresetDefault, buildPresetCmdStringAddArgs = null, testPreset = null, testPresetCmdStringFormat = CMakeRunner.testPresetDefault, testPresetCmdStringAddArgs = null, vcpkgEnvStringFormat = CMakeRunner.vcpkgEnvDefault) { + constructor(baseLib, workflowPreset = null, workflowPresetCmdStringFormat = CMakeRunner.workflowPresetDefault, configurePreset = null, configurePresetCmdStringFormat = CMakeRunner.configurePresetDefault, configurePresetCmdStringAddArgs = null, buildPreset = null, buildPresetCmdStringFormat = CMakeRunner.buildPresetDefault, buildPresetCmdStringAddArgs = null, testPreset = null, testPresetCmdStringFormat = CMakeRunner.testPresetDefault, testPresetCmdStringAddArgs = null, vcpkgEnvStringFormat = CMakeRunner.vcpkgEnvDefault) { var _a, _b, _c; this.baseLib = baseLib; + this.workflowPreset = workflowPreset; + this.workflowPresetCmdStringFormat = workflowPresetCmdStringFormat; this.configurePreset = configurePreset; this.configurePresetCmdStringFormat = configurePresetCmdStringFormat; this.configurePresetCmdStringAddArgs = configurePresetCmdStringAddArgs; @@ -5216,10 +5222,10 @@ class CMakeRunner { this.cmakeSourceDir = path.dirname((_c = baseutillib.BaseUtilLib.normalizePath(this.cmakeListsTxtPath)) !== null && _c !== void 0 ? _c : ""); baseutillib.BaseUtilLib.throwIfNull(this.cmakeSourceDir, cmakeglobals.cmakeListsTxtPath); } - static run(baseLib, configurePreset, configurePresetCmdStringFormat, configurePresetCmdStringAddArgs, buildPreset, buildPresetCmdStringFormat, buildPresetCmdStringAddArgs, testPreset, testPresetCmdStringFormat, testPresetCmdStringAddArgs, vcpkgEnvCmdStringFormat) { + static run(baseLib, workflowPreset, workflowPresetCmdStringFormat, configurePreset, configurePresetCmdStringFormat, configurePresetCmdStringAddArgs, buildPreset, buildPresetCmdStringFormat, buildPresetCmdStringAddArgs, testPreset, testPresetCmdStringFormat, testPresetCmdStringAddArgs, vcpkgEnvCmdStringFormat) { return __awaiter(this, void 0, void 0, function* () { yield using_statement_1.using(baseutillib.Matcher.createMatcher('all', baseLib, __dirname), () => __awaiter(this, void 0, void 0, function* () { - const cmakeRunner = new CMakeRunner(baseLib, configurePreset, configurePresetCmdStringFormat, configurePresetCmdStringAddArgs, buildPreset, buildPresetCmdStringFormat, buildPresetCmdStringAddArgs, testPreset, testPresetCmdStringFormat, testPresetCmdStringAddArgs, vcpkgEnvCmdStringFormat); + const cmakeRunner = new CMakeRunner(baseLib, workflowPreset, workflowPresetCmdStringFormat, configurePreset, configurePresetCmdStringFormat, configurePresetCmdStringAddArgs, buildPreset, buildPresetCmdStringFormat, buildPresetCmdStringAddArgs, testPreset, testPresetCmdStringFormat, testPresetCmdStringAddArgs, vcpkgEnvCmdStringFormat); yield cmakeRunner.run(); })); }); @@ -5231,17 +5237,23 @@ class CMakeRunner { this.baseLib.debug(`cmake located at: '${cmake}'.`); const ctest = yield this.baseLib.which('ctest', true); this.baseLib.debug(`ctest located at: '${ctest}'.`); - if (this.configurePreset) { - const configureTool = this.baseLib.tool(cmake); - yield this.configure(configureTool, this.configurePreset); + if (this.workflowPreset) { + const workflowTool = this.baseLib.tool(cmake); + yield this.workflow(workflowTool, this.workflowPreset); } - if (this.buildPreset) { - const buildTool = this.baseLib.tool(cmake); - yield this.build(buildTool, this.buildPreset); - } - if (this.testPreset) { - const testTool = this.baseLib.tool(ctest); - yield this.test(testTool, this.testPreset); + else { + if (this.configurePreset) { + const configureTool = this.baseLib.tool(cmake); + yield this.configure(configureTool, this.configurePreset); + } + if (this.buildPreset) { + const buildTool = this.baseLib.tool(cmake); + yield this.build(buildTool, this.buildPreset); + } + if (this.testPreset) { + const testTool = this.baseLib.tool(ctest); + yield this.test(testTool, this.testPreset); + } } this.baseLib.debug('run()>>'); }); @@ -5280,7 +5292,6 @@ class CMakeRunner { return __awaiter(this, void 0, void 0, function* () { this.baseLib.debug('configure()<<'); baseutillib.setEnvVarIfUndefined("CONFIGURE_PRESET_NAME", configurePresetName); - const args = baseutillib.replaceFromEnvVar(this.configurePresetCmdStringFormat); CMakeRunner.addArguments(cmake, this.configurePresetCmdStringFormat); if (this.configurePresetCmdStringAddArgs) { CMakeRunner.addArguments(cmake, this.configurePresetCmdStringAddArgs); @@ -5319,6 +5330,17 @@ class CMakeRunner { this.baseLib.debug('configure()>>'); }); } + workflow(cmake, workflowPresetName) { + return __awaiter(this, void 0, void 0, function* () { + this.baseLib.debug('workflow()<<'); + baseutillib.setEnvVarIfUndefined("WORKFLOW_PRESET_NAME", workflowPresetName); + CMakeRunner.addArguments(cmake, this.workflowPresetCmdStringFormat); + // + this.baseLib.debug(`Running the workflow preset named '${workflowPresetName}' ...`); + yield this.baseUtils.wrapOp(`Running workflow '${workflowPresetName}' with CMake`, () => __awaiter(this, void 0, void 0, function* () { return yield this.launchCMake(cmake, this.cmakeSourceDir, this.logFilesCollector); })); + this.baseLib.debug('workflow()>>'); + }); + } launchCMake(cmake, sourceDir, logCollector) { return __awaiter(this, void 0, void 0, function* () { const options = { @@ -5350,6 +5372,7 @@ class CMakeRunner { } } exports.CMakeRunner = CMakeRunner; +CMakeRunner.workflowPresetDefault = "[`--workflow`, `--preset`, `$[env.WORKFLOW_PRESET_NAME]`, `--fresh`]"; CMakeRunner.configurePresetDefault = "[`--preset`, `$[env.CONFIGURE_PRESET_NAME]`]"; CMakeRunner.buildPresetDefault = "[`--build`, `--preset`, `$[env.BUILD_PRESET_NAME]`]"; CMakeRunner.testPresetDefault = "[`--preset`, `$[env.TEST_PRESET_NAME]`]"; @@ -14686,10 +14709,10 @@ module.exports = micromatch; module.exports = minimatch minimatch.Minimatch = Minimatch -var path = { sep: '/' } -try { - path = __nccwpck_require__(1017) -} catch (er) {} +var path = (function () { try { return __nccwpck_require__(1017) } catch (e) {}}()) || { + sep: '/' +} +minimatch.sep = path.sep var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {} var expand = __nccwpck_require__(3717) @@ -14741,43 +14764,64 @@ function filter (pattern, options) { } function ext (a, b) { - a = a || {} b = b || {} var t = {} - Object.keys(b).forEach(function (k) { - t[k] = b[k] - }) Object.keys(a).forEach(function (k) { t[k] = a[k] }) + Object.keys(b).forEach(function (k) { + t[k] = b[k] + }) return t } minimatch.defaults = function (def) { - if (!def || !Object.keys(def).length) return minimatch + if (!def || typeof def !== 'object' || !Object.keys(def).length) { + return minimatch + } var orig = minimatch var m = function minimatch (p, pattern, options) { - return orig.minimatch(p, pattern, ext(def, options)) + return orig(p, pattern, ext(def, options)) } m.Minimatch = function Minimatch (pattern, options) { return new orig.Minimatch(pattern, ext(def, options)) } + m.Minimatch.defaults = function defaults (options) { + return orig.defaults(ext(def, options)).Minimatch + } + + m.filter = function filter (pattern, options) { + return orig.filter(pattern, ext(def, options)) + } + + m.defaults = function defaults (options) { + return orig.defaults(ext(def, options)) + } + + m.makeRe = function makeRe (pattern, options) { + return orig.makeRe(pattern, ext(def, options)) + } + + m.braceExpand = function braceExpand (pattern, options) { + return orig.braceExpand(pattern, ext(def, options)) + } + + m.match = function (list, pattern, options) { + return orig.match(list, pattern, ext(def, options)) + } return m } Minimatch.defaults = function (def) { - if (!def || !Object.keys(def).length) return Minimatch return minimatch.defaults(def).Minimatch } function minimatch (p, pattern, options) { - if (typeof pattern !== 'string') { - throw new TypeError('glob pattern string required') - } + assertValidPattern(pattern) if (!options) options = {} @@ -14786,9 +14830,6 @@ function minimatch (p, pattern, options) { return false } - // "" only matches "" - if (pattern.trim() === '') return p === '' - return new Minimatch(pattern, options).match(p) } @@ -14797,15 +14838,14 @@ function Minimatch (pattern, options) { return new Minimatch(pattern, options) } - if (typeof pattern !== 'string') { - throw new TypeError('glob pattern string required') - } + assertValidPattern(pattern) if (!options) options = {} + pattern = pattern.trim() // windows support: need to use /, not \ - if (path.sep !== '/') { + if (!options.allowWindowsEscape && path.sep !== '/') { pattern = pattern.split(path.sep).join('/') } @@ -14816,6 +14856,7 @@ function Minimatch (pattern, options) { this.negate = false this.comment = false this.empty = false + this.partial = !!options.partial // make the set of regexps etc. this.make() @@ -14825,9 +14866,6 @@ Minimatch.prototype.debug = function () {} Minimatch.prototype.make = make function make () { - // don't do it more than once. - if (this._made) return - var pattern = this.pattern var options = this.options @@ -14847,7 +14885,7 @@ function make () { // step 2: expand braces var set = this.globSet = this.braceExpand() - if (options.debug) this.debug = console.error + if (options.debug) this.debug = function debug() { console.error.apply(console, arguments) } this.debug(this.pattern, set) @@ -14927,12 +14965,11 @@ function braceExpand (pattern, options) { pattern = typeof pattern === 'undefined' ? this.pattern : pattern - if (typeof pattern === 'undefined') { - throw new TypeError('undefined pattern') - } + assertValidPattern(pattern) - if (options.nobrace || - !pattern.match(/\{.*\}/)) { + // Thanks to Yeting Li for + // improving this regexp to avoid a ReDOS vulnerability. + if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) { // shortcut. no need to expand. return [pattern] } @@ -14940,6 +14977,17 @@ function braceExpand (pattern, options) { return expand(pattern) } +var MAX_PATTERN_LENGTH = 1024 * 64 +var assertValidPattern = function (pattern) { + if (typeof pattern !== 'string') { + throw new TypeError('invalid pattern') + } + + if (pattern.length > MAX_PATTERN_LENGTH) { + throw new TypeError('pattern is too long') + } +} + // parse a component of the expanded set. // At this point, no pattern may contain "/" in it // so we're going to return a 2d array, where each entry is the full @@ -14954,14 +15002,17 @@ function braceExpand (pattern, options) { Minimatch.prototype.parse = parse var SUBPARSE = {} function parse (pattern, isSub) { - if (pattern.length > 1024 * 64) { - throw new TypeError('pattern is too long') - } + assertValidPattern(pattern) var options = this.options // shortcuts - if (!options.noglobstar && pattern === '**') return GLOBSTAR + if (pattern === '**') { + if (!options.noglobstar) + return GLOBSTAR + else + pattern = '*' + } if (pattern === '') return '' var re = '' @@ -15017,10 +15068,12 @@ function parse (pattern, isSub) { } switch (c) { - case '/': + /* istanbul ignore next */ + case '/': { // completely not allowed, even escaped. // Should already be path-split by now. return false + } case '\\': clearStateChar() @@ -15139,25 +15192,23 @@ function parse (pattern, isSub) { // handle the case where we left a class open. // "[z-a]" is valid, equivalent to "\[z-a\]" - if (inClass) { - // split where the last [ was, make sure we don't have - // an invalid re. if so, re-walk the contents of the - // would-be class to re-translate any characters that - // were passed through as-is - // TODO: It would probably be faster to determine this - // without a try/catch and a new RegExp, but it's tricky - // to do safely. For now, this is safe and works. - var cs = pattern.substring(classStart + 1, i) - try { - RegExp('[' + cs + ']') - } catch (er) { - // not a valid class! - var sp = this.parse(cs, SUBPARSE) - re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]' - hasMagic = hasMagic || sp[1] - inClass = false - continue - } + // split where the last [ was, make sure we don't have + // an invalid re. if so, re-walk the contents of the + // would-be class to re-translate any characters that + // were passed through as-is + // TODO: It would probably be faster to determine this + // without a try/catch and a new RegExp, but it's tricky + // to do safely. For now, this is safe and works. + var cs = pattern.substring(classStart + 1, i) + try { + RegExp('[' + cs + ']') + } catch (er) { + // not a valid class! + var sp = this.parse(cs, SUBPARSE) + re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]' + hasMagic = hasMagic || sp[1] + inClass = false + continue } // finish up the class. @@ -15241,9 +15292,7 @@ function parse (pattern, isSub) { // something that could conceivably capture a dot var addPatternStart = false switch (re.charAt(0)) { - case '.': - case '[': - case '(': addPatternStart = true + case '[': case '.': case '(': addPatternStart = true } // Hack to work around lack of negative lookbehind in JS @@ -15305,7 +15354,7 @@ function parse (pattern, isSub) { var flags = options.nocase ? 'i' : '' try { var regExp = new RegExp('^' + re + '$', flags) - } catch (er) { + } catch (er) /* istanbul ignore next - should be impossible */ { // If it was an invalid regular expression, then it can't match // anything. This trick looks for a character after the end of // the string, which is of course impossible, except in multi-line @@ -15363,7 +15412,7 @@ function makeRe () { try { this.regexp = new RegExp(re, flags) - } catch (ex) { + } catch (ex) /* istanbul ignore next - should be impossible */ { this.regexp = false } return this.regexp @@ -15381,8 +15430,8 @@ minimatch.match = function (list, pattern, options) { return list } -Minimatch.prototype.match = match -function match (f, partial) { +Minimatch.prototype.match = function match (f, partial) { + if (typeof partial === 'undefined') partial = this.partial this.debug('match', f, this.pattern) // short-circuit in the case of busted things. // comments, etc. @@ -15464,6 +15513,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) { // should be impossible. // some invalid regexp stuff in the set. + /* istanbul ignore if */ if (p === false) return false if (p === GLOBSTAR) { @@ -15537,6 +15587,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) { // no match was found. // However, in partial mode, we can't say this is necessarily over. // If there's more *pattern* left, then + /* istanbul ignore if */ if (partial) { // ran out of file this.debug('\n>>> no match, partial?', file, fr, pattern, pr) @@ -15550,11 +15601,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) { // patterns with magic have been turned into regexps. var hit if (typeof p === 'string') { - if (options.nocase) { - hit = f.toLowerCase() === p.toLowerCase() - } else { - hit = f === p - } + hit = f === p this.debug('string match', p, f, hit) } else { hit = f.match(p) @@ -15585,16 +15632,16 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) { // this is ok if we're doing the match as part of // a glob fs traversal. return partial - } else if (pi === pl) { + } else /* istanbul ignore else */ if (pi === pl) { // ran out of pattern, still have file left. // this is only acceptable if we're on the very last // empty segment of a file with a trailing slash. // a/* should match a/b/ - var emptyFileEnd = (fi === fl - 1) && (file[fi] === '') - return emptyFileEnd + return (fi === fl - 1) && (file[fi] === '') } // should be unreachable. + /* istanbul ignore next */ throw new Error('wtf?') } diff --git a/package-lock.json b/package-lock.json index cb1d6ee..832cd91 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,11 +13,11 @@ "@actions/exec": "^1.0.3", "@actions/github": "^4.0.0", "@actions/io": "^1.0.2", - "@lukka/action-lib": "3.1.0", - "@lukka/assets-lib": "3.1.0", - "@lukka/base-lib": "3.1.0", - "@lukka/base-util-lib": "3.1.0", - "@lukka/run-cmake-lib": "3.1.0", + "@lukka/action-lib": "3.3.0", + "@lukka/assets-lib": "3.3.0", + "@lukka/base-lib": "3.3.0", + "@lukka/base-util-lib": "3.3.0", + "@lukka/run-cmake-lib": "3.3.0", "@types/adm-zip": "^0.4.32", "@types/follow-redirects": "^1.8.0", "@types/jest": "^26.0.14", @@ -1620,9 +1620,9 @@ } }, "node_modules/@lukka/action-lib": { - "version": "3.1.0", - "resolved": "https://npm.pkg.github.com/download/@lukka/action-lib/3.1.0/547dcf612077fbef5447ee055d9e6c37dfa33010", - "integrity": "sha512-WvyTfGnmrsTWGKBdh9OrICt1Z/6uF1fLxrTFqoyKR5NmjUGfMHamTPjCDqQoaqv/3YRS+mNfAXsEJWFrntWmTQ==", + "version": "3.3.0", + "resolved": "https://npm.pkg.github.com/download/@lukka/action-lib/3.3.0/5fc4362eb61fa87848bcc0254116dbb6fc4dbde5", + "integrity": "sha512-hlvMtQUQkrlXVYRokf8kuL3ME4LOf9RFeKMJTm7MJrnQXSmDHbFj7F8IIJpr5LY2SH/69xcJg2LeNdV+mZLR0A==", "license": "MIT", "dependencies": { "@actions/core": "^1.9.1", @@ -1630,8 +1630,8 @@ "@actions/github": "^5.0.3", "@actions/glob": "^0.3.0", "@actions/io": "^1.1.2", - "@lukka/base-lib": "^3.1.0", - "@lukka/base-util-lib": "^3.1.0", + "@lukka/base-lib": "^3.3.0", + "@lukka/base-util-lib": "^3.3.0", "@types/adm-zip": "^0.4.32", "@types/follow-redirects": "^1.14.1", "@types/q": "^1.5.1", @@ -1840,15 +1840,15 @@ } }, "node_modules/@lukka/assets-lib": { - "version": "3.1.0", - "resolved": "https://npm.pkg.github.com/download/@lukka/assets-lib/3.1.0/27d49436aec9bde887e1f4d1036a36545383d4e9", - "integrity": "sha512-g0hOupvV3aCymY07BxqOgIh1L3/FxOGkdUMtCks1fdc06Q2C/OiTqIvN2Gvg6MEIDGF3uQDyCLTbooNa1CGitA==", + "version": "3.3.0", + "resolved": "https://npm.pkg.github.com/download/@lukka/assets-lib/3.3.0/e2f8697c6bd1449904adc4b89adf7c156b160843", + "integrity": "sha512-wb2046Pw/x1sNEgnyAS+qV5wIIWazeZGbCA0fqM7t0yMiV9wt9/Qlm6d9JhpVa7AQSgxDGvM6kOcJ/hIJP8+YA==", "license": "MIT" }, "node_modules/@lukka/base-lib": { - "version": "3.1.0", - "resolved": "https://npm.pkg.github.com/download/@lukka/base-lib/3.1.0/4ea1eb1965ac1b21fea993ba35b89ad1e5156ecb", - "integrity": "sha512-Fl6qUPD+RK0gFLPi10+am/0sEN8WbVRUmR43AhGhYJQiVAoMoue7icrztgdgWXxDvGDaaeMdQ4LbvvEOILMPfw==", + "version": "3.3.0", + "resolved": "https://npm.pkg.github.com/download/@lukka/base-lib/3.3.0/f2cb59d710f1ba9d3fbdb9381f8295da3695f5ec", + "integrity": "sha512-lY51MTUh/FO5Ey1hvVoejvhMIkZMN1h7PYt2CrhNzh2PlW6DTTuHc42gLlVa2Rqznmsn85bG8GTzg/kFhXHC3Q==", "license": "MIT", "dependencies": { "@types/adm-zip": "^0.4.32", @@ -2028,25 +2028,25 @@ } }, "node_modules/@lukka/base-util-lib": { - "version": "3.1.0", - "resolved": "https://npm.pkg.github.com/download/@lukka/base-util-lib/3.1.0/bd919a34e0388a62dabfb6e1326330e591216e52", - "integrity": "sha512-kVfMhgNXhFNe0CEAkIb0OhtiHtBodapLlXDGZz36su0FS1SMgS2JLZqr5zqyDOfuo//zpAjWCOM/TNSYgRNedQ==", + "version": "3.3.0", + "resolved": "https://npm.pkg.github.com/download/@lukka/base-util-lib/3.3.0/2d3c7da0654298ef8825b731737f7be8ee56abff", + "integrity": "sha512-oiLtNc0aK8H9rTA2oGl2rJkjEQArgcsToVBYFUloG3w9zAfJckjZPO2sEy2vHoqHrArykdOo3c2MjPvhGRu1xw==", "license": "MIT", "dependencies": { - "@lukka/base-lib": "^3.1.0", + "@lukka/base-lib": "^3.3.0", "fast-glob": "3.2.7" } }, "node_modules/@lukka/run-cmake-lib": { - "version": "3.1.0", - "resolved": "https://npm.pkg.github.com/download/@lukka/run-cmake-lib/3.1.0/51faaa45ce667b9f38214000e50516f9746c643b", - "integrity": "sha512-JC2dD6tBynGvthA8Txfro9s3LR+qHfp/nunA/Zh7qtenNsTn5NzLyov5nXuVM+J01y23OCc0/9sTBzWvwmU/XA==", + "version": "3.3.0", + "resolved": "https://npm.pkg.github.com/download/@lukka/run-cmake-lib/3.3.0/fc549e9d48db8c26fcce40ce92a11f634888ed88", + "integrity": "sha512-q/5w20gyMK1zHfccIqemAuF/H39yf0g56zzdccpyXAOfCt2KnydFE6kkYsqDkcXrw5EhZp5k34hQ9goMZhCZdQ==", "license": "MIT", "dependencies": { - "@lukka/action-lib": "^3.1.0", - "@lukka/base-lib": "^3.1.0", - "@lukka/base-util-lib": "^3.1.0", - "@lukka/run-vcpkg-lib": "^3.1.0", + "@lukka/action-lib": "^3.3.0", + "@lukka/base-lib": "^3.3.0", + "@lukka/base-util-lib": "^3.3.0", + "@lukka/run-vcpkg-lib": "^3.3.0", "@types/adm-zip": "^0.4.32", "@types/follow-redirects": "^1.14.1", "@types/q": "^1.5.1", @@ -2226,14 +2226,14 @@ } }, "node_modules/@lukka/run-vcpkg-lib": { - "version": "3.1.0", - "resolved": "https://npm.pkg.github.com/download/@lukka/run-vcpkg-lib/3.1.0/fb8b617f53d1997e479aa79b5bbc8eb4d585b2a9", - "integrity": "sha512-v+A+YxMLtT8bvLnMFpNfhsMTcMhZKMuGEGNzMqUR8zNDTwxArPUKRrptAtEL+Yxke5/kmhKz4w2CxK2EnKMvbQ==", + "version": "3.3.0", + "resolved": "https://npm.pkg.github.com/download/@lukka/run-vcpkg-lib/3.3.0/d9c931073f8c8ab8676ddda7b8d4c9841ddf0d45", + "integrity": "sha512-o7cjaynkY/B2uylcgL7CIjGZ2zUb2VmhuvKqgCvZz716c83TTXC2ZdRK8kfeky+ITjoFvGRA6UoWim4o4djqEw==", "license": "MIT", "dependencies": { - "@lukka/action-lib": "^3.1.0", - "@lukka/base-lib": "^3.1.0", - "@lukka/base-util-lib": "^3.1.0", + "@lukka/action-lib": "^3.3.0", + "@lukka/base-lib": "^3.3.0", + "@lukka/base-util-lib": "^3.3.0", "@types/adm-zip": "^0.4.32", "@types/follow-redirects": "^1.14.1", "@types/q": "^1.5.1", @@ -16349,17 +16349,17 @@ } }, "@lukka/action-lib": { - "version": "3.1.0", - "resolved": "https://npm.pkg.github.com/download/@lukka/action-lib/3.1.0/547dcf612077fbef5447ee055d9e6c37dfa33010", - "integrity": "sha512-WvyTfGnmrsTWGKBdh9OrICt1Z/6uF1fLxrTFqoyKR5NmjUGfMHamTPjCDqQoaqv/3YRS+mNfAXsEJWFrntWmTQ==", + "version": "3.3.0", + "resolved": "https://npm.pkg.github.com/download/@lukka/action-lib/3.3.0/5fc4362eb61fa87848bcc0254116dbb6fc4dbde5", + "integrity": "sha512-hlvMtQUQkrlXVYRokf8kuL3ME4LOf9RFeKMJTm7MJrnQXSmDHbFj7F8IIJpr5LY2SH/69xcJg2LeNdV+mZLR0A==", "requires": { "@actions/core": "^1.9.1", "@actions/exec": "^1.1.1", "@actions/github": "^5.0.3", "@actions/glob": "^0.3.0", "@actions/io": "^1.1.2", - "@lukka/base-lib": "^3.1.0", - "@lukka/base-util-lib": "^3.1.0", + "@lukka/base-lib": "^3.3.0", + "@lukka/base-util-lib": "^3.3.0", "@types/adm-zip": "^0.4.32", "@types/follow-redirects": "^1.14.1", "@types/q": "^1.5.1", @@ -16522,14 +16522,14 @@ } }, "@lukka/assets-lib": { - "version": "3.1.0", - "resolved": "https://npm.pkg.github.com/download/@lukka/assets-lib/3.1.0/27d49436aec9bde887e1f4d1036a36545383d4e9", - "integrity": "sha512-g0hOupvV3aCymY07BxqOgIh1L3/FxOGkdUMtCks1fdc06Q2C/OiTqIvN2Gvg6MEIDGF3uQDyCLTbooNa1CGitA==" + "version": "3.3.0", + "resolved": "https://npm.pkg.github.com/download/@lukka/assets-lib/3.3.0/e2f8697c6bd1449904adc4b89adf7c156b160843", + "integrity": "sha512-wb2046Pw/x1sNEgnyAS+qV5wIIWazeZGbCA0fqM7t0yMiV9wt9/Qlm6d9JhpVa7AQSgxDGvM6kOcJ/hIJP8+YA==" }, "@lukka/base-lib": { - "version": "3.1.0", - "resolved": "https://npm.pkg.github.com/download/@lukka/base-lib/3.1.0/4ea1eb1965ac1b21fea993ba35b89ad1e5156ecb", - "integrity": "sha512-Fl6qUPD+RK0gFLPi10+am/0sEN8WbVRUmR43AhGhYJQiVAoMoue7icrztgdgWXxDvGDaaeMdQ4LbvvEOILMPfw==", + "version": "3.3.0", + "resolved": "https://npm.pkg.github.com/download/@lukka/base-lib/3.3.0/f2cb59d710f1ba9d3fbdb9381f8295da3695f5ec", + "integrity": "sha512-lY51MTUh/FO5Ey1hvVoejvhMIkZMN1h7PYt2CrhNzh2PlW6DTTuHc42gLlVa2Rqznmsn85bG8GTzg/kFhXHC3Q==", "requires": { "@types/adm-zip": "^0.4.32", "@types/follow-redirects": "^1.14.1", @@ -16665,23 +16665,23 @@ } }, "@lukka/base-util-lib": { - "version": "3.1.0", - "resolved": "https://npm.pkg.github.com/download/@lukka/base-util-lib/3.1.0/bd919a34e0388a62dabfb6e1326330e591216e52", - "integrity": "sha512-kVfMhgNXhFNe0CEAkIb0OhtiHtBodapLlXDGZz36su0FS1SMgS2JLZqr5zqyDOfuo//zpAjWCOM/TNSYgRNedQ==", + "version": "3.3.0", + "resolved": "https://npm.pkg.github.com/download/@lukka/base-util-lib/3.3.0/2d3c7da0654298ef8825b731737f7be8ee56abff", + "integrity": "sha512-oiLtNc0aK8H9rTA2oGl2rJkjEQArgcsToVBYFUloG3w9zAfJckjZPO2sEy2vHoqHrArykdOo3c2MjPvhGRu1xw==", "requires": { - "@lukka/base-lib": "^3.1.0", + "@lukka/base-lib": "^3.3.0", "fast-glob": "3.2.7" } }, "@lukka/run-cmake-lib": { - "version": "3.1.0", - "resolved": "https://npm.pkg.github.com/download/@lukka/run-cmake-lib/3.1.0/51faaa45ce667b9f38214000e50516f9746c643b", - "integrity": "sha512-JC2dD6tBynGvthA8Txfro9s3LR+qHfp/nunA/Zh7qtenNsTn5NzLyov5nXuVM+J01y23OCc0/9sTBzWvwmU/XA==", - "requires": { - "@lukka/action-lib": "^3.1.0", - "@lukka/base-lib": "^3.1.0", - "@lukka/base-util-lib": "^3.1.0", - "@lukka/run-vcpkg-lib": "^3.1.0", + "version": "3.3.0", + "resolved": "https://npm.pkg.github.com/download/@lukka/run-cmake-lib/3.3.0/fc549e9d48db8c26fcce40ce92a11f634888ed88", + "integrity": "sha512-q/5w20gyMK1zHfccIqemAuF/H39yf0g56zzdccpyXAOfCt2KnydFE6kkYsqDkcXrw5EhZp5k34hQ9goMZhCZdQ==", + "requires": { + "@lukka/action-lib": "^3.3.0", + "@lukka/base-lib": "^3.3.0", + "@lukka/base-util-lib": "^3.3.0", + "@lukka/run-vcpkg-lib": "^3.3.0", "@types/adm-zip": "^0.4.32", "@types/follow-redirects": "^1.14.1", "@types/q": "^1.5.1", @@ -16818,13 +16818,13 @@ } }, "@lukka/run-vcpkg-lib": { - "version": "3.1.0", - "resolved": "https://npm.pkg.github.com/download/@lukka/run-vcpkg-lib/3.1.0/fb8b617f53d1997e479aa79b5bbc8eb4d585b2a9", - "integrity": "sha512-v+A+YxMLtT8bvLnMFpNfhsMTcMhZKMuGEGNzMqUR8zNDTwxArPUKRrptAtEL+Yxke5/kmhKz4w2CxK2EnKMvbQ==", + "version": "3.3.0", + "resolved": "https://npm.pkg.github.com/download/@lukka/run-vcpkg-lib/3.3.0/d9c931073f8c8ab8676ddda7b8d4c9841ddf0d45", + "integrity": "sha512-o7cjaynkY/B2uylcgL7CIjGZ2zUb2VmhuvKqgCvZz716c83TTXC2ZdRK8kfeky+ITjoFvGRA6UoWim4o4djqEw==", "requires": { - "@lukka/action-lib": "^3.1.0", - "@lukka/base-lib": "^3.1.0", - "@lukka/base-util-lib": "^3.1.0", + "@lukka/action-lib": "^3.3.0", + "@lukka/base-lib": "^3.3.0", + "@lukka/base-util-lib": "^3.3.0", "@types/adm-zip": "^0.4.32", "@types/follow-redirects": "^1.14.1", "@types/q": "^1.5.1", diff --git a/package.json b/package.json index 83e1f15..f52b2b4 100644 --- a/package.json +++ b/package.json @@ -43,11 +43,11 @@ "@actions/exec": "^1.0.3", "@actions/github": "^4.0.0", "@actions/io": "^1.0.2", - "@lukka/action-lib": "3.1.0", - "@lukka/assets-lib": "3.1.0", - "@lukka/base-lib": "3.1.0", - "@lukka/base-util-lib": "3.1.0", - "@lukka/run-cmake-lib": "3.1.0", + "@lukka/action-lib": "3.3.0", + "@lukka/assets-lib": "3.3.0", + "@lukka/base-lib": "3.3.0", + "@lukka/base-util-lib": "3.3.0", + "@lukka/run-cmake-lib": "3.3.0", "@types/adm-zip": "^0.4.32", "@types/follow-redirects": "^1.8.0", "@types/jest": "^26.0.14", diff --git a/src/cmake-action.ts b/src/cmake-action.ts index fe82045..a4c6b47 100644 --- a/src/cmake-action.ts +++ b/src/cmake-action.ts @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2020-2021-2022 Luca Cappa +// Copyright (c) 2019-2020-2021-2022-2023 Luca Cappa // Released under the term specified in file LICENSE.txt // SPDX short identifier: MIT @@ -16,6 +16,8 @@ export async function main(): Promise { const configurePreset = actionLib.getInput(cmakeglobals.configurePreset, false); const buildPreset = actionLib.getInput(cmakeglobals.buildPreset, false); const testPreset = actionLib.getInput(cmakeglobals.testPreset, false); + const workflowPreset = actionLib.getInput(cmakeglobals.workflowPreset, false); + const workflowPresetCmdStringFormat = actionLib.getInput(cmakeglobals.workflowPresetFormat, false); const configurePresetCmdStringFormat = actionLib.getInput(cmakeglobals.configurePresetFormat, false); const buildPresetCmdStringFormat = actionLib.getInput(cmakeglobals.buildPresetFormat, false); const testPresetCmdStringFormat = actionLib.getInput(cmakeglobals.testPresetFormat, false); @@ -25,6 +27,7 @@ export async function main(): Promise { const runVcpkgEnvFormatString = actionLib.getInput(vcpkgglobals.runVcpkgEnvFormatStringInput, false); await runcmakelib.CMakeRunner.run( actionLib, + workflowPreset, workflowPresetCmdStringFormat, configurePreset, configurePresetCmdStringFormat, configurePresetAdditionalArgs, buildPreset, buildPresetCmdStringFormat, buildPresetAdditionalArgs, testPreset, testPresetCmdStringFormat, testPresetAdditionalArgs,