From fc8122a1ea7c801c232cdac010f3c4c88088e29d Mon Sep 17 00:00:00 2001 From: Lydia Duncan Date: Thu, 3 Oct 2024 15:11:35 -0700 Subject: [PATCH] Use a new Mason environment variable instead of a set location Adds `MASON_LICENSE_CACHE_PATH` as something that Mason understands, and when it is specified, use it with `--reference-if-able` when downloading the license repository. Updates the test EXECENV to set this environment variable to REPO_CACHE_PATH, which we use for other cached repositories in nightly testing, but only if that environment variable is defined. This should allow fellow team members to not have to set this environment variable (because they probably won't need it) ---- Signed-off-by: Lydia Duncan --- test/mason/EXECENV | 20 +++++++++++++++----- tools/mason/MasonEnv.chpl | 10 ++++++++++ tools/mason/MasonPublish.chpl | 3 ++- 3 files changed, 27 insertions(+), 6 deletions(-) mode change 100644 => 100755 test/mason/EXECENV diff --git a/test/mason/EXECENV b/test/mason/EXECENV old mode 100644 new mode 100755 index a8780d12d32e..8789b269f5d5 --- a/test/mason/EXECENV +++ b/test/mason/EXECENV @@ -1,9 +1,19 @@ +#!/usr/bin/env python3 + +import os + # Ensure mason in PATH -PATH=$CHPL_HOME/bin/$CHPL_HOST_BIN_SUBDIR:$PATH +print('PATH=$CHPL_HOME/bin/$CHPL_HOST_BIN_SUBDIR:$PATH') # Mason envs -MASON_HOME=$PWD/mason_home +print('MASON_HOME=$PWD/mason_home') + # Note, this registry should only ever be used by mason update tests -MASON_REGISTRY=registry|https://github.com/chapel-lang/mason-registry -MASON_OFFLINE=false -SPACK_ROOT=$PWD/mason_home/spack + +print('MASON_REGISTRY=registry|https://github.com/chapel-lang/mason-registry') +print('MASON_OFFLINE=false') +print('SPACK_ROOT=$MASON_HOME/spack') + +cachePath = os.getenv('REPO_CACHE_PATH', default='') +if cachePath != '': + print('MASON_LICENSE_CACHE_PATH=' + cachePath) diff --git a/tools/mason/MasonEnv.chpl b/tools/mason/MasonEnv.chpl index f199f7a8672e..027dbd546772 100644 --- a/tools/mason/MasonEnv.chpl +++ b/tools/mason/MasonEnv.chpl @@ -112,6 +112,16 @@ proc MASON_REGISTRY { return registries; } +/* Returns the path to use when caching the list of licenses, if provided by the + user. This is useful for systems where internet connectivity can be erratic + or slow. + */ +proc MASON_LICENSE_CACHE_PATH: string { + const licenseCache = getEnv("MASON_LICENSE_CACHE_PATH"); + + return licenseCache; +} + proc masonEnv(args) { var parser = new argumentParser(helpHandler=new MasonEnvHelpHandler()); diff --git a/tools/mason/MasonPublish.chpl b/tools/mason/MasonPublish.chpl index 02d610e33f79..6d0f2e767ae8 100644 --- a/tools/mason/MasonPublish.chpl +++ b/tools/mason/MasonPublish.chpl @@ -690,7 +690,8 @@ proc refreshLicenseList(overwrite=false) throws { const branch = '--branch main '; const depth = '--depth 1 '; const url = 'https://github.com/spdx/license-list-data.git '; - const referIfAble = " --reference-if-able " + dest; + const referIfAble = if MASON_LICENSE_CACHE_PATH != "" then + " --reference-if-able " + MASON_LICENSE_CACHE_PATH + "/spdx" else ""; const command = 'git clone -q ' + branch + depth + url + dest + referIfAble; if !isDir(dest) { runCommand(command);