@actions/core#debug TypeScript Examples

The following examples show how to use @actions/core#debug. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ArchiveTools.ts    From powershell with MIT License 6 votes vote down vote up
private async unzipUsingPowerShell(zipPath: string, destination: string) {
        debug(`Using powershell Expand-Archive cmdlet to extract ${zipPath} to ${destination}`);
        const script = `
            $prevProgressPref = $ProgressPreference
            $ProgressPreference = 'SilentlyContinue'
            Expand-Archive -Path ${zipPath} -DestinationPath ${destination}
            $ProgressPreference = $prevProgressPref`;
        await PowerShellToolRunner.init();
        const exitCode = await PowerShellToolRunner.executePowerShellScriptBlock(script);
        if (exitCode != 0) {
            throw new Error(`Extraction using Expand-Archive cmdlet failed from ${zipPath} to ${destination}`);
        }
    }
Example #2
Source File: platform.ts    From cuda-toolkit with MIT License 6 votes vote down vote up
export async function getOs(): Promise<OSType> {
  const osPlatform = os.platform()
  switch (osPlatform) {
    case 'win32':
      return OSType.windows
    case 'linux':
      return OSType.linux
    default:
      debug(`Unsupported OS: ${osPlatform}`)
      throw new Error(`Unsupported OS: ${osPlatform}`)
  }
}
Example #3
Source File: actions_python.ts    From setup-cpp with Apache License 2.0 6 votes vote down vote up
export async function setupActionsPython(version: string, _setupDir: string, arch: string) {
  if (process.env.AGENT_TOOLSDIRECTORY?.trim()) {
    debug(`Python is expected to be installed into AGENT_TOOLSDIRECTORY=${process.env.AGENT_TOOLSDIRECTORY}`)
    process.env.RUNNER_TOOL_CACHE = process.env.AGENT_TOOLSDIRECTORY
  } else {
    debug(`Python is expected to be installed into RUNNER_TOOL_CACHE==${process.env.RUNNER_TOOL_CACHE}`)
  }
  if (version) {
    let pythonVersion: string
    if (isPyPyVersion(version)) {
      const installed = await findPyPyVersion(version, arch)
      pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}`
      info(`Successfully setup PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`)
    } else {
      const installed = await useCpythonVersion(version, arch)
      pythonVersion = installed.version
      info(`Successfully setup ${installed.impl} (${pythonVersion})`)
    }

    const cache = "pip" // core.getInput("cache") // package manager used for caching

    await cacheDependencies(cache, pythonVersion)
  }

  if (isGitHubCI()) {
    addPythonLoggingMatcher()
  }

  return undefined
}
Example #4
Source File: ArchiveTools.ts    From powershell with MIT License 5 votes vote down vote up
private async unzipUsing7Zip(zipPath: string, destination: string) {
        debug(`Using 7zip to extract ${zipPath} to ${destination}`);
        const path7Zip = await which("7z.exe", true);
        const exitCode = await exec(`${path7Zip} x -o${destination} ${zipPath}`);
        if (exitCode != 0) {
            throw new Error(`Extraction using 7zip failed from ${zipPath} to ${destination}`);
        }
    }
Example #5
Source File: main.ts    From setup-foreman with MIT License 5 votes vote down vote up
async function run(): Promise<void> {
  try {
    const versionReq: string = getInput("version");
    const githubToken: string = getInput("token");
    const workingDir: string = getInput("working-directory");

    const octokit = new GitHub(githubToken);
    const releases = await foreman.getReleases(octokit);

    debug("Choosing release from GitHub API");

    const release = foreman.chooseRelease(versionReq, releases);
    if (release == null) {
      throw new Error(
        `Could not find Foreman release for version ${versionReq}`
      );
    }

    debug(`Chose release ${release.tag_name}`);

    const asset = foreman.chooseAsset(release);
    if (asset == null) {
      throw new Error(
        `Could not find asset for version ${release.tag_name} on platform ${process.platform}`
      );
    }

    debug(`Chose release asset ${asset.browser_download_url}`);

    const zipPath = await downloadTool(asset.browser_download_url);
    const extractedPath = await extractZip(zipPath, ".foreman-install");
    addPath(resolve(extractedPath));

    if (process.platform === "darwin" || process.platform === "linux") {
      await exec("chmod +x .foreman-install/foreman");
    }

    await foreman.authenticate(githubToken);
    foreman.addBinDirToPath();

    if (workingDir !== undefined && workingDir !== null && workingDir !== "") {
      process.chdir(workingDir);
    }
    await foreman.installTools();
  } catch (error) {
    if (error instanceof Error) {
      setFailed(error.message);
    }
  }
}
Example #6
Source File: search.ts    From checkstyle-github-action with MIT License 5 votes vote down vote up
export async function findResults(
  searchPath: string,
  globOptions?: glob.GlobOptions
): Promise<SearchResult> {
  const searchResults: string[] = []
  const globber = await glob.create(
    searchPath,
    globOptions || getDefaultGlobOptions()
  )
  const rawSearchResults: string[] = await globber.glob()

  /*
      Directories will be rejected if attempted to be uploaded. This includes just empty
      directories so filter any directories out from the raw search results
    */
  for (const searchResult of rawSearchResults) {
    if (!lstatSync(searchResult).isDirectory()) {
      debug(`File:${searchResult} was found using the provided searchPath`)
      searchResults.push(searchResult)
    } else {
      debug(
        `Removing ${searchResult} from rawSearchResults because it is a directory`
      )
    }
  }

  /*
      Only a single search pattern is being included so only 1 searchResult is expected. In the future if multiple search patterns are
      simultaneously supported this will change
    */
  const searchPaths: string[] = globber.getSearchPaths()
  if (searchPaths.length > 1) {
    throw new Error('Only 1 search path should be returned')
  }

  /*
      Special case for a single file artifact that is uploaded without a directory or wildcard pattern. The directory structure is
      not preserved and the root directory will be the single files parent directory
    */
  if (searchResults.length === 1 && searchPaths[0] === searchResults[0]) {
    return {
      filesToUpload: searchResults,
      rootDirectory: dirname(searchResults[0])
    }
  }

  return {
    filesToUpload: searchResults,
    rootDirectory: searchPaths[0]
  }
}
Example #7
Source File: search.ts    From upload-artifact-as-is with MIT License 5 votes vote down vote up
export async function findFilesToUpload(
    searchPath: string,
    globOptions?: glob.GlobOptions
): Promise<SearchResult> {
    const searchResults: string[] = []
    const globber = await glob.create(
        searchPath,
        globOptions || getDefaultGlobOptions()
    )
    const rawSearchResults: string[] = await globber.glob()

    /*
      Directories will be rejected if attempted to be uploaded. This includes just empty
      directories so filter any directories out from the raw search results
    */
    for (const searchResult of rawSearchResults) {
        if (!lstatSync(searchResult).isDirectory()) {
            debug(`File:${searchResult} was found using the provided searchPath`)
            searchResults.push(searchResult)
        } else {
            debug(
                `Removing ${searchResult} from rawSearchResults because it is a directory`
            )
        }
    }

    /*
      Only a single search pattern is being included so only 1 searchResult is expected. In the future if multiple search patterns are
      simultaneously supported this will change
    */
    const searchPaths: string[] = globber.getSearchPaths()
    if (searchPaths.length > 1) {
        throw new Error('Only 1 search path should be returned')
    }

    /*
      Special case for a single file artifact that is uploaded without a directory or wildcard pattern. The directory structure is
      not preserved and the root directory will be the single files parent directory
    */
    if (searchResults.length === 1 && searchPaths[0] === searchResults[0]) {
        return {
            filesToUpload: searchResults,
            rootDirectory: dirname(searchResults[0])
        }
    }

    return {
        filesToUpload: searchResults,
        rootDirectory: searchPaths[0]
    }
}
Example #8
Source File: index.ts    From retry with MIT License 5 votes vote down vote up
async function retryWait() {
  const waitStart = Date.now();
  await wait(ms.seconds(RETRY_WAIT_SECONDS));
  debug(`Waited ${Date.now() - waitStart}ms`);
  debug(`Configured wait: ${ms.seconds(RETRY_WAIT_SECONDS)}ms`);
}
Example #9
Source File: index.ts    From retry with MIT License 5 votes vote down vote up
async function runCmd(attempt: number) {
  const end_time = Date.now() + getTimeout();
  const executable = getExecutable();

  exit = 0;
  done = false;

  debug(`Running command ${COMMAND} on ${OS} using shell ${executable}`)
  var child = attempt > 1 && NEW_COMMAND_ON_RETRY
      ? exec(NEW_COMMAND_ON_RETRY, { 'shell': executable })
      : exec(COMMAND, { 'shell': executable });

  child.stdout?.on('data', (data) => {
    process.stdout.write(data);
  });
  child.stderr?.on('data', (data) => {
    process.stdout.write(data);
  });

  child.on('exit', (code, signal) => {
    debug(`Code: ${code}`);
    debug(`Signal: ${signal}`);
    if (code && code > 0) {
      exit = code;
    }
    // timeouts are killed manually
    if (signal === 'SIGTERM') {
      return;
    }
    done = true;
  });

  do {
    await wait(ms.seconds(POLLING_INTERVAL_SECONDS));
  } while (Date.now() < end_time && !done);

  if (!done) {
    kill(child.pid);
    await retryWait();
    throw new Error(`Timeout of ${getTimeout()}ms hit`);
  } else if (exit > 0) {
    await retryWait();
    throw new Error(`Child_process exited with error code ${exit}`);
  } else {
    return;
  }
}
Example #10
Source File: annotations.ts    From action-eslint with MIT License 5 votes vote down vote up
disableAnnotations = (): void => {
  debug('Disabling Annotations');
  info('##[remove-matcher owner=eslint-compact]');
  info('##[remove-matcher owner=eslint-stylish]');
}