Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function runLHCITarget(options) {
if (!options.token) throw new Error('Must provide token for LHCI target');
const api = new ApiClient({rootURL: options.serverBaseUrl, extraHeaders: options.extraHeaders});
const project = await api.findProjectByToken(options.token);
if (!project) {
throw new Error('Could not find active project with provided token');
}
const hash = getCurrentHash();
const branch = getCurrentBranch();
const ancestorHash =
branch === 'master' ? getAncestorHashForMaster() : getAncestorHashForBranch();
const build = await api.createBuild({
projectId: project.id,
lifecycle: 'unsealed',
hash,
branch,
ancestorHash,
commitMessage: getCommitMessage(hash),
author: getAuthor(hash),
avatarUrl: getAvatarUrl(hash),
externalBuildUrl: getExternalBuildUrl(),
runAt: new Date().toISOString(),
committedAt: getCommitTime(hash),
async function runGithubStatusCheck(options, targetUrlMap) {
const hash = getCurrentHash();
const slug = getGitHubRepoSlug();
const {githubToken, githubAppToken} = options;
if (!githubToken && !githubAppToken) return print('No GitHub token set, skipping.\n');
print('GitHub token found, attempting to set status...\n');
if (!slug) return print(`No GitHub remote found, skipping.\n`);
if (!slug.includes('/')) return print(`Invalid repo slug "${slug}", skipping.\n`);
if (!hash) return print(`Invalid hash "${hash}"\n, skipping.`);
const assertionResults = loadAssertionResults();
const groupedResults = _.groupBy(assertionResults, result => result.url).sort(
(a, b) => a[0].url.length - b[0].url.length
);
if (groupedResults.length) {
for (const group of groupedResults) {
test: async ({serverBaseUrl = '', token = ''}) => {
const client = new ApiClient({rootURL: serverBaseUrl});
const project = await client.findProjectByToken(token);
if (!project) return true;
const builds = await client.getBuilds(project.id, {
branch: getCurrentBranch(),
hash: getCurrentHash(),
});
return builds.length === 0;
},
},