Skip to content

Commit

Permalink
Use a new Mason environment variable instead of a set location
Browse files Browse the repository at this point in the history
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 <lydia-duncan@users.noreply.github.com>
  • Loading branch information
lydia-duncan committed Oct 3, 2024
1 parent 56e7575 commit fc8122a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
20 changes: 15 additions & 5 deletions test/mason/EXECENV
100644 → 100755
Original file line number Diff line number Diff line change
@@ -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)
10 changes: 10 additions & 0 deletions tools/mason/MasonEnv.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
3 changes: 2 additions & 1 deletion tools/mason/MasonPublish.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit fc8122a

Please sign in to comment.