Skip to content

Commit

Permalink
redist
Browse files Browse the repository at this point in the history
  • Loading branch information
jaimergp committed Apr 23, 2024
1 parent dceb88d commit a587dba
Show file tree
Hide file tree
Showing 16 changed files with 4,600 additions and 53,205 deletions.
25,801 changes: 933 additions & 24,868 deletions dist/delete/index.js

Large diffs are not rendered by default.

31,873 changes: 3,602 additions & 28,271 deletions dist/setup/index.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/base-tools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const TOOL_PROVIDERS: types.IToolProvider[] = [
*/
export async function installBaseTools(
inputs: types.IActionInputs,
options: types.IDynamicOptions,
options: types.IDynamicOptions
) {
let tools = [];
let postInstallOptions = { ...options };
Expand All @@ -47,7 +47,7 @@ export async function installBaseTools(
postInstallOptions = { ...postInstallOptions, ...toolUpdates.options };
if (provider.postInstall) {
core.info(
`... we will perform post-install steps after we ${provider.label}.`,
`... we will perform post-install steps after we ${provider.label}.`
);
postInstallActions.push(provider.postInstall);
}
Expand Down
14 changes: 7 additions & 7 deletions src/conda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function envCommandFlag(inputs: types.IActionInputs): string[] {
*/
export function condaExecutable(
options: types.IDynamicOptions,
subcommand?: string,
subcommand?: string
): string {
const dir: string = condaBasePath(options);
let condaExe: string;
Expand All @@ -71,7 +71,7 @@ export function isMambaInstalled(options: types.IDynamicOptions) {
*/
export async function condaCommand(
cmd: string[],
options: types.IDynamicOptions,
options: types.IDynamicOptions
): Promise<void> {
const command = [condaExecutable(options, cmd[0]), ...cmd];
return await utils.execute(command);
Expand All @@ -83,7 +83,7 @@ export async function condaCommand(
export async function bootstrapConfig(): Promise<void> {
await fs.promises.writeFile(
constants.CONDARC_PATH,
constants.BOOTSTRAP_CONDARC,
constants.BOOTSTRAP_CONDARC
);
}

Expand All @@ -93,7 +93,7 @@ export async function bootstrapConfig(): Promise<void> {
export async function copyConfig(inputs: types.IActionInputs) {
const sourcePath: string = path.join(
process.env["GITHUB_WORKSPACE"] || "",
inputs.condaConfigFile,
inputs.condaConfigFile
);
core.info(`Copying "${sourcePath}" to "${constants.CONDARC_PATH}..."`);
await io.cp(sourcePath, constants.CONDARC_PATH);
Expand All @@ -104,11 +104,11 @@ export async function copyConfig(inputs: types.IActionInputs) {
*/
export async function applyCondaConfiguration(
inputs: types.IActionInputs,
options: types.IDynamicOptions,
options: types.IDynamicOptions
): Promise<void> {
const configEntries = Object.entries(inputs.condaConfig) as [
keyof types.ICondaConfig,
string,
string
][];

// Channels are special: if specified as an action input, these take priority
Expand Down Expand Up @@ -153,7 +153,7 @@ export async function applyCondaConfiguration(
*/
export async function condaInit(
inputs: types.IActionInputs,
options: types.IDynamicOptions,
options: types.IDynamicOptions
): Promise<void> {
let ownPath: string;
const isValidActivate = !utils.isBaseEnv(inputs.activateEnvironment);
Expand Down
2 changes: 1 addition & 1 deletion src/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async function run(): Promise<void> {

if (fs.existsSync(cacheFolder) && fs.lstatSync(cacheFolder).isDirectory()) {
core.startGroup(
"Removing uncompressed packages to trim down cache folder...",
"Removing uncompressed packages to trim down cache folder..."
);
let fullPath: string;
for (let folder_or_file of fs.readdirSync(cacheFolder)) {
Expand Down
4 changes: 2 additions & 2 deletions src/env/explicit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ export const ensureExplicit: types.IEnvProvider = {
condaArgs: async (inputs, options) => {
if (inputs.pythonVersion) {
throw Error(
`'python-version: ${inputs.pythonVersion}' is incompatible with an explicit 'environmentFile`,
`'python-version: ${inputs.pythonVersion}' is incompatible with an explicit 'environmentFile`
);
}

if (options.envSpec?.explicit) {
outputs.setEnvironmentFileOutputs(
inputs.environmentFile,
options.envSpec.explicit,
options.envSpec.explicit
);
}

Expand Down
10 changes: 5 additions & 5 deletions src/env/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const ENV_PROVIDERS: types.IEnvProvider[] = [
*/
export async function ensureEnvironment(
inputs: types.IActionInputs,
options: types.IDynamicOptions,
options: types.IDynamicOptions
): Promise<void> {
for (const provider of ENV_PROVIDERS) {
core.info(`Can we ${provider.label}?`);
Expand All @@ -42,13 +42,13 @@ export async function ensureEnvironment(
const args = await provider.condaArgs(inputs, options);
return await core.group(
`Updating '${inputs.activateEnvironment}' env from ${provider.label}...`,
() => conda.condaCommand(args, options),
() => conda.condaCommand(args, options)
);
}
}

throw Error(
`'activate-environment: ${inputs.activateEnvironment}' could not be created`,
`'activate-environment: ${inputs.activateEnvironment}' could not be created`
);
}

Expand All @@ -64,15 +64,15 @@ export async function ensureEnvironment(
* multiple files, alternate inputs, etc.
*/
export async function getEnvSpec(
inputs: types.IActionInputs,
inputs: types.IActionInputs
): Promise<types.IEnvSpec> {
if (!inputs.environmentFile) {
return {};
}

const sourceEnvironmentPath: string = path.join(
process.env["GITHUB_WORKSPACE"] || "",
inputs.environmentFile,
inputs.environmentFile
);

const source = fs.readFileSync(sourceEnvironmentPath, "utf8");
Expand Down
10 changes: 5 additions & 5 deletions src/env/yaml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ interface IYAMLEnvPatchProvider {
/** Whether this patch should be applied for the given `inputs` and `options` */
provides: (
inputs: types.IActionInputs,
options: types.IDynamicOptions,
options: types.IDynamicOptions
) => boolean;
/** A regular expression for detecting whether a spec will need to be replaced */
specMatch: RegExp;
Expand Down Expand Up @@ -66,7 +66,7 @@ export const ensureYaml: types.IEnvProvider = {
const yamlData = options.envSpec?.yaml;
if (yamlData == null) {
throw Error(
`'environment-file: ${inputs.environmentFile}' appears to be malformed`,
`'environment-file: ${inputs.environmentFile}' appears to be malformed`
);
}

Expand Down Expand Up @@ -112,10 +112,10 @@ export const ensureYaml: types.IEnvProvider = {
const origParent = path.dirname(origPath);
envFile = path.join(
origParent,
`setup-miniconda-patched-${path.basename(origPath)}`,
`setup-miniconda-patched-${path.basename(origPath)}`
);
core.info(
`Making patched copy of 'environment-file: ${inputs.environmentFile}'`,
`Making patched copy of 'environment-file: ${inputs.environmentFile}'`
);
core.info(`Using: ${envFile}\n${patchedYaml}`);
fs.writeFileSync(envFile, patchedYaml, "utf8");
Expand All @@ -124,7 +124,7 @@ export const ensureYaml: types.IEnvProvider = {
core.info(`Using 'environment-file: ${inputs.environmentFile}' as-is`);
outputs.setEnvironmentFileOutputs(
envFile,
fs.readFileSync(inputs.environmentFile, "utf-8"),
fs.readFileSync(inputs.environmentFile, "utf-8")
);
}

Expand Down
15 changes: 7 additions & 8 deletions src/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ import * as types from "./types";
* network calls or subprocesses).
*/
interface IRule {
(
inputs: types.IActionInputs,
condaConfig: types.ICondaConfig,
): string | false;
(inputs: types.IActionInputs, condaConfig: types.ICondaConfig):
| string
| false;
}

const urlExt = (url: string) => path.posix.extname(new URL(url).pathname);
Expand Down Expand Up @@ -61,12 +60,12 @@ const RULES: IRule[] = [
constants.KNOWN_EXTENSIONS
}`,
(
i, // Miniconda x86 is only published for Windows lately (last Linux was 2019, last MacOS 2015)
i // Miniconda x86 is only published for Windows lately (last Linux was 2019, last MacOS 2015)
) =>
!!(i.architecture === "x86" && !constants.IS_WINDOWS) &&
`'architecture: ${i.architecture}' is only available for recent versions on Windows`,
(
i, // We only support miniconda 4.6 or later (`conda init` and /condabin were added here, which we need)
i // We only support miniconda 4.6 or later (`conda init` and /condabin were added here, which we need)
) =>
!!(
!["latest", ""].includes(i.minicondaVersion) &&
Expand Down Expand Up @@ -97,7 +96,7 @@ export async function parseInputs(): Promise<types.IActionInputs> {
condaConfig: Object.freeze({
add_anaconda_token: core.getInput("add-anaconda-token"),
add_pip_as_python_dependency: core.getInput(
"add-pip-as-python-dependency",
"add-pip-as-python-dependency"
),
allow_softlinks: core.getInput("allow-softlinks"),
auto_activate_base: core.getInput("auto-activate-base"),
Expand All @@ -113,7 +112,7 @@ export async function parseInputs(): Promise<types.IActionInputs> {
changeps1: "false",
}),
cleanPatchedEnvironmentFile: core.getInput(
"clean-patched-environment-file",
"clean-patched-environment-file"
),
runPost: core.getInput("run-post"),
});
Expand Down
8 changes: 4 additions & 4 deletions src/installer/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import * as types from "../types";
* - or has been renamed during a build process
*/
export async function ensureLocalInstaller(
options: types.ILocalInstallerOpts,
options: types.ILocalInstallerOpts
): Promise<string> {
core.info("Ensuring Installer...");

Expand Down Expand Up @@ -51,7 +51,7 @@ export async function ensureLocalInstaller(
let cacheDirectoryPath = tc.find(
installerName,
version,
...(options.arch ? [options.arch] : []),
...(options.arch ? [options.arch] : [])
);
if (cacheDirectoryPath !== "") {
core.info(`Found ${installerName} cache at ${cacheDirectoryPath}!`);
Expand All @@ -68,7 +68,7 @@ export async function ensureLocalInstaller(
if (executablePath === "") {
const rawDownloadPath = await tc.downloadTool(options.url);
core.info(
`Downloaded ${installerName}, ensuring extension ${installerExtension}`,
`Downloaded ${installerName}, ensuring extension ${installerExtension}`
);
// Always ensure the installer ends with a known path
executablePath = rawDownloadPath + installerExtension;
Expand All @@ -79,7 +79,7 @@ export async function ensureLocalInstaller(
installerName,
tool,
version,
...(options.arch ? [options.arch] : []),
...(options.arch ? [options.arch] : [])
);
core.info(`Cached ${tool}@${version}: ${cacheResult}!`);
}
Expand Down
8 changes: 4 additions & 4 deletions src/installer/download-miniconda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ async function minicondaVersions(arch: string): Promise<string[]> {
try {
let extension: string = constants.IS_UNIX ? "sh" : "exe";
const downloadPath: string = await tc.downloadTool(
constants.MINICONDA_BASE_URL,
constants.MINICONDA_BASE_URL
);
const content: string = fs.readFileSync(downloadPath, "utf8");
let hrefs: string[] = getHrefs(content);
hrefs = hrefs.filter((item: string) => item.startsWith("/Miniconda3"));
hrefs = hrefs.filter((item: string) =>
item.endsWith(`${arch}.${extension}`),
item.endsWith(`${arch}.${extension}`)
);
hrefs = hrefs.map((item: string) => item.substring(1));
return hrefs;
Expand All @@ -44,7 +44,7 @@ async function minicondaVersions(arch: string): Promise<string[]> {
*/
export async function downloadMiniconda(
pythonMajorVersion: number,
inputs: types.IActionInputs,
inputs: types.IActionInputs
): Promise<string> {
// Check valid arch
let arch: string =
Expand All @@ -68,7 +68,7 @@ export async function downloadMiniconda(
if (versions) {
if (!versions.includes(minicondaInstallerName)) {
throw new Error(
`Invalid miniconda version!\n\nMust be among ${versions.toString()}`,
`Invalid miniconda version!\n\nMust be among ${versions.toString()}`
);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/installer/download-miniforge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as base from "./base";
*/
export async function downloadMiniforge(
inputs: types.IActionInputs,
options: types.IDynamicOptions,
options: types.IDynamicOptions
): Promise<string> {
const tool =
inputs.miniforgeVariant.trim() || constants.MINIFORGE_DEFAULT_VARIANT;
Expand All @@ -33,13 +33,13 @@ export async function downloadMiniforge(
// e.g. https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh
fileName = [tool, osName, `${arch}.${extension}`].join("-");
url = [constants.MINIFORGE_URL_PREFIX, version, "download", fileName].join(
"/",
"/"
);
} else {
// e.g. https://github.com/conda-forge/miniforge/releases/download/4.9.2-5/Miniforge3-4.9.2-5-Linux-x86_64.sh
fileName = [tool, version, osName, `${arch}.${extension}`].join("-");
url = [constants.MINIFORGE_URL_PREFIX, "download", version, fileName].join(
"/",
"/"
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/installer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const INSTALLER_PROVIDERS: types.IInstallerProvider[] = [
/** See if any provider works with the given inputs and options */
export async function getLocalInstallerPath(
inputs: types.IActionInputs,
options: types.IDynamicOptions,
options: types.IDynamicOptions
) {
for (const provider of INSTALLER_PROVIDERS) {
core.info(`Can we ${provider.label}?`);
Expand All @@ -57,7 +57,7 @@ export async function runInstaller(
installerPath: string,
outputPath: string,
inputs: types.IActionInputs,
options: types.IDynamicOptions,
options: types.IDynamicOptions
): Promise<types.IDynamicOptions> {
const installerExtension = path.extname(installerPath);
let command: string[];
Expand Down
6 changes: 3 additions & 3 deletions src/outputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import * as utils from "./utils";
* Add Conda executable to PATH environment variable
*/
export async function setPathVariables(
options: types.IDynamicOptions,
options: types.IDynamicOptions
): Promise<void> {
const condaBin: string = path.join(conda.condaBasePath(options), "condabin");
const condaPath: string = conda.condaBasePath(options);
Expand All @@ -41,13 +41,13 @@ export async function setCacheVariable(options: types.IDynamicOptions) {
export function setEnvironmentFileOutputs(
envFile: string,
envContent: string,
patched = false,
patched = false
): void {
core.setOutput(constants.OUTPUT_ENV_FILE_PATH, path.resolve(envFile));
core.setOutput(constants.OUTPUT_ENV_FILE_CONTENT, envContent);
core.setOutput(
constants.OUTPUT_ENV_FILE_WAS_PATCHED,
patched ? "true" : "false",
patched ? "true" : "false"
);
core.saveState(constants.OUTPUT_ENV_FILE_WAS_PATCHED, patched);
}
Loading

0 comments on commit a587dba

Please sign in to comment.