From 0acdb790edf593eba2c908f2afa5466a508543ad Mon Sep 17 00:00:00 2001 From: Pau Ruiz Safont Date: Thu, 16 Mar 2023 10:59:03 +0000 Subject: [PATCH] setup-ocaml/cache: generate key for local repositories The location might be a relative filepath instead of a url, create a fallback path for these, sidestepping opam to create the url for all cases. --- CHANGELOG.md | 4 ++++ dist/index.js | 11 ++++++++--- dist/post/index.js | 11 ++++++++--- src/setup-ocaml/cache.ts | 10 +++++++--- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d33f83f7..da42208d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ and this project adheres to ## [unreleased] +### Fixed + +- Ensure cache key creation works with local opam repositories. + ## [2.0.12] ### Changed diff --git a/dist/index.js b/dist/index.js index f48cc837..bfb9a70a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -122123,9 +122123,14 @@ async function composeOpamCacheKeys() { } function composeOpamDownloadCacheKeys() { const repositories = OPAM_REPOSITORIES.map(([, u]) => { - const url = new URL(u); - const urn = external_node_path_namespaceObject.join(url.hostname, url.pathname); - return urn; + try { + const url = new URL(u); + const urn = external_node_path_namespaceObject.join(url.hostname, url.pathname); + return urn; + } + catch { + return external_node_path_namespaceObject.resolve(u); + } }).join("_"); const ocamlVersion = OCAML_COMPILER.toLowerCase().replace(/\W/g, "_"); const { year, month, date } = composeDate(); diff --git a/dist/post/index.js b/dist/post/index.js index 47d92937..b0266b2a 100644 --- a/dist/post/index.js +++ b/dist/post/index.js @@ -118347,9 +118347,14 @@ async function composeOpamCacheKeys() { } function composeOpamDownloadCacheKeys() { const repositories = OPAM_REPOSITORIES.map(([, u]) => { - const url = new URL(u); - const urn = external_node_path_namespaceObject.join(url.hostname, url.pathname); - return urn; + try { + const url = new URL(u); + const urn = external_node_path_namespaceObject.join(url.hostname, url.pathname); + return urn; + } + catch { + return external_node_path_namespaceObject.resolve(u); + } }).join("_"); const ocamlVersion = constants_OCAML_COMPILER.toLowerCase().replace(/\W/g, "_"); const { year, month, date } = composeDate(); diff --git a/src/setup-ocaml/cache.ts b/src/setup-ocaml/cache.ts index e4f665aa..07242bc0 100644 --- a/src/setup-ocaml/cache.ts +++ b/src/setup-ocaml/cache.ts @@ -95,9 +95,13 @@ async function composeOpamCacheKeys() { function composeOpamDownloadCacheKeys() { const repositories = OPAM_REPOSITORIES.map(([, u]) => { - const url = new URL(u); - const urn = path.join(url.hostname, url.pathname); - return urn; + try { + const url = new URL(u); + const urn = path.join(url.hostname, url.pathname); + return urn; + } catch { + return path.resolve(u); + } }).join("_"); const ocamlVersion = OCAML_COMPILER.toLowerCase().replace(/\W/g, "_"); const { year, month, date } = composeDate();