diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 6d264b50..1929cc4b 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -44,7 +44,6 @@ jobs: NODE_COVERALLS_DEBUG: 1 tests: - needs: build_and_unit_test name: '${{ matrix.os }}: functional tests' runs-on: ${{ matrix.os }} strategy: @@ -71,7 +70,7 @@ jobs: runVcpkgInstall: true # This forces the creation of a new cache entry each time the workflow is run. # It is the same across jobs in the same workflows. - appendedCacheKey: ${{ env.GITHUB_RUN_ID }} + prependedCacheKey: ${{ env.GITHUB_RUN_ID }} env: VCPKG_INSTALLED_DIR: ${{ github.workspace }}/vcpkg_installed @@ -88,13 +87,12 @@ jobs: uses: actions/checkout@v3 with: submodules: true - - name: basic test for run-vcpkg (not running vcpkg). uses: ./ with: vcpkgDirectory: ${{ github.workspace }}/vcpkg vcpkgGitCommitId: '14e7bb4ae24616ec54ff6b2f6ef4e8659434ea44' - appendedCacheKey: ${{ env.GITHUB_RUN_ID }} + prependedCacheKey: ${{ env.GITHUB_RUN_ID }} finalize_coveralls: needs: build_and_unit_test diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 35418e1c..a8a0a18f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,8 +15,8 @@ The software is provided as is, there is no warranty of any kind. All users are `run-vcpkg` depends on public NPM packages published by [lukka/run-cmake-vcpkg-action-libs](https://github.com/lukka/run-cmake-vcpkg-action-libs) in the [GitHub Packages registry](https://docs.github.com/en/free-pro-team@latest/packages/using-github-packages-with-your-projects-ecosystem/configuring-npm-for-use-with-github-packages). Unexpectedly, a public package still requires authentication when downloading it, hence if you want to `npm install` those packages correctly, you need to obtain a token with `read:packages` scope. Then create in the root of the repository a `.npmrc` file with the following content: - //npm.pkg.github.com/:_authToken=YOURTOKEN - @lukka:registry=https://npm.pkg.github.com/ + //npm.pkg.github.com/:_authToken=YOURTOKEN + @lukka:registry=https://npm.pkg.github.com/ __Note__: **Never commit this `.npmrc` file!** diff --git a/README.md b/README.md index f042d98d..905560f5 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,18 @@ jobs: # (i.e. let CMake run `vcpkg install`) using the vcpkg.cmake toolchain. # runVcpkgInstall: true + # The following `run` step is useful to prevent storing partial cache in the GH cache + # service. + # This is useful when vcpkg is not run at `run-vcpkg`'s runtime, but later when CMake + # is running, e.g. at `run-cmake` runtime. + # Driving the environment variable `RUNVCPKG_NO_CACHE`, at the end of the workflow the + # `run-vcpkg` post step is instructed to not save anything when the workflow has been + # cancelled or it has failed. + #- run: | + # echo "RUNVCPKG_NO_CACHE=1" >> $GITHUB_ENV + # if: ${{ failure() || cancelled() }} + # shell: bash + - name: Run CMake consuming CMakePreset.json and vcpkg.json by mean of vcpkg. uses: lukka/run-cmake@v10 with: @@ -108,8 +120,8 @@ jobs: # VCPKG_ENABLE_METRICS: 1 # # [OPTIONAL] Define the vcpkg's triplet you want to enforce, otherwise the default one - # for the hosting system will be automatically choosen (x64 is the default on all platforms, - # e.g. `x64-osx`). + # for the hosting system will be automatically choosen (x64 is the default on all + # platforms, e.g. `x64-osx`). # VCPKG_DEFAULT_TRIPLET: ${{ matrix.triplet }} ``` @@ -124,9 +136,9 @@ Flowchart with related input in [action.yml](https://github.com/lukka/run-vcpkg/ ``` ┌──────────────────────────┐ │ Compute cache key from: │ Inputs: -│ - vcpkg Git commit │ - `appendedCacheKey` +│ - vcpkg Git commit │ - `prependedCacheKey` and `appendedCacheKey` │ - platform and OS │ - `vcpkgGitCommitId` -│ - user provided key │ +│ - user provided keys │ └─────────────┬────────────┘ │ ▼ diff --git a/__tests__/functional.test.ts b/__tests__/functional.test.ts index 37d1521b..e993df7c 100644 --- a/__tests__/functional.test.ts +++ b/__tests__/functional.test.ts @@ -48,7 +48,7 @@ describe('run-vcpkg functional tests', () => { test('vcpkg setup and install must succeed', () => { process.env.INPUT_VCPKGDIRECTORY = vcpkgDirectory; process.env.INPUT_VCPKGJSONGLOB = "**/vcpkg.json"; - process.env.INPUT_VCPKGGITCOMMITID = "b86c0c35b88e2bf3557ff49dc831689c2f085090"; + process.env.INPUT_VCPKGGITCOMMITID = "6ca56aeb457f033d344a7106cb3f9f1abf8f4e98"; process.env.INPUT_RUNVCPKGINSTALL = "true"; process.env.INPUT_RUNVCPKGFORMATSTRING = runvcpkglib.VcpkgRunner.VCPKGINSTALLCMDDEFAULT; @@ -62,7 +62,7 @@ describe('run-vcpkg functional tests', () => { test('vcpkg setup and no install must succeed', () => { process.env.INPUT_VCPKGDIRECTORY = vcpkgDirectory; process.env.INPUT_VCPKGJSONGLOB = "**/vcpkg.json"; - process.env.INPUT_VCPKGGITCOMMITID = "b86c0c35b88e2bf3557ff49dc831689c2f085090"; + process.env.INPUT_VCPKGGITCOMMITID = "6ca56aeb457f033d344a7106cb3f9f1abf8f4e98"; process.env.INPUT_RUNVCPKGINSTALL = "false"; process.env.INPUT_RUNVCPKGFORMATSTRING = "['invalid command']"; @@ -77,7 +77,7 @@ describe('run-vcpkg functional tests', () => { delete process.env.INPUT_VCPKGDIRECTORY; console.log(process.env.INPUT_VCPKGDIRECTORY); delete process.env.INPUT_VCPKGJSONGLOB; - process.env.INPUT_VCPKGGITCOMMITID = "b86c0c35b88e2bf3557ff49dc831689c2f085090"; + process.env.INPUT_VCPKGGITCOMMITID = "6ca56aeb457f033d344a7106cb3f9f1abf8f4e98"; process.env.INPUT_RUNVCPKGINSTALL = "false"; process.env.INPUT_RUNVCPKGFORMATSTRING = runvcpkglib.VcpkgRunner.VCPKGINSTALLCMDDEFAULT; @@ -102,7 +102,7 @@ describe('run-vcpkg functional tests', () => { await actionLib.rmRF(await runvcpkglib.getDefaultVcpkgInstallDirectory(baseLibUtils.baseLib)); await actionLib.rmRF(await runvcpkglib.getDefaultVcpkgCacheDirectory(baseLibUtils.baseLib)); - process.env.INPUT_VCPKGGITCOMMITID = "b86c0c35b88e2bf3557ff49dc831689c2f085090"; + process.env.INPUT_VCPKGGITCOMMITID = "6ca56aeb457f033d344a7106cb3f9f1abf8f4e98"; process.env.INPUT_RUNVCPKGINSTALL = "true"; process.env.INPUT_RUNVCPKGFORMATSTRING = runvcpkglib.VcpkgRunner.VCPKGINSTALLCMDDEFAULT; diff --git a/__tests__/unit.test.ts b/__tests__/unit.test.ts index d339fc95..492b30b1 100644 --- a/__tests__/unit.test.ts +++ b/__tests__/unit.test.ts @@ -157,6 +157,7 @@ test('run-vcpkg: cache hit', async () => { function (a, b, c): Promise { return Promise.resolve(primaryHitKey); }); process.env.INPUT_VCPKGDIRECTORY = "/var/tmp/vcpkg"; process.env.INPUT_APPENDEDCACHEKEY = "appendedCacheKey"; + process.env.INPUT_PREPENDEDCACHEKEY = "prependedCacheKey"; // Act. const vcpkg: vcpkgaction.VcpkgAction = new vcpkgaction.VcpkgAction(baseUtil); @@ -299,10 +300,10 @@ test('getVcpkgCommitId() tests', async () => { test('computeCacheKey(): vcpkg not as a submodule (no commit id user provided and no vcpkg.json found)', async () => { // Arrange. const expected: baseutil.KeySet = { - "primary": "runnerOS=imageos42-vcpkgGitCommit=1234_appendedKey=appendedCacheKey", + "primary": "prependedKey=prependedCacheKey-runnerOS=imageos42-vcpkgGitCommit=1234_appendedKey=appendedCacheKey", "restore": [ - "runnerOS=imageos42-vcpkgGitCommit=1234" + "prependedKey=prependedCacheKey-runnerOS=imageos42-vcpkgGitCommit=1234" ] }; process.env.ImageOS = "imageos"; @@ -321,7 +322,8 @@ test('computeCacheKey(): vcpkg not as a submodule (no commit id user provided an null, ".", "", - "appendedCacheKey")).toStrictEqual(expected); + "appendedCacheKey", + "prependedCacheKey")).toStrictEqual(expected); expect(warningMock).toBeCalledTimes(0); // Cleanup. @@ -332,11 +334,11 @@ test('computeCacheKey(): vcpkg not as a submodule (no commit id user provided an test('computeCacheKey(): vcpkg not as a submodule (no commit id user provided)', async () => { // Arrange. const expected: baseutil.KeySet = { - "primary": "runnerOS=imageos42-vcpkgGitCommit=1234_vcpkgJson=hash-of-vcpkg.json-vcpkgConfigurationJson=hash-of-vcpkg-configuration.json_appendedKey=appendedCacheKey", + "primary": "prependedKey=prependedCacheKey-runnerOS=imageos42-vcpkgGitCommit=1234_vcpkgJson=hash-of-vcpkg.json-vcpkgConfigurationJson=hash-of-vcpkg-configuration.json_appendedKey=appendedCacheKey", "restore": [ - "runnerOS=imageos42-vcpkgGitCommit=1234_vcpkgJson=hash-of-vcpkg.json-vcpkgConfigurationJson=hash-of-vcpkg-configuration.json", - "runnerOS=imageos42-vcpkgGitCommit=1234" + "prependedKey=prependedCacheKey-runnerOS=imageos42-vcpkgGitCommit=1234_vcpkgJson=hash-of-vcpkg.json-vcpkgConfigurationJson=hash-of-vcpkg-configuration.json", + "prependedKey=prependedCacheKey-runnerOS=imageos42-vcpkgGitCommit=1234" ] }; process.env.ImageOS = "imageos"; @@ -353,7 +355,8 @@ test('computeCacheKey(): vcpkg not as a submodule (no commit id user provided)', "hash-of-vcpkg-configuration.json", ".", "", - "appendedCacheKey")).toStrictEqual(expected); + "appendedCacheKey", + "prependedCacheKey")).toStrictEqual(expected); expect(warningMock).toBeCalledTimes(0); // Cleanup. @@ -363,11 +366,11 @@ test('computeCacheKey(): vcpkg not as a submodule (no commit id user provided)', test('computeCacheKey(): vcpkg as a submodule (no commit id user provided)', async () => { // Arrange. const expected: baseutil.KeySet = { - "primary": "runnerOS=imageos42-vcpkgGitCommit=5678_vcpkgJson=hash-of-vcpkg.json-vcpkgConfigurationJson=hash-of-vcpkg-configuration.json_appendedKey=appendedCacheKey", + "primary": "prependedKey=prependedCacheKey-runnerOS=imageos42-vcpkgGitCommit=5678_vcpkgJson=hash-of-vcpkg.json-vcpkgConfigurationJson=hash-of-vcpkg-configuration.json_appendedKey=appendedCacheKey", "restore": [ - "runnerOS=imageos42-vcpkgGitCommit=5678_vcpkgJson=hash-of-vcpkg.json-vcpkgConfigurationJson=hash-of-vcpkg-configuration.json", - "runnerOS=imageos42-vcpkgGitCommit=5678" + "prependedKey=prependedCacheKey-runnerOS=imageos42-vcpkgGitCommit=5678_vcpkgJson=hash-of-vcpkg.json-vcpkgConfigurationJson=hash-of-vcpkg-configuration.json", + "prependedKey=prependedCacheKey-runnerOS=imageos42-vcpkgGitCommit=5678" ] }; process.env.ImageOS = "imageos"; @@ -384,7 +387,8 @@ test('computeCacheKey(): vcpkg as a submodule (no commit id user provided)', asy "hash-of-vcpkg-configuration.json", ".", "", - "appendedCacheKey")).toStrictEqual(expected); + "appendedCacheKey", + "prependedCacheKey")).toStrictEqual(expected); expect(warningMock).toBeCalledTimes(0); // Cleanup. @@ -394,11 +398,11 @@ test('computeCacheKey(): vcpkg as a submodule (no commit id user provided)', asy test('computeCacheKey(): vcpkg as a submodule, with user provided Git commit id, it must trigger a warning', async () => { // Arrange. const expected: baseutil.KeySet = { - "primary": "runnerOS=imageos42-vcpkgGitCommit=0912_vcpkgJson=hash-of-vcpkg.json-vcpkgConfigurationJson=hash-of-vcpkg-configuration.json_appendedKey=appendedCacheKey", + "primary": "prependedKey=prependedCacheKey-runnerOS=imageos42-vcpkgGitCommit=0912_vcpkgJson=hash-of-vcpkg.json-vcpkgConfigurationJson=hash-of-vcpkg-configuration.json_appendedKey=appendedCacheKey", "restore": [ - "runnerOS=imageos42-vcpkgGitCommit=0912_vcpkgJson=hash-of-vcpkg.json-vcpkgConfigurationJson=hash-of-vcpkg-configuration.json", - "runnerOS=imageos42-vcpkgGitCommit=0912" + "prependedKey=prependedCacheKey-runnerOS=imageos42-vcpkgGitCommit=0912_vcpkgJson=hash-of-vcpkg.json-vcpkgConfigurationJson=hash-of-vcpkg-configuration.json", + "prependedKey=prependedCacheKey-runnerOS=imageos42-vcpkgGitCommit=0912" ] }; process.env.ImageOS = "imageos"; @@ -415,7 +419,8 @@ test('computeCacheKey(): vcpkg as a submodule, with user provided Git commit id, "hash-of-vcpkg-configuration.json", path.resolve("."), "vcpkgcommitid", - "appendedCacheKey")).toStrictEqual(expected); + "appendedCacheKey", + "prependedCacheKey")).toStrictEqual(expected); expect(warningMock).toBeCalledTimes(1); vcpkgCommitIdMock.mockClear(); }); @@ -423,10 +428,10 @@ test('computeCacheKey(): vcpkg as a submodule, with user provided Git commit id, test('computeCacheKey(): vcpkg with user provided commit it must not trigger a warning', async () => { // Arrange. const expected: baseutil.KeySet = { - "primary": "runnerOS=imageos42-vcpkgGitCommit=userId_vcpkgJson=hash-of-vcpkg.json-vcpkgConfigurationJson=hash-of-vcpkg-configuration.json_appendedKey=appendedCacheKey", + "primary": "prependedKey=prependedCacheKey-runnerOS=imageos42-vcpkgGitCommit=userId_vcpkgJson=hash-of-vcpkg.json-vcpkgConfigurationJson=hash-of-vcpkg-configuration.json_appendedKey=appendedCacheKey", "restore": [ - "runnerOS=imageos42-vcpkgGitCommit=userId_vcpkgJson=hash-of-vcpkg.json-vcpkgConfigurationJson=hash-of-vcpkg-configuration.json", - "runnerOS=imageos42-vcpkgGitCommit=userId"] + "prependedKey=prependedCacheKey-runnerOS=imageos42-vcpkgGitCommit=userId_vcpkgJson=hash-of-vcpkg.json-vcpkgConfigurationJson=hash-of-vcpkg-configuration.json", + "prependedKey=prependedCacheKey-runnerOS=imageos42-vcpkgGitCommit=userId"] }; process.env.ImageOS = "imageos"; process.env.ImageVersion = "42"; @@ -442,6 +447,7 @@ test('computeCacheKey(): vcpkg with user provided commit it must not trigger a w "hash-of-vcpkg-configuration.json", "/Users/luca/github/run-vcpkg/__tests__/assets/", "userId", - "appendedCacheKey")).toStrictEqual(expected); + "appendedCacheKey", + "prependedCacheKey")).toStrictEqual(expected); expect(warningMock).toBeCalledTimes(0); }); diff --git a/action.yml b/action.yml index 3f7cc193..7a7d6a01 100644 --- a/action.yml +++ b/action.yml @@ -16,6 +16,9 @@ inputs: default: false required: false description: "Run the installation of package by running `vcpkg install` on the directory of the discovered 'vcpkg.json' file. Default is false." + prependedCacheKey: + required: false + description: "Specify a value to prepend to the cache key." appendedCacheKey: required: false description: "Specify a value to append to the cache key." diff --git a/dist/index.js b/dist/index.js index 71c3946a..22012fa6 100644 --- a/dist/index.js +++ b/dist/index.js @@ -72,7 +72,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }); }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.VcpkgAction = exports.VCPKG_SUCCESS_STATE = exports.VCPKG_ADDITIONAL_CACHED_PATHS_STATE = exports.VCPKG_ROOT_STATE = exports.VCPKG_ADDED_CACHEKEY_STATE = exports.VCPKG_DO_NOT_CACHE_STATE = exports.VCPKG_KEY_CACHE_HIT_STATE = exports.VCPKG_CACHE_COMPUTEDKEY_STATE = exports.logCollectionRegExpsInput = exports.appendedCacheKeyInput = exports.vcpkgUrlInput = exports.doNotUpdateVcpkgInput = exports.vcpkgCommitIdInput = exports.vcpkgDirectoryInput = exports.runVcpkgFormatStringInput = exports.runVcpkgInstallInput = exports.vcpkgJsonIgnoresInput = exports.vcpkgJsonGlobInput = exports.binaryCachePathInput = exports.additionalCachedPathsInput = exports.doNotCacheInput = void 0; +exports.VcpkgAction = exports.VCPKG_SUCCESS_STATE = exports.VCPKG_ADDITIONAL_CACHED_PATHS_STATE = exports.VCPKG_ROOT_STATE = exports.VCPKG_ADDED_CACHEKEY_STATE = exports.VCPKG_DO_NOT_CACHE_STATE = exports.VCPKG_KEY_CACHE_HIT_STATE = exports.VCPKG_CACHE_COMPUTEDKEY_STATE = exports.logCollectionRegExpsInput = exports.prependedCacheKeyInput = exports.appendedCacheKeyInput = exports.vcpkgUrlInput = exports.doNotUpdateVcpkgInput = exports.vcpkgCommitIdInput = exports.vcpkgDirectoryInput = exports.runVcpkgFormatStringInput = exports.runVcpkgInstallInput = exports.vcpkgJsonIgnoresInput = exports.vcpkgJsonGlobInput = exports.binaryCachePathInput = exports.additionalCachedPathsInput = exports.doNotCacheInput = void 0; const path = __nccwpck_require__(5622); const cache = __nccwpck_require__(7799); const runvcpkglib = __nccwpck_require__(4393); @@ -93,6 +93,7 @@ exports.vcpkgUrlInput = "VCPKGGITURL"; * The input's name for additional content for the cache key. */ exports.appendedCacheKeyInput = 'APPENDEDCACHEKEY'; +exports.prependedCacheKeyInput = 'PREPENDEDCACHEKEY'; exports.logCollectionRegExpsInput = 'LOGCOLLECTIONREGEXPS'; // Saved data in the action, and consumed by post-action. exports.VCPKG_CACHE_COMPUTEDKEY_STATE = "VCPKG_CACHE_COMPUTEDKEY_STATE"; @@ -104,25 +105,26 @@ exports.VCPKG_ADDITIONAL_CACHED_PATHS_STATE = "VCPKG_ADDITIONAL_CACHED_PATHS_STA exports.VCPKG_SUCCESS_STATE = "VCPKG_SUCCESS_STATE"; class VcpkgAction { constructor(baseUtilLib) { - var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o; + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p; this.baseUtilLib = baseUtilLib; this.doNotCache = false; // Fetch inputs. this.appendedCacheKey = (_a = baseUtilLib.baseLib.getInput(exports.appendedCacheKeyInput, false)) !== null && _a !== void 0 ? _a : null; + this.prependedCacheKey = (_b = baseUtilLib.baseLib.getInput(exports.prependedCacheKeyInput, false)) !== null && _b !== void 0 ? _b : null; const vcpkgRootDir = baseUtilLib.baseLib.getPathInput(exports.vcpkgDirectoryInput, false, false); this.vcpkgRootDir = vcpkgRootDir ? path.normalize(path.resolve(vcpkgRootDir)) : null; - this.userProvidedCommitId = (_b = baseUtilLib.baseLib.getInput(exports.vcpkgCommitIdInput, false)) !== null && _b !== void 0 ? _b : null; - vcpkgutil.Utils.addCachedPaths(baseUtilLib.baseLib, (_c = baseUtilLib.baseLib.getInput(exports.additionalCachedPathsInput, false)) !== null && _c !== void 0 ? _c : null); - this.runVcpkgFormatString = (_d = baseUtilLib.baseLib.getInput(exports.runVcpkgFormatStringInput, false)) !== null && _d !== void 0 ? _d : null; - this.vcpkgJsonGlob = (_e = baseUtilLib.baseLib.getInput(exports.vcpkgJsonGlobInput, false)) !== null && _e !== void 0 ? _e : VcpkgAction.VCPKGJSON_GLOB; - this.vcpkgJsonIgnores = eval((_f = baseUtilLib.baseLib.getInput(exports.vcpkgJsonIgnoresInput, false)) !== null && _f !== void 0 ? _f : VcpkgAction.VCPKGJSON_IGNORES); - this.runVcpkgInstall = (_g = baseUtilLib.baseLib.getBoolInput(exports.runVcpkgInstallInput, false)) !== null && _g !== void 0 ? _g : false; - this.doNotCache = (_h = baseUtilLib.baseLib.getBoolInput(exports.doNotCacheInput, false)) !== null && _h !== void 0 ? _h : false; - this.doNotUpdateVcpkg = (_j = baseUtilLib.baseLib.getBoolInput(exports.doNotUpdateVcpkgInput, false)) !== null && _j !== void 0 ? _j : false; - this.vcpkgUrl = (_k = baseUtilLib.baseLib.getInput(exports.vcpkgUrlInput, false)) !== null && _k !== void 0 ? _k : VcpkgAction.DEFAULTVCPKGURL; - this.vcpkgCommitId = (_l = baseUtilLib.baseLib.getInput(exports.vcpkgCommitIdInput, false)) !== null && _l !== void 0 ? _l : null; - this.logCollectionRegExps = (_m = baseUtilLib.baseLib.getDelimitedInput(exports.logCollectionRegExpsInput, ';', false)) !== null && _m !== void 0 ? _m : []; - this.binaryCachePath = (_o = baseUtilLib.baseLib.getPathInput(exports.binaryCachePathInput, false, true)) !== null && _o !== void 0 ? _o : null; + this.userProvidedCommitId = (_c = baseUtilLib.baseLib.getInput(exports.vcpkgCommitIdInput, false)) !== null && _c !== void 0 ? _c : null; + vcpkgutil.Utils.addCachedPaths(baseUtilLib.baseLib, (_d = baseUtilLib.baseLib.getInput(exports.additionalCachedPathsInput, false)) !== null && _d !== void 0 ? _d : null); + this.runVcpkgFormatString = (_e = baseUtilLib.baseLib.getInput(exports.runVcpkgFormatStringInput, false)) !== null && _e !== void 0 ? _e : null; + this.vcpkgJsonGlob = (_f = baseUtilLib.baseLib.getInput(exports.vcpkgJsonGlobInput, false)) !== null && _f !== void 0 ? _f : VcpkgAction.VCPKGJSON_GLOB; + this.vcpkgJsonIgnores = eval((_g = baseUtilLib.baseLib.getInput(exports.vcpkgJsonIgnoresInput, false)) !== null && _g !== void 0 ? _g : VcpkgAction.VCPKGJSON_IGNORES); + this.runVcpkgInstall = (_h = baseUtilLib.baseLib.getBoolInput(exports.runVcpkgInstallInput, false)) !== null && _h !== void 0 ? _h : false; + this.doNotCache = (_j = baseUtilLib.baseLib.getBoolInput(exports.doNotCacheInput, false)) !== null && _j !== void 0 ? _j : false; + this.doNotUpdateVcpkg = (_k = baseUtilLib.baseLib.getBoolInput(exports.doNotUpdateVcpkgInput, false)) !== null && _k !== void 0 ? _k : false; + this.vcpkgUrl = (_l = baseUtilLib.baseLib.getInput(exports.vcpkgUrlInput, false)) !== null && _l !== void 0 ? _l : VcpkgAction.DEFAULTVCPKGURL; + this.vcpkgCommitId = (_m = baseUtilLib.baseLib.getInput(exports.vcpkgCommitIdInput, false)) !== null && _m !== void 0 ? _m : null; + this.logCollectionRegExps = (_o = baseUtilLib.baseLib.getDelimitedInput(exports.logCollectionRegExpsInput, ';', false)) !== null && _o !== void 0 ? _o : []; + this.binaryCachePath = (_p = baseUtilLib.baseLib.getPathInput(exports.binaryCachePathInput, false, true)) !== null && _p !== void 0 ? _p : null; } run() { return __awaiter(this, void 0, void 0, function* () { @@ -156,7 +158,7 @@ class VcpkgAction { let vcpkgJsonFilePath = null; yield this.baseUtilLib.wrapOp('Compute vcpkg cache key', () => __awaiter(this, void 0, void 0, function* () { const [vcpkgJsonFile, vcpkgJsonHash, vcpkgConfigurationJsonHash] = yield vcpkgutil.Utils.getVcpkgJsonHash(this.baseUtilLib, this.vcpkgJsonGlob, this.vcpkgJsonIgnores); - keys = yield vcpkgutil.Utils.computeCacheKeys(this.baseUtilLib, vcpkgJsonHash, vcpkgConfigurationJsonHash, this.vcpkgRootDir, this.userProvidedCommitId, this.appendedCacheKey); + keys = yield vcpkgutil.Utils.computeCacheKeys(this.baseUtilLib, vcpkgJsonHash, vcpkgConfigurationJsonHash, this.vcpkgRootDir, this.userProvidedCommitId, this.appendedCacheKey, this.prependedCacheKey); if (keys) { baseLib.info(`Computed key: ${JSON.stringify(keys)}`); vcpkgJsonFilePath = vcpkgJsonFile; @@ -180,7 +182,7 @@ class VcpkgAction { return __awaiter(this, void 0, void 0, function* () { this.baseUtilLib.baseLib.debug("restoreCache()<<"); if (this.doNotCache) { - this.baseUtilLib.baseLib.info(`Skipping as caching is disabled(${exports.doNotCacheInput}: true)`); + this.baseUtilLib.baseLib.info(`Skipping saving cache as caching is disabled (${exports.doNotCacheInput}: ${this.doNotCache}).`); } else { if (!this.vcpkgRootDir) @@ -336,12 +338,13 @@ class Utils { return [null, null, null]; }); } - static computeCacheKeys(baseUtilLib, vcpkgJsonHash, vcpkgConfJsonHash, vcpkgDirectory, userProvidedCommitId, appendedCacheKey) { + static computeCacheKeys(baseUtilLib, vcpkgJsonHash, vcpkgConfJsonHash, vcpkgDirectory, userProvidedCommitId, appendedCacheKey, prependedCacheKey) { return __awaiter(this, void 0, void 0, function* () { baseUtilLib.baseLib.debug(`computeCacheKeys()<<`); const cacheKeySegments = []; // Add to the first segment of the key the values of env vars ImageOS and ImageVersion if available. - let firstSegment = `runnerOS=${process.env['ImageOS'] ? process.env['ImageOS'] : process.platform}`; + let firstSegment = prependedCacheKey ? `prependedKey=${prependedCacheKey}-` : ""; + firstSegment += `runnerOS=${process.env['ImageOS'] ? process.env['ImageOS'] : process.platform}`; firstSegment += process.env['ImageVersion'] || ""; const [commitId, isSubmodule] = yield Utils.getVcpkgCommitId(baseUtilLib, vcpkgDirectory); if (commitId) { diff --git a/dist/post/index.js b/dist/post/index.js index 0875cd9f..18a53045 100644 --- a/dist/post/index.js +++ b/dist/post/index.js @@ -79,7 +79,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }); }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.VcpkgAction = exports.VCPKG_SUCCESS_STATE = exports.VCPKG_ADDITIONAL_CACHED_PATHS_STATE = exports.VCPKG_ROOT_STATE = exports.VCPKG_ADDED_CACHEKEY_STATE = exports.VCPKG_DO_NOT_CACHE_STATE = exports.VCPKG_KEY_CACHE_HIT_STATE = exports.VCPKG_CACHE_COMPUTEDKEY_STATE = exports.logCollectionRegExpsInput = exports.appendedCacheKeyInput = exports.vcpkgUrlInput = exports.doNotUpdateVcpkgInput = exports.vcpkgCommitIdInput = exports.vcpkgDirectoryInput = exports.runVcpkgFormatStringInput = exports.runVcpkgInstallInput = exports.vcpkgJsonIgnoresInput = exports.vcpkgJsonGlobInput = exports.binaryCachePathInput = exports.additionalCachedPathsInput = exports.doNotCacheInput = void 0; +exports.VcpkgAction = exports.VCPKG_SUCCESS_STATE = exports.VCPKG_ADDITIONAL_CACHED_PATHS_STATE = exports.VCPKG_ROOT_STATE = exports.VCPKG_ADDED_CACHEKEY_STATE = exports.VCPKG_DO_NOT_CACHE_STATE = exports.VCPKG_KEY_CACHE_HIT_STATE = exports.VCPKG_CACHE_COMPUTEDKEY_STATE = exports.logCollectionRegExpsInput = exports.prependedCacheKeyInput = exports.appendedCacheKeyInput = exports.vcpkgUrlInput = exports.doNotUpdateVcpkgInput = exports.vcpkgCommitIdInput = exports.vcpkgDirectoryInput = exports.runVcpkgFormatStringInput = exports.runVcpkgInstallInput = exports.vcpkgJsonIgnoresInput = exports.vcpkgJsonGlobInput = exports.binaryCachePathInput = exports.additionalCachedPathsInput = exports.doNotCacheInput = void 0; const path = __nccwpck_require__(5622); const cache = __nccwpck_require__(7799); const runvcpkglib = __nccwpck_require__(4393); @@ -100,6 +100,7 @@ exports.vcpkgUrlInput = "VCPKGGITURL"; * The input's name for additional content for the cache key. */ exports.appendedCacheKeyInput = 'APPENDEDCACHEKEY'; +exports.prependedCacheKeyInput = 'PREPENDEDCACHEKEY'; exports.logCollectionRegExpsInput = 'LOGCOLLECTIONREGEXPS'; // Saved data in the action, and consumed by post-action. exports.VCPKG_CACHE_COMPUTEDKEY_STATE = "VCPKG_CACHE_COMPUTEDKEY_STATE"; @@ -111,25 +112,26 @@ exports.VCPKG_ADDITIONAL_CACHED_PATHS_STATE = "VCPKG_ADDITIONAL_CACHED_PATHS_STA exports.VCPKG_SUCCESS_STATE = "VCPKG_SUCCESS_STATE"; class VcpkgAction { constructor(baseUtilLib) { - var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o; + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p; this.baseUtilLib = baseUtilLib; this.doNotCache = false; // Fetch inputs. this.appendedCacheKey = (_a = baseUtilLib.baseLib.getInput(exports.appendedCacheKeyInput, false)) !== null && _a !== void 0 ? _a : null; + this.prependedCacheKey = (_b = baseUtilLib.baseLib.getInput(exports.prependedCacheKeyInput, false)) !== null && _b !== void 0 ? _b : null; const vcpkgRootDir = baseUtilLib.baseLib.getPathInput(exports.vcpkgDirectoryInput, false, false); this.vcpkgRootDir = vcpkgRootDir ? path.normalize(path.resolve(vcpkgRootDir)) : null; - this.userProvidedCommitId = (_b = baseUtilLib.baseLib.getInput(exports.vcpkgCommitIdInput, false)) !== null && _b !== void 0 ? _b : null; - vcpkgutil.Utils.addCachedPaths(baseUtilLib.baseLib, (_c = baseUtilLib.baseLib.getInput(exports.additionalCachedPathsInput, false)) !== null && _c !== void 0 ? _c : null); - this.runVcpkgFormatString = (_d = baseUtilLib.baseLib.getInput(exports.runVcpkgFormatStringInput, false)) !== null && _d !== void 0 ? _d : null; - this.vcpkgJsonGlob = (_e = baseUtilLib.baseLib.getInput(exports.vcpkgJsonGlobInput, false)) !== null && _e !== void 0 ? _e : VcpkgAction.VCPKGJSON_GLOB; - this.vcpkgJsonIgnores = eval((_f = baseUtilLib.baseLib.getInput(exports.vcpkgJsonIgnoresInput, false)) !== null && _f !== void 0 ? _f : VcpkgAction.VCPKGJSON_IGNORES); - this.runVcpkgInstall = (_g = baseUtilLib.baseLib.getBoolInput(exports.runVcpkgInstallInput, false)) !== null && _g !== void 0 ? _g : false; - this.doNotCache = (_h = baseUtilLib.baseLib.getBoolInput(exports.doNotCacheInput, false)) !== null && _h !== void 0 ? _h : false; - this.doNotUpdateVcpkg = (_j = baseUtilLib.baseLib.getBoolInput(exports.doNotUpdateVcpkgInput, false)) !== null && _j !== void 0 ? _j : false; - this.vcpkgUrl = (_k = baseUtilLib.baseLib.getInput(exports.vcpkgUrlInput, false)) !== null && _k !== void 0 ? _k : VcpkgAction.DEFAULTVCPKGURL; - this.vcpkgCommitId = (_l = baseUtilLib.baseLib.getInput(exports.vcpkgCommitIdInput, false)) !== null && _l !== void 0 ? _l : null; - this.logCollectionRegExps = (_m = baseUtilLib.baseLib.getDelimitedInput(exports.logCollectionRegExpsInput, ';', false)) !== null && _m !== void 0 ? _m : []; - this.binaryCachePath = (_o = baseUtilLib.baseLib.getPathInput(exports.binaryCachePathInput, false, true)) !== null && _o !== void 0 ? _o : null; + this.userProvidedCommitId = (_c = baseUtilLib.baseLib.getInput(exports.vcpkgCommitIdInput, false)) !== null && _c !== void 0 ? _c : null; + vcpkgutil.Utils.addCachedPaths(baseUtilLib.baseLib, (_d = baseUtilLib.baseLib.getInput(exports.additionalCachedPathsInput, false)) !== null && _d !== void 0 ? _d : null); + this.runVcpkgFormatString = (_e = baseUtilLib.baseLib.getInput(exports.runVcpkgFormatStringInput, false)) !== null && _e !== void 0 ? _e : null; + this.vcpkgJsonGlob = (_f = baseUtilLib.baseLib.getInput(exports.vcpkgJsonGlobInput, false)) !== null && _f !== void 0 ? _f : VcpkgAction.VCPKGJSON_GLOB; + this.vcpkgJsonIgnores = eval((_g = baseUtilLib.baseLib.getInput(exports.vcpkgJsonIgnoresInput, false)) !== null && _g !== void 0 ? _g : VcpkgAction.VCPKGJSON_IGNORES); + this.runVcpkgInstall = (_h = baseUtilLib.baseLib.getBoolInput(exports.runVcpkgInstallInput, false)) !== null && _h !== void 0 ? _h : false; + this.doNotCache = (_j = baseUtilLib.baseLib.getBoolInput(exports.doNotCacheInput, false)) !== null && _j !== void 0 ? _j : false; + this.doNotUpdateVcpkg = (_k = baseUtilLib.baseLib.getBoolInput(exports.doNotUpdateVcpkgInput, false)) !== null && _k !== void 0 ? _k : false; + this.vcpkgUrl = (_l = baseUtilLib.baseLib.getInput(exports.vcpkgUrlInput, false)) !== null && _l !== void 0 ? _l : VcpkgAction.DEFAULTVCPKGURL; + this.vcpkgCommitId = (_m = baseUtilLib.baseLib.getInput(exports.vcpkgCommitIdInput, false)) !== null && _m !== void 0 ? _m : null; + this.logCollectionRegExps = (_o = baseUtilLib.baseLib.getDelimitedInput(exports.logCollectionRegExpsInput, ';', false)) !== null && _o !== void 0 ? _o : []; + this.binaryCachePath = (_p = baseUtilLib.baseLib.getPathInput(exports.binaryCachePathInput, false, true)) !== null && _p !== void 0 ? _p : null; } run() { return __awaiter(this, void 0, void 0, function* () { @@ -163,7 +165,7 @@ class VcpkgAction { let vcpkgJsonFilePath = null; yield this.baseUtilLib.wrapOp('Compute vcpkg cache key', () => __awaiter(this, void 0, void 0, function* () { const [vcpkgJsonFile, vcpkgJsonHash, vcpkgConfigurationJsonHash] = yield vcpkgutil.Utils.getVcpkgJsonHash(this.baseUtilLib, this.vcpkgJsonGlob, this.vcpkgJsonIgnores); - keys = yield vcpkgutil.Utils.computeCacheKeys(this.baseUtilLib, vcpkgJsonHash, vcpkgConfigurationJsonHash, this.vcpkgRootDir, this.userProvidedCommitId, this.appendedCacheKey); + keys = yield vcpkgutil.Utils.computeCacheKeys(this.baseUtilLib, vcpkgJsonHash, vcpkgConfigurationJsonHash, this.vcpkgRootDir, this.userProvidedCommitId, this.appendedCacheKey, this.prependedCacheKey); if (keys) { baseLib.info(`Computed key: ${JSON.stringify(keys)}`); vcpkgJsonFilePath = vcpkgJsonFile; @@ -187,7 +189,7 @@ class VcpkgAction { return __awaiter(this, void 0, void 0, function* () { this.baseUtilLib.baseLib.debug("restoreCache()<<"); if (this.doNotCache) { - this.baseUtilLib.baseLib.info(`Skipping as caching is disabled(${exports.doNotCacheInput}: true)`); + this.baseUtilLib.baseLib.info(`Skipping saving cache as caching is disabled (${exports.doNotCacheInput}: ${this.doNotCache}).`); } else { if (!this.vcpkgRootDir) @@ -399,12 +401,13 @@ class Utils { return [null, null, null]; }); } - static computeCacheKeys(baseUtilLib, vcpkgJsonHash, vcpkgConfJsonHash, vcpkgDirectory, userProvidedCommitId, appendedCacheKey) { + static computeCacheKeys(baseUtilLib, vcpkgJsonHash, vcpkgConfJsonHash, vcpkgDirectory, userProvidedCommitId, appendedCacheKey, prependedCacheKey) { return __awaiter(this, void 0, void 0, function* () { baseUtilLib.baseLib.debug(`computeCacheKeys()<<`); const cacheKeySegments = []; // Add to the first segment of the key the values of env vars ImageOS and ImageVersion if available. - let firstSegment = `runnerOS=${process.env['ImageOS'] ? process.env['ImageOS'] : process.platform}`; + let firstSegment = prependedCacheKey ? `prependedKey=${prependedCacheKey}-` : ""; + firstSegment += `runnerOS=${process.env['ImageOS'] ? process.env['ImageOS'] : process.platform}`; firstSegment += process.env['ImageVersion'] || ""; const [commitId, isSubmodule] = yield Utils.getVcpkgCommitId(baseUtilLib, vcpkgDirectory); if (commitId) { diff --git a/package-lock.json b/package-lock.json index af9c52de..12822da0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1373,9 +1373,9 @@ } }, "node_modules/@lukka/action-lib/node_modules/ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz", + "integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==", "engines": { "node": ">=6" } @@ -1817,9 +1817,9 @@ } }, "node_modules/@lukka/base-lib/node_modules/ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz", + "integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==", "engines": { "node": ">=6" } @@ -2270,9 +2270,9 @@ } }, "node_modules/@lukka/run-vcpkg-lib/node_modules/ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz", + "integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==", "engines": { "node": ">=6" } @@ -4151,13 +4151,19 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001251", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001251.tgz", - "integrity": "sha512-HOe1r+9VkU4TFmnU70z+r7OLmtR+/chB1rdcJUeQlAinjEeb0cKL20tlAtOagNZhbrtLnCvV19B4FmF1rgzl6A==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - } + "version": "1.0.30001412", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001412.tgz", + "integrity": "sha512-+TeEIee1gS5bYOiuf+PS/kp2mrXic37Hl66VY6EAfxasIk5fELTktK2oOezYed12H8w7jt3s512PpulQidPjwA==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + } + ] }, "node_modules/capture-exit": { "version": "2.0.0", @@ -4224,7 +4230,7 @@ "node_modules/chokidar/node_modules/glob-parent": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", - "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", + "integrity": "sha512-E8Ak/2+dZY6fnzlR7+ueWvhsH1SjHr4jjss4YS/h4py44jY9MhK/VFdaZJAWDz6BbL21KeteKxFSFpq8OS5gVA==", "dev": true, "dependencies": { "is-glob": "^3.1.0", @@ -6168,7 +6174,7 @@ "node_modules/glob-stream": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/glob-stream/-/glob-stream-6.1.0.tgz", - "integrity": "sha1-cEXJlBOz65SIjYOrRtC0BMx73eQ=", + "integrity": "sha512-uMbLGAP3S2aDOHUDfdoYcdIePUCfysbAd0IAoWVZbeGU/oNQ8asHVSshLDJUPWxfzj8zsCG7/XeHPHTtow0nsw==", "dev": true, "dependencies": { "extend": "^3.0.0", @@ -6189,7 +6195,7 @@ "node_modules/glob-stream/node_modules/glob-parent": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", - "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", + "integrity": "sha512-E8Ak/2+dZY6fnzlR7+ueWvhsH1SjHr4jjss4YS/h4py44jY9MhK/VFdaZJAWDz6BbL21KeteKxFSFpq8OS5gVA==", "dev": true, "dependencies": { "is-glob": "^3.1.0", @@ -6411,9 +6417,9 @@ } }, "node_modules/gulp-eslint/node_modules/ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz", + "integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==", "dev": true, "engines": { "node": ">=6" @@ -6868,7 +6874,7 @@ "node_modules/gulp-install": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/gulp-install/-/gulp-install-1.1.0.tgz", - "integrity": "sha1-k4a0bLRmm0cle2rfTj6i6DySiho=", + "integrity": "sha512-oH/OHjy74cU8VCdpaGw8S7AX92ETB9Rhc8nucgVIYbp0ihX4CGWLvGDUKN1FGYD25YKHfGcl7jH8sUnuRbbBgA==", "dev": true, "dependencies": { "dargs": "^5.1.0", @@ -6999,7 +7005,7 @@ "node_modules/gulp-util": { "version": "3.0.8", "resolved": "https://registry.npmjs.org/gulp-util/-/gulp-util-3.0.8.tgz", - "integrity": "sha1-AFTh50RQLifATBh8PsxQXdVLu08=", + "integrity": "sha512-q5oWPc12lwSFS9h/4VIjG+1NuNDlJ48ywV2JKItY4Ycc/n1fXJeYPVQsfu5ZrhQi7FGSDBalwUCLar/GyHXKGw==", "deprecated": "gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5", "dev": true, "dependencies": { @@ -7087,7 +7093,7 @@ "node_modules/gulp-util/node_modules/lodash.template": { "version": "3.6.2", "resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-3.6.2.tgz", - "integrity": "sha1-+M3sxhaaJVvpCYrosMU9N4kx0U8=", + "integrity": "sha512-0B4Y53I0OgHUJkt+7RmlDFWKjVAI/YUpWNiL9GQz5ORDr4ttgfQGo+phBWKFLJbBdtOwgMuUkdOHOnPg45jKmQ==", "dev": true, "dependencies": { "lodash._basecopy": "^3.0.0", @@ -14152,9 +14158,9 @@ }, "dependencies": { "ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==" + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz", + "integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==" }, "ansi-styles": { "version": "3.2.1", @@ -14490,9 +14496,9 @@ }, "dependencies": { "ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==" + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz", + "integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==" }, "ansi-styles": { "version": "3.2.1", @@ -14837,9 +14843,9 @@ }, "dependencies": { "ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==" + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz", + "integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==" }, "ansi-styles": { "version": "3.2.1", @@ -16283,9 +16289,9 @@ "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==" }, "caniuse-lite": { - "version": "1.0.30001251", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001251.tgz", - "integrity": "sha512-HOe1r+9VkU4TFmnU70z+r7OLmtR+/chB1rdcJUeQlAinjEeb0cKL20tlAtOagNZhbrtLnCvV19B4FmF1rgzl6A==" + "version": "1.0.30001412", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001412.tgz", + "integrity": "sha512-+TeEIee1gS5bYOiuf+PS/kp2mrXic37Hl66VY6EAfxasIk5fELTktK2oOezYed12H8w7jt3s512PpulQidPjwA==" }, "capture-exit": { "version": "2.0.0", @@ -16337,7 +16343,7 @@ "glob-parent": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", - "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", + "integrity": "sha512-E8Ak/2+dZY6fnzlR7+ueWvhsH1SjHr4jjss4YS/h4py44jY9MhK/VFdaZJAWDz6BbL21KeteKxFSFpq8OS5gVA==", "dev": true, "requires": { "is-glob": "^3.1.0", @@ -17867,7 +17873,7 @@ "glob-stream": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/glob-stream/-/glob-stream-6.1.0.tgz", - "integrity": "sha1-cEXJlBOz65SIjYOrRtC0BMx73eQ=", + "integrity": "sha512-uMbLGAP3S2aDOHUDfdoYcdIePUCfysbAd0IAoWVZbeGU/oNQ8asHVSshLDJUPWxfzj8zsCG7/XeHPHTtow0nsw==", "dev": true, "requires": { "extend": "^3.0.0", @@ -17885,7 +17891,7 @@ "glob-parent": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", - "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", + "integrity": "sha512-E8Ak/2+dZY6fnzlR7+ueWvhsH1SjHr4jjss4YS/h4py44jY9MhK/VFdaZJAWDz6BbL21KeteKxFSFpq8OS5gVA==", "dev": true, "requires": { "is-glob": "^3.1.0", @@ -18067,9 +18073,9 @@ }, "dependencies": { "ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz", + "integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==", "dev": true }, "ansi-styles": { @@ -18420,7 +18426,7 @@ "gulp-install": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/gulp-install/-/gulp-install-1.1.0.tgz", - "integrity": "sha1-k4a0bLRmm0cle2rfTj6i6DySiho=", + "integrity": "sha512-oH/OHjy74cU8VCdpaGw8S7AX92ETB9Rhc8nucgVIYbp0ihX4CGWLvGDUKN1FGYD25YKHfGcl7jH8sUnuRbbBgA==", "dev": true, "requires": { "dargs": "^5.1.0", @@ -18532,7 +18538,7 @@ "gulp-util": { "version": "3.0.8", "resolved": "https://registry.npmjs.org/gulp-util/-/gulp-util-3.0.8.tgz", - "integrity": "sha1-AFTh50RQLifATBh8PsxQXdVLu08=", + "integrity": "sha512-q5oWPc12lwSFS9h/4VIjG+1NuNDlJ48ywV2JKItY4Ycc/n1fXJeYPVQsfu5ZrhQi7FGSDBalwUCLar/GyHXKGw==", "dev": true, "requires": { "array-differ": "^1.0.0", @@ -18601,7 +18607,7 @@ "lodash.template": { "version": "3.6.2", "resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-3.6.2.tgz", - "integrity": "sha1-+M3sxhaaJVvpCYrosMU9N4kx0U8=", + "integrity": "sha512-0B4Y53I0OgHUJkt+7RmlDFWKjVAI/YUpWNiL9GQz5ORDr4ttgfQGo+phBWKFLJbBdtOwgMuUkdOHOnPg45jKmQ==", "dev": true, "requires": { "lodash._basecopy": "^3.0.0", diff --git a/src/vcpkg-action.ts b/src/vcpkg-action.ts index c846cc19..ba99dcc3 100644 --- a/src/vcpkg-action.ts +++ b/src/vcpkg-action.ts @@ -24,6 +24,7 @@ export const vcpkgUrlInput = "VCPKGGITURL"; * The input's name for additional content for the cache key. */ export const appendedCacheKeyInput = 'APPENDEDCACHEKEY'; +export const prependedCacheKeyInput = 'PREPENDEDCACHEKEY'; export const logCollectionRegExpsInput = 'LOGCOLLECTIONREGEXPS'; // Saved data in the action, and consumed by post-action. @@ -42,6 +43,7 @@ export class VcpkgAction { private static readonly DEFAULTVCPKGURL = 'https://github.com/microsoft/vcpkg.git'; private readonly doNotCache: boolean = false; private readonly appendedCacheKey: string | null; + private readonly prependedCacheKey: string | null; private readonly runVcpkgFormatString: string | null; private readonly vcpkgJsonGlob: string; private readonly vcpkgJsonIgnores: string[]; @@ -58,6 +60,7 @@ export class VcpkgAction { constructor(private readonly baseUtilLib: baseutillib.BaseUtilLib) { // Fetch inputs. this.appendedCacheKey = baseUtilLib.baseLib.getInput(appendedCacheKeyInput, false) ?? null; + this.prependedCacheKey = baseUtilLib.baseLib.getInput(prependedCacheKeyInput, false) ?? null; const vcpkgRootDir = baseUtilLib.baseLib.getPathInput(vcpkgDirectoryInput, false, false); this.vcpkgRootDir = vcpkgRootDir ? path.normalize(path.resolve(vcpkgRootDir)) : null; this.userProvidedCommitId = baseUtilLib.baseLib.getInput(vcpkgCommitIdInput, false) ?? null; @@ -116,7 +119,8 @@ export class VcpkgAction { vcpkgConfigurationJsonHash, this.vcpkgRootDir as string, this.userProvidedCommitId, - this.appendedCacheKey); + this.appendedCacheKey, + this.prependedCacheKey); if (keys) { baseLib.info(`Computed key: ${JSON.stringify(keys)}`); @@ -152,7 +156,7 @@ export class VcpkgAction { private async restoreCache(keys: baseutillib.KeySet): Promise { this.baseUtilLib.baseLib.debug("restoreCache()<<"); if (this.doNotCache) { - this.baseUtilLib.baseLib.info(`Skipping as caching is disabled(${doNotCacheInput}: true)`); + this.baseUtilLib.baseLib.info(`Skipping saving cache as caching is disabled (${doNotCacheInput}: ${this.doNotCache}).`); } else { if (!this.vcpkgRootDir) throw new Error("vcpkg_ROOT must be defined"); const pathsToCache: string[] = vcpkgutil.Utils.getAllCachedPaths( diff --git a/src/vcpkg-utils.ts b/src/vcpkg-utils.ts index 4fe9dde3..60ce7e91 100644 --- a/src/vcpkg-utils.ts +++ b/src/vcpkg-utils.ts @@ -90,12 +90,14 @@ export class Utils { vcpkgConfJsonHash: string | null, vcpkgDirectory: string, userProvidedCommitId: string | null, - appendedCacheKey: string | null): Promise { + appendedCacheKey: string | null, + prependedCacheKey: string | null): Promise { baseUtilLib.baseLib.debug(`computeCacheKeys()<<`); const cacheKeySegments: string[] = []; // Add to the first segment of the key the values of env vars ImageOS and ImageVersion if available. - let firstSegment = `runnerOS=${process.env['ImageOS'] ? process.env['ImageOS'] : process.platform}`; + let firstSegment = prependedCacheKey ? `prependedKey=${prependedCacheKey}-` : ""; + firstSegment += `runnerOS=${process.env['ImageOS'] ? process.env['ImageOS'] : process.platform}`; firstSegment += process.env['ImageVersion'] || ""; const [commitId, isSubmodule] = await Utils.getVcpkgCommitId(baseUtilLib, vcpkgDirectory);