mirror of
https://code.forgejo.org/actions/setup-go.git
synced 2025-03-01 12:43:26 +00:00
Some checks failed
Basic validation / Basic validation (push) Failing after 0s
Check dist/ / Check dist/ (push) Failing after -1m18s
CodeQL analysis / CodeQL analysis (push) Failing after 0s
Licensed / Licensed (push) Failing after -1m18s
Validate 'setup-go' / stable (macos-latest) (push) Has been cancelled
Validate 'setup-go' / stable (ubuntu-latest) (push) Has been cancelled
Validate 'setup-go' / stable (windows-latest) (push) Has been cancelled
Validate 'setup-go' / oldstable (macos-latest) (push) Has been cancelled
Validate 'setup-go' / oldstable (ubuntu-latest) (push) Has been cancelled
Validate 'setup-go' / oldstable (windows-latest) (push) Has been cancelled
Validate 'setup-go' / Setup local-cache version (push) Has been cancelled
Validate 'setup-go' / aliases-arch (x32, ubuntu-latest, oldstable) (push) Has been cancelled
Validate 'setup-go' / aliases-arch (x32, ubuntu-latest, stable) (push) Has been cancelled
Validate 'setup-go' / aliases-arch (x32, windows-latest, oldstable) (push) Has been cancelled
Validate 'setup-go' / aliases-arch (x32, windows-latest, stable) (push) Has been cancelled
Validate 'setup-go' / aliases-arch (x64, macos-latest, oldstable) (push) Has been cancelled
Validate 'setup-go' / aliases-arch (x64, macos-latest, stable) (push) Has been cancelled
Validate 'setup-go' / aliases-arch (x64, ubuntu-latest, oldstable) (push) Has been cancelled
Validate 'setup-go' / aliases-arch (x64, ubuntu-latest, stable) (push) Has been cancelled
Validate 'setup-go' / aliases-arch (x64, windows-latest, oldstable) (push) Has been cancelled
Validate 'setup-go' / aliases-arch (x64, windows-latest, stable) (push) Has been cancelled
Validate 'setup-go' / check-latest (1.20.14, macos-latest) (push) Has been cancelled
Validate 'setup-go' / check-latest (1.20.14, ubuntu-latest) (push) Has been cancelled
Validate 'setup-go' / check-latest (1.20.14, windows-latest) (push) Has been cancelled
Validate 'setup-go' / check-latest (1.21, macos-latest) (push) Has been cancelled
Validate 'setup-go' / check-latest (1.21, ubuntu-latest) (push) Has been cancelled
Validate 'setup-go' / check-latest (1.21, windows-latest) (push) Has been cancelled
Validate 'setup-go' / go-version-file (macos-latest) (push) Has been cancelled
Validate 'setup-go' / go-version-file (ubuntu-latest) (push) Has been cancelled
Validate 'setup-go' / go-version-file (windows-latest) (push) Has been cancelled
Validate 'setup-go' / go-version-file-with-gowork (macos-latest) (push) Has been cancelled
Validate 'setup-go' / go-version-file-with-gowork (ubuntu-latest) (push) Has been cancelled
Validate 'setup-go' / go-version-file-with-gowork (windows-latest) (push) Has been cancelled
Validate 'setup-go' / Setup 1.20.14 macos-latest (push) Has been cancelled
Validate 'setup-go' / Setup 1.20.14 ubuntu-latest (push) Has been cancelled
Validate 'setup-go' / Setup 1.20.14 windows-latest (push) Has been cancelled
Validate 'setup-go' / Setup 1.21.10 macos-latest (push) Has been cancelled
Validate 'setup-go' / Setup 1.21.10 ubuntu-latest (push) Has been cancelled
Validate 'setup-go' / Setup 1.21.10 windows-latest (push) Has been cancelled
Validate 'setup-go' / Setup 1.22.3 macos-latest (push) Has been cancelled
Validate 'setup-go' / Setup 1.22.3 ubuntu-latest (push) Has been cancelled
Validate 'setup-go' / Setup 1.22.3 windows-latest (push) Has been cancelled
Validate 'setup-go' / Setup 1.21 macos-latest (push) Has been cancelled
Validate 'setup-go' / Setup 1.21 ubuntu-latest (push) Has been cancelled
Validate 'setup-go' / Setup 1.21 windows-latest (push) Has been cancelled
Validate 'setup-go' / architecture (1.20.14, macos-latest) (push) Has been cancelled
Validate 'setup-go' / architecture (1.20.14, ubuntu-latest) (push) Has been cancelled
Validate 'setup-go' / architecture (1.20.14, windows-latest) (push) Has been cancelled
Validate 'setup-go' / architecture (1.21, macos-latest) (push) Has been cancelled
Validate 'setup-go' / architecture (1.21, ubuntu-latest) (push) Has been cancelled
Validate 'setup-go' / architecture (1.21, windows-latest) (push) Has been cancelled
Validate Windows installation / Validate if symlink is created (push) Has been cancelled
Validate Windows installation / Find default go version (push) Has been cancelled
Validate Windows installation / Validate if hostedtoolcache works as expected (push) Has been cancelled
Validate Windows installation / Validate if symlink is not created for default go (push) Has been cancelled
* Revise `isGhes` logic * ran `npm run format` * added unit test * tweaked unit test * ran `npm run format`
91 lines
2.5 KiB
TypeScript
91 lines
2.5 KiB
TypeScript
import * as cache from '@actions/cache';
|
|
import * as core from '@actions/core';
|
|
import * as exec from '@actions/exec';
|
|
import {supportedPackageManagers, PackageManagerInfo} from './package-managers';
|
|
|
|
export const getCommandOutput = async (toolCommand: string) => {
|
|
let {stdout, stderr, exitCode} = await exec.getExecOutput(
|
|
toolCommand,
|
|
undefined,
|
|
{ignoreReturnCode: true}
|
|
);
|
|
|
|
if (exitCode) {
|
|
stderr = !stderr.trim()
|
|
? `The '${toolCommand}' command failed with exit code: ${exitCode}`
|
|
: stderr;
|
|
throw new Error(stderr);
|
|
}
|
|
|
|
return stdout.trim();
|
|
};
|
|
|
|
export const getPackageManagerInfo = async (packageManager: string) => {
|
|
if (!supportedPackageManagers[packageManager]) {
|
|
throw new Error(
|
|
`It's not possible to use ${packageManager}, please, check correctness of the package manager name spelling.`
|
|
);
|
|
}
|
|
const obtainedPackageManager = supportedPackageManagers[packageManager];
|
|
|
|
return obtainedPackageManager;
|
|
};
|
|
|
|
export const getCacheDirectoryPath = async (
|
|
packageManagerInfo: PackageManagerInfo
|
|
) => {
|
|
const pathOutputs = await Promise.allSettled(
|
|
packageManagerInfo.cacheFolderCommandList.map(async command =>
|
|
getCommandOutput(command)
|
|
)
|
|
);
|
|
|
|
const results = pathOutputs.map(item => {
|
|
if (item.status === 'fulfilled') {
|
|
return item.value;
|
|
} else {
|
|
core.info(`[warning]getting cache directory path failed: ${item.reason}`);
|
|
}
|
|
|
|
return '';
|
|
});
|
|
|
|
const cachePaths = results.filter(item => item);
|
|
|
|
if (!cachePaths.length) {
|
|
throw new Error(`Could not get cache folder paths.`);
|
|
}
|
|
|
|
return cachePaths;
|
|
};
|
|
|
|
export function isGhes(): boolean {
|
|
const ghUrl = new URL(
|
|
process.env['GITHUB_SERVER_URL'] || 'https://github.com'
|
|
);
|
|
|
|
const hostname = ghUrl.hostname.trimEnd().toUpperCase();
|
|
const isGitHubHost = hostname === 'GITHUB.COM';
|
|
const isGitHubEnterpriseCloudHost = hostname.endsWith('.GHE.COM');
|
|
const isLocalHost = hostname.endsWith('.LOCALHOST');
|
|
|
|
return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost;
|
|
}
|
|
|
|
export function isCacheFeatureAvailable(): boolean {
|
|
if (cache.isFeatureAvailable()) {
|
|
return true;
|
|
}
|
|
|
|
if (isGhes()) {
|
|
core.warning(
|
|
'Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.'
|
|
);
|
|
return false;
|
|
}
|
|
|
|
core.warning(
|
|
'The runner was not able to contact the cache service. Caching will be skipped'
|
|
);
|
|
return false;
|
|
}
|