Use getRepositoryNwo()
This commit is contained in:
parent
b22f3341fe
commit
f88459c0a3
10 changed files with 32 additions and 61 deletions
|
|
@ -26,7 +26,7 @@ import { EnvVar } from "./environment";
|
||||||
import { Features } from "./feature-flags";
|
import { Features } from "./feature-flags";
|
||||||
import { Language } from "./languages";
|
import { Language } from "./languages";
|
||||||
import { getActionsLogger, Logger } from "./logging";
|
import { getActionsLogger, Logger } from "./logging";
|
||||||
import { parseRepositoryNwo } from "./repository";
|
import { getRepositoryNwo } from "./repository";
|
||||||
import * as statusReport from "./status-report";
|
import * as statusReport from "./status-report";
|
||||||
import {
|
import {
|
||||||
ActionName,
|
ActionName,
|
||||||
|
|
@ -251,9 +251,7 @@ async function run() {
|
||||||
logger,
|
logger,
|
||||||
);
|
);
|
||||||
|
|
||||||
const repositoryNwo = parseRepositoryNwo(
|
const repositoryNwo = getRepositoryNwo();
|
||||||
util.getRequiredEnvParam("GITHUB_REPOSITORY"),
|
|
||||||
);
|
|
||||||
|
|
||||||
const gitHubVersion = await getGitHubVersion();
|
const gitHubVersion = await getGitHubVersion();
|
||||||
|
|
||||||
|
|
@ -359,7 +357,7 @@ async function run() {
|
||||||
actionsUtil.getRequiredInput("wait-for-processing") === "true"
|
actionsUtil.getRequiredInput("wait-for-processing") === "true"
|
||||||
) {
|
) {
|
||||||
await uploadLib.waitForProcessing(
|
await uploadLib.waitForProcessing(
|
||||||
parseRepositoryNwo(util.getRequiredEnvParam("GITHUB_REPOSITORY")),
|
getRepositoryNwo(),
|
||||||
uploadResult.sarifID,
|
uploadResult.sarifID,
|
||||||
getActionsLogger(),
|
getActionsLogger(),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import { EnvVar } from "./environment";
|
||||||
import { FeatureEnablement, Feature } from "./feature-flags";
|
import { FeatureEnablement, Feature } from "./feature-flags";
|
||||||
import { isScannedLanguage, Language } from "./languages";
|
import { isScannedLanguage, Language } from "./languages";
|
||||||
import { Logger, withGroupAsync } from "./logging";
|
import { Logger, withGroupAsync } from "./logging";
|
||||||
|
import { getRepositoryNwo } from "./repository";
|
||||||
import { DatabaseCreationTimings, EventReport } from "./status-report";
|
import { DatabaseCreationTimings, EventReport } from "./status-report";
|
||||||
import { ToolsFeature } from "./tools-features";
|
import { ToolsFeature } from "./tools-features";
|
||||||
import { endTracingForCluster } from "./tracer-config";
|
import { endTracingForCluster } from "./tracer-config";
|
||||||
|
|
@ -389,15 +390,13 @@ async function getFileDiffsWithBasehead(
|
||||||
branches: PullRequestBranches,
|
branches: PullRequestBranches,
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
): Promise<FileDiff[] | undefined> {
|
): Promise<FileDiff[] | undefined> {
|
||||||
const ownerRepo = util.getRequiredEnvParam("GITHUB_REPOSITORY").split("/");
|
const repositoryNwo = getRepositoryNwo();
|
||||||
const owner = ownerRepo[0];
|
|
||||||
const repo = ownerRepo[1];
|
|
||||||
const basehead = `${branches.base}...${branches.head}`;
|
const basehead = `${branches.base}...${branches.head}`;
|
||||||
try {
|
try {
|
||||||
const response = await getApiClient().rest.repos.compareCommitsWithBasehead(
|
const response = await getApiClient().rest.repos.compareCommitsWithBasehead(
|
||||||
{
|
{
|
||||||
owner,
|
owner: repositoryNwo.owner,
|
||||||
repo,
|
repo: repositoryNwo.repo,
|
||||||
basehead,
|
basehead,
|
||||||
per_page: 1,
|
per_page: 1,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import * as retry from "@octokit/plugin-retry";
|
||||||
import consoleLogLevel from "console-log-level";
|
import consoleLogLevel from "console-log-level";
|
||||||
|
|
||||||
import { getActionVersion, getRequiredInput } from "./actions-util";
|
import { getActionVersion, getRequiredInput } from "./actions-util";
|
||||||
import { parseRepositoryNwo } from "./repository";
|
import { getRepositoryNwo } from "./repository";
|
||||||
import {
|
import {
|
||||||
ConfigurationError,
|
ConfigurationError,
|
||||||
getRequiredEnvParam,
|
getRequiredEnvParam,
|
||||||
|
|
@ -123,17 +123,15 @@ export async function getGitHubVersion(): Promise<GitHubVersion> {
|
||||||
* Get the path of the currently executing workflow relative to the repository root.
|
* Get the path of the currently executing workflow relative to the repository root.
|
||||||
*/
|
*/
|
||||||
export async function getWorkflowRelativePath(): Promise<string> {
|
export async function getWorkflowRelativePath(): Promise<string> {
|
||||||
const repo_nwo = getRequiredEnvParam("GITHUB_REPOSITORY").split("/");
|
const repo_nwo = getRepositoryNwo();
|
||||||
const owner = repo_nwo[0];
|
|
||||||
const repo = repo_nwo[1];
|
|
||||||
const run_id = Number(getRequiredEnvParam("GITHUB_RUN_ID"));
|
const run_id = Number(getRequiredEnvParam("GITHUB_RUN_ID"));
|
||||||
|
|
||||||
const apiClient = getApiClient();
|
const apiClient = getApiClient();
|
||||||
const runsResponse = await apiClient.request(
|
const runsResponse = await apiClient.request(
|
||||||
"GET /repos/:owner/:repo/actions/runs/:run_id?exclude_pull_requests=true",
|
"GET /repos/:owner/:repo/actions/runs/:run_id?exclude_pull_requests=true",
|
||||||
{
|
{
|
||||||
owner,
|
owner: repo_nwo.owner,
|
||||||
repo,
|
repo: repo_nwo.repo,
|
||||||
run_id,
|
run_id,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
@ -218,9 +216,7 @@ export async function listActionsCaches(
|
||||||
key: string,
|
key: string,
|
||||||
ref: string,
|
ref: string,
|
||||||
): Promise<ActionsCacheItem[]> {
|
): Promise<ActionsCacheItem[]> {
|
||||||
const repositoryNwo = parseRepositoryNwo(
|
const repositoryNwo = getRepositoryNwo();
|
||||||
getRequiredEnvParam("GITHUB_REPOSITORY"),
|
|
||||||
);
|
|
||||||
|
|
||||||
return await getApiClient().paginate(
|
return await getApiClient().paginate(
|
||||||
"GET /repos/{owner}/{repo}/actions/caches",
|
"GET /repos/{owner}/{repo}/actions/caches",
|
||||||
|
|
@ -235,9 +231,7 @@ export async function listActionsCaches(
|
||||||
|
|
||||||
/** Delete an Actions cache item by its ID. */
|
/** Delete an Actions cache item by its ID. */
|
||||||
export async function deleteActionsCache(id: number) {
|
export async function deleteActionsCache(id: number) {
|
||||||
const repositoryNwo = parseRepositoryNwo(
|
const repositoryNwo = getRepositoryNwo();
|
||||||
getRequiredEnvParam("GITHUB_REPOSITORY"),
|
|
||||||
);
|
|
||||||
|
|
||||||
await getApiClient().rest.actions.deleteActionsCacheById({
|
await getApiClient().rest.actions.deleteActionsCacheById({
|
||||||
owner: repositoryNwo.owner,
|
owner: repositoryNwo.owner,
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,9 @@ import { EnvVar } from "./environment";
|
||||||
import { Feature, featureConfig, Features } from "./feature-flags";
|
import { Feature, featureConfig, Features } from "./feature-flags";
|
||||||
import { isTracedLanguage, Language } from "./languages";
|
import { isTracedLanguage, Language } from "./languages";
|
||||||
import { Logger } from "./logging";
|
import { Logger } from "./logging";
|
||||||
import { parseRepositoryNwo } from "./repository";
|
import { getRepositoryNwo } from "./repository";
|
||||||
import { ToolsFeature } from "./tools-features";
|
import { ToolsFeature } from "./tools-features";
|
||||||
import { BuildMode, getRequiredEnvParam } from "./util";
|
import { BuildMode } from "./util";
|
||||||
|
|
||||||
export async function determineAutobuildLanguages(
|
export async function determineAutobuildLanguages(
|
||||||
codeql: CodeQL,
|
codeql: CodeQL,
|
||||||
|
|
@ -117,9 +117,7 @@ export async function setupCppAutobuild(codeql: CodeQL, logger: Logger) {
|
||||||
const envVar = featureConfig[Feature.CppDependencyInstallation].envVar;
|
const envVar = featureConfig[Feature.CppDependencyInstallation].envVar;
|
||||||
const featureName = "C++ automatic installation of dependencies";
|
const featureName = "C++ automatic installation of dependencies";
|
||||||
const gitHubVersion = await getGitHubVersion();
|
const gitHubVersion = await getGitHubVersion();
|
||||||
const repositoryNwo = parseRepositoryNwo(
|
const repositoryNwo = getRepositoryNwo();
|
||||||
getRequiredEnvParam("GITHUB_REPOSITORY"),
|
|
||||||
);
|
|
||||||
const features = new Features(
|
const features = new Features(
|
||||||
gitHubVersion,
|
gitHubVersion,
|
||||||
repositoryNwo,
|
repositoryNwo,
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import { Config } from "./config-utils";
|
||||||
import { EnvVar } from "./environment";
|
import { EnvVar } from "./environment";
|
||||||
import { Feature, FeatureEnablement } from "./feature-flags";
|
import { Feature, FeatureEnablement } from "./feature-flags";
|
||||||
import { Logger } from "./logging";
|
import { Logger } from "./logging";
|
||||||
import { RepositoryNwo, parseRepositoryNwo } from "./repository";
|
import { RepositoryNwo, getRepositoryNwo } from "./repository";
|
||||||
import { JobStatus } from "./status-report";
|
import { JobStatus } from "./status-report";
|
||||||
import * as uploadLib from "./upload-lib";
|
import * as uploadLib from "./upload-lib";
|
||||||
import {
|
import {
|
||||||
|
|
@ -255,9 +255,7 @@ async function removeUploadedSarif(
|
||||||
const client = getApiClient();
|
const client = getApiClient();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const repositoryNwo = parseRepositoryNwo(
|
const repositoryNwo = getRepositoryNwo();
|
||||||
getRequiredEnvParam("GITHUB_REPOSITORY"),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Wait to make sure the analysis is ready for download before requesting it.
|
// Wait to make sure the analysis is ready for download before requesting it.
|
||||||
await delay(5000);
|
await delay(5000);
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ import * as debugArtifacts from "./debug-artifacts";
|
||||||
import { Features } from "./feature-flags";
|
import { Features } from "./feature-flags";
|
||||||
import * as initActionPostHelper from "./init-action-post-helper";
|
import * as initActionPostHelper from "./init-action-post-helper";
|
||||||
import { getActionsLogger } from "./logging";
|
import { getActionsLogger } from "./logging";
|
||||||
import { parseRepositoryNwo } from "./repository";
|
import { getRepositoryNwo } from "./repository";
|
||||||
import {
|
import {
|
||||||
StatusReportBase,
|
StatusReportBase,
|
||||||
sendStatusReport,
|
sendStatusReport,
|
||||||
|
|
@ -26,12 +26,7 @@ import {
|
||||||
ActionName,
|
ActionName,
|
||||||
getJobStatusDisplayName,
|
getJobStatusDisplayName,
|
||||||
} from "./status-report";
|
} from "./status-report";
|
||||||
import {
|
import { checkDiskUsage, checkGitHubVersionInRange, wrapError } from "./util";
|
||||||
checkDiskUsage,
|
|
||||||
checkGitHubVersionInRange,
|
|
||||||
getRequiredEnvParam,
|
|
||||||
wrapError,
|
|
||||||
} from "./util";
|
|
||||||
|
|
||||||
interface InitPostStatusReport
|
interface InitPostStatusReport
|
||||||
extends StatusReportBase,
|
extends StatusReportBase,
|
||||||
|
|
@ -52,9 +47,7 @@ async function runWrapper() {
|
||||||
const gitHubVersion = await getGitHubVersion();
|
const gitHubVersion = await getGitHubVersion();
|
||||||
checkGitHubVersionInRange(gitHubVersion, logger);
|
checkGitHubVersionInRange(gitHubVersion, logger);
|
||||||
|
|
||||||
const repositoryNwo = parseRepositoryNwo(
|
const repositoryNwo = getRepositoryNwo();
|
||||||
getRequiredEnvParam("GITHUB_REPOSITORY"),
|
|
||||||
);
|
|
||||||
const features = new Features(
|
const features = new Features(
|
||||||
gitHubVersion,
|
gitHubVersion,
|
||||||
repositoryNwo,
|
repositoryNwo,
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ import {
|
||||||
import { Language } from "./languages";
|
import { Language } from "./languages";
|
||||||
import { getActionsLogger, Logger } from "./logging";
|
import { getActionsLogger, Logger } from "./logging";
|
||||||
import { OverlayDatabaseMode } from "./overlay-database-utils";
|
import { OverlayDatabaseMode } from "./overlay-database-utils";
|
||||||
import { parseRepositoryNwo } from "./repository";
|
import { getRepositoryNwo } from "./repository";
|
||||||
import { ToolsSource } from "./setup-codeql";
|
import { ToolsSource } from "./setup-codeql";
|
||||||
import {
|
import {
|
||||||
ActionName,
|
ActionName,
|
||||||
|
|
@ -281,9 +281,7 @@ async function run() {
|
||||||
checkGitHubVersionInRange(gitHubVersion, logger);
|
checkGitHubVersionInRange(gitHubVersion, logger);
|
||||||
checkActionVersion(getActionVersion(), gitHubVersion);
|
checkActionVersion(getActionVersion(), gitHubVersion);
|
||||||
|
|
||||||
const repositoryNwo = parseRepositoryNwo(
|
const repositoryNwo = getRepositoryNwo();
|
||||||
getRequiredEnvParam("GITHUB_REPOSITORY"),
|
|
||||||
);
|
|
||||||
|
|
||||||
const features = new Features(
|
const features = new Features(
|
||||||
gitHubVersion,
|
gitHubVersion,
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ import { DocUrl } from "./doc-url";
|
||||||
import { EnvVar } from "./environment";
|
import { EnvVar } from "./environment";
|
||||||
import { getRef } from "./git-utils";
|
import { getRef } from "./git-utils";
|
||||||
import { Logger } from "./logging";
|
import { Logger } from "./logging";
|
||||||
|
import { getRepositoryNwo } from "./repository";
|
||||||
import {
|
import {
|
||||||
ConfigurationError,
|
ConfigurationError,
|
||||||
isHTTPError,
|
isHTTPError,
|
||||||
|
|
@ -393,16 +394,15 @@ export async function sendStatusReport<S extends StatusReportBase>(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const nwo = getRequiredEnvParam("GITHUB_REPOSITORY");
|
const nwo = getRepositoryNwo();
|
||||||
const [owner, repo] = nwo.split("/");
|
|
||||||
const client = getApiClient();
|
const client = getApiClient();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await client.request(
|
await client.request(
|
||||||
"PUT /repos/:owner/:repo/code-scanning/analysis/status",
|
"PUT /repos/:owner/:repo/code-scanning/analysis/status",
|
||||||
{
|
{
|
||||||
owner,
|
owner: nwo.owner,
|
||||||
repo,
|
repo: nwo.repo,
|
||||||
data: statusReportJSON,
|
data: statusReportJSON,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ import * as fingerprints from "./fingerprints";
|
||||||
import * as gitUtils from "./git-utils";
|
import * as gitUtils from "./git-utils";
|
||||||
import { initCodeQL } from "./init";
|
import { initCodeQL } from "./init";
|
||||||
import { Logger } from "./logging";
|
import { Logger } from "./logging";
|
||||||
import { parseRepositoryNwo, RepositoryNwo } from "./repository";
|
import { getRepositoryNwo, RepositoryNwo } from "./repository";
|
||||||
import { ToolsFeature } from "./tools-features";
|
import { ToolsFeature } from "./tools-features";
|
||||||
import * as util from "./util";
|
import * as util from "./util";
|
||||||
import {
|
import {
|
||||||
|
|
@ -624,11 +624,7 @@ export async function uploadFiles(
|
||||||
logger.debug(`Number of results in upload: ${numResultInSarif}`);
|
logger.debug(`Number of results in upload: ${numResultInSarif}`);
|
||||||
|
|
||||||
// Make the upload
|
// Make the upload
|
||||||
const sarifID = await uploadPayload(
|
const sarifID = await uploadPayload(payload, getRepositoryNwo(), logger);
|
||||||
payload,
|
|
||||||
parseRepositoryNwo(util.getRequiredEnvParam("GITHUB_REPOSITORY")),
|
|
||||||
logger,
|
|
||||||
);
|
|
||||||
|
|
||||||
logger.endGroup();
|
logger.endGroup();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import { getActionVersion, getTemporaryDirectory } from "./actions-util";
|
||||||
import { getGitHubVersion } from "./api-client";
|
import { getGitHubVersion } from "./api-client";
|
||||||
import { Features } from "./feature-flags";
|
import { Features } from "./feature-flags";
|
||||||
import { Logger, getActionsLogger } from "./logging";
|
import { Logger, getActionsLogger } from "./logging";
|
||||||
import { parseRepositoryNwo } from "./repository";
|
import { getRepositoryNwo } from "./repository";
|
||||||
import {
|
import {
|
||||||
createStatusReportBase,
|
createStatusReportBase,
|
||||||
sendStatusReport,
|
sendStatusReport,
|
||||||
|
|
@ -20,7 +20,6 @@ import {
|
||||||
checkActionVersion,
|
checkActionVersion,
|
||||||
checkDiskUsage,
|
checkDiskUsage,
|
||||||
getErrorMessage,
|
getErrorMessage,
|
||||||
getRequiredEnvParam,
|
|
||||||
initializeEnvironment,
|
initializeEnvironment,
|
||||||
isInTestMode,
|
isInTestMode,
|
||||||
wrapError,
|
wrapError,
|
||||||
|
|
@ -63,9 +62,7 @@ async function run() {
|
||||||
// Make inputs accessible in the `post` step.
|
// Make inputs accessible in the `post` step.
|
||||||
actionsUtil.persistInputs();
|
actionsUtil.persistInputs();
|
||||||
|
|
||||||
const repositoryNwo = parseRepositoryNwo(
|
const repositoryNwo = getRepositoryNwo();
|
||||||
getRequiredEnvParam("GITHUB_REPOSITORY"),
|
|
||||||
);
|
|
||||||
const features = new Features(
|
const features = new Features(
|
||||||
gitHubVersion,
|
gitHubVersion,
|
||||||
repositoryNwo,
|
repositoryNwo,
|
||||||
|
|
@ -100,7 +97,7 @@ async function run() {
|
||||||
core.debug("In test mode. Waiting for processing is disabled.");
|
core.debug("In test mode. Waiting for processing is disabled.");
|
||||||
} else if (actionsUtil.getRequiredInput("wait-for-processing") === "true") {
|
} else if (actionsUtil.getRequiredInput("wait-for-processing") === "true") {
|
||||||
await upload_lib.waitForProcessing(
|
await upload_lib.waitForProcessing(
|
||||||
parseRepositoryNwo(getRequiredEnvParam("GITHUB_REPOSITORY")),
|
getRepositoryNwo(),
|
||||||
uploadResult.sarifID,
|
uploadResult.sarifID,
|
||||||
logger,
|
logger,
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue