Moves mock GitHub API to /common (#2728)
* Move mock GitHub API to /common * Rename MRVA mock scenarios * Update mock GitHub API docs
This commit is contained in:
@@ -133,4 +133,4 @@ Once the scenario has been recorded, it's often useful to remove some of the req
|
||||
|
||||
### Scenario data location
|
||||
|
||||
Pre-recorded scenarios are stored in `./src/variant-analysis/github-api/mocks/scenarios`. However, it's possible to configure the location, by setting the `codeQL.mockGitHubApiServer.scenariosPath` configuration property in the VS Code user settings.
|
||||
Pre-recorded scenarios are stored in `./src/common/mock-gh-api/scenarios`. However, it's possible to configure the location, by setting the `codeQL.mockGitHubApiServer.scenariosPath` configuration property in the VS Code user settings.
|
||||
|
||||
@@ -18,15 +18,15 @@ import { Octokit, type RestEndpointMethodTypes } from "@octokit/rest";
|
||||
import { throttling } from "@octokit/plugin-throttling";
|
||||
|
||||
import { getFiles } from "./util/files";
|
||||
import type { GitHubApiRequest } from "../src/variant-analysis/gh-api/mocks/gh-api-request";
|
||||
import { isGetVariantAnalysisRequest } from "../src/variant-analysis/gh-api/mocks/gh-api-request";
|
||||
import type { GitHubApiRequest } from "../src/common/mock-gh-api/gh-api-request";
|
||||
import { isGetVariantAnalysisRequest } from "../src/common/mock-gh-api/gh-api-request";
|
||||
import { VariantAnalysis } from "../src/variant-analysis/gh-api/variant-analysis";
|
||||
import { RepositoryWithMetadata } from "../src/variant-analysis/gh-api/repository";
|
||||
|
||||
const extensionDirectory = resolve(__dirname, "..");
|
||||
const scenariosDirectory = resolve(
|
||||
extensionDirectory,
|
||||
"src/variant-analysis/gh-api/mocks/scenarios",
|
||||
"src/common/mock-gh-api/scenarios",
|
||||
);
|
||||
|
||||
// Make sure we don't run into rate limits by automatically waiting until we can
|
||||
|
||||
@@ -22,7 +22,7 @@ const scenarioName = process.argv[2];
|
||||
const extensionDirectory = resolve(__dirname, "..");
|
||||
const scenariosDirectory = resolve(
|
||||
extensionDirectory,
|
||||
"src/variant-analysis/gh-api/mocks/scenarios",
|
||||
"src/common/mock-gh-api/scenarios",
|
||||
);
|
||||
const scenarioDirectory = resolve(scenariosDirectory, scenarioName);
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ const extensionDirectory = resolve(__dirname, "..");
|
||||
const rootDirectory = resolve(extensionDirectory, "../..");
|
||||
const scenariosDirectory = resolve(
|
||||
extensionDirectory,
|
||||
"src/variant-analysis/gh-api/mocks/scenarios",
|
||||
"src/common/mock-gh-api/scenarios",
|
||||
);
|
||||
|
||||
const debug = process.env.RUNNER_DEBUG || process.argv.includes("--debug");
|
||||
@@ -19,7 +19,7 @@ async function lintScenarios() {
|
||||
const schema = createGenerator({
|
||||
path: resolve(
|
||||
extensionDirectory,
|
||||
"src/variant-analysis/gh-api/mocks/gh-api-request.ts",
|
||||
"src/common/mock-gh-api/gh-api-request.ts",
|
||||
),
|
||||
tsconfig: resolve(extensionDirectory, "tsconfig.json"),
|
||||
type: "GitHubApiRequest",
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { Repository } from "../repository";
|
||||
import { VariantAnalysis, VariantAnalysisRepoTask } from "../variant-analysis";
|
||||
import { Repository } from "../../variant-analysis/gh-api/repository";
|
||||
import {
|
||||
VariantAnalysis,
|
||||
VariantAnalysisRepoTask,
|
||||
} from "../../variant-analysis/gh-api/variant-analysis";
|
||||
|
||||
// Types that represent requests/responses from the GitHub API
|
||||
// that we need to mock.
|
||||
@@ -2,11 +2,11 @@ import { join, resolve } from "path";
|
||||
import { pathExists } from "fs-extra";
|
||||
import { setupServer, SetupServer } from "msw/node";
|
||||
|
||||
import { DisposableObject } from "../../../common/disposable-object";
|
||||
import { DisposableObject } from "../disposable-object";
|
||||
|
||||
import { Recorder } from "./recorder";
|
||||
import { createRequestHandlers } from "./request-handlers";
|
||||
import { getDirectoryNamesInsidePath } from "../../../common/files";
|
||||
import { getDirectoryNamesInsidePath } from "../files";
|
||||
|
||||
/**
|
||||
* Enables mocking of the GitHub API server via HTTP interception, using msw.
|
||||
@@ -129,11 +129,11 @@ export class MockGitHubApiServer extends DisposableObject {
|
||||
|
||||
public async getDefaultScenariosPath(): Promise<string | undefined> {
|
||||
// This should be the directory where package.json is located
|
||||
const rootDirectory = resolve(__dirname, "../../../..");
|
||||
const rootDirectory = resolve(__dirname, "../../..");
|
||||
|
||||
const scenariosPath = resolve(
|
||||
rootDirectory,
|
||||
"src/variant-analysis/gh-api/mocks/scenarios",
|
||||
"src/common/mock-gh-api/scenarios",
|
||||
);
|
||||
if (await pathExists(scenariosPath)) {
|
||||
return scenariosPath;
|
||||
@@ -8,7 +8,7 @@ import { IsomorphicResponse } from "@mswjs/interceptors";
|
||||
import { Headers } from "headers-polyfill";
|
||||
import fetch from "node-fetch";
|
||||
|
||||
import { DisposableObject } from "../../../common/disposable-object";
|
||||
import { DisposableObject } from "../disposable-object";
|
||||
|
||||
import {
|
||||
GetVariantAnalysisRepoResultRequest,
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user