feat: Update Docker configuration for Copilot debugging

This commit updates the Docker configuration in the `.vscode/launch.json` file to improve the debugging experience for Copilot. It modifies the `Debug: Copilot Locally` configuration by changing the `localRoot` to `${workspaceFolder}/TestServer` and updating the `name` to `Copilot: Debug with Docker`. Additionally, it sets the `port` to `9985`, `remoteRoot` to `/usr/src/app`, and enables `restart` and `autoAttachChildProcesses` for better debugging capabilities. These changes enhance the development workflow and make it easier to debug Copilot locally with Docker.
This commit is contained in:
Simon Larsen
2024-07-15 08:36:23 -06:00
parent 39b5982d67
commit 5f3cfa3f0d
5 changed files with 41 additions and 31 deletions

32
.vscode/launch.json vendored
View File

@@ -20,18 +20,18 @@
],
"configurations": [
{
"name": "Debug: Copilot Locally",
"request": "launch",
"localRoot": "${workspaceFolder}/Copilot",
"runtimeArgs": [
"run-script",
"start"
],
"runtimeExecutable": "npm",
"address": "127.0.0.1",
"localRoot": "${workspaceFolder}/TestServer",
"name": "Copilot: Debug with Docker",
"port": 9985,
"remoteRoot": "/usr/src/app",
"request": "attach",
"skipFiles": [
"<node_internals>/**"
],
"type": "node"
"type": "node",
"restart": true,
"autoAttachChildProcesses": true
},
{
"name": "Debug Infrastructure Agent",
@@ -147,20 +147,6 @@
"restart": true,
"autoAttachChildProcesses": true
},
{
"address": "127.0.0.1",
"localRoot": "${workspaceFolder}/Copilot",
"name": "Copilot: Debug with Docker",
"port": 9985,
"remoteRoot": "/usr/src/app",
"request": "attach",
"skipFiles": [
"<node_internals>/**"
],
"type": "node",
"restart": true,
"autoAttachChildProcesses": true
},
{
"address": "127.0.0.1",
"localRoot": "${workspaceFolder}/Workers",

View File

@@ -14,6 +14,7 @@ Init()
})
.catch(async (error: Error | HTTPErrorResponse) => {
try {
logger.error(error);
await CodeRepositoryUtil.discardChanges();
// change back to main branch.

View File

@@ -135,7 +135,11 @@ export default class CopilotActionService {
// add files to stage
logger.info("Adding files to stage");
logger.info("Adding files to stage: ");
for (const filePath of filePaths) {
logger.info(`- ${filePath}`);
}
await CodeRepositoryUtil.addFilesToGit({
filePaths: filePaths,

View File

@@ -49,6 +49,10 @@ export default class CodeRepositoryUtil {
public static gitHubUtil: GitHubUtil | null = null;
public static folderNameOfClonedRepository: string | null = null;
public static isRepoCloned(): boolean {
return Boolean(this.folderNameOfClonedRepository);
}
public static async getOpenSetupPullRequest(): Promise<CopilotPullRequest | null> {
const openPullRequests: Array<CopilotPullRequest> =
await CopilotPullRequestService.getOpenPullRequestsFromDatabase();
@@ -475,21 +479,29 @@ export default class CodeRepositoryUtil {
}
public static async discardChanges(): Promise<void> {
await CodeRepositoryServerUtil.discardChanges({
repoPath: this.getLocalRepositoryPath(),
});
if (this.isRepoCloned()) {
await CodeRepositoryServerUtil.discardChanges({
repoPath: this.getLocalRepositoryPath(),
});
}
}
public static async checkoutBranch(data: {
branchName: string;
}): Promise<void> {
await CodeRepositoryServerUtil.checkoutBranch({
repoPath: this.getLocalRepositoryPath(),
branchName: data.branchName,
});
if (this.isRepoCloned()) {
await CodeRepositoryServerUtil.checkoutBranch({
repoPath: this.getLocalRepositoryPath(),
branchName: data.branchName,
});
}
}
public static async checkoutMainBranch(): Promise<void> {
if (!this.isRepoCloned()) {
return;
}
const codeRepository: CopilotCodeRepository =
await this.getCodeRepository();
@@ -685,6 +697,8 @@ export default class CodeRepositoryUtil {
return this.codeRepositoryResult;
}
logger.info("Fetching Code Repository...");
const repositorySecretKey: string | null = GetRepositorySecretKey();
if (!repositorySecretKey) {

View File

@@ -13,6 +13,7 @@ import API from "Common/Utils/API";
import HTTPErrorResponse from "Common/Types/API/HTTPErrorResponse";
import HTTPResponse from "Common/Types/API/HTTPResponse";
import { JSONObject } from "Common/Types/JSON";
import logger from "CommonServer/Utils/Logger";
export default class InitUtil {
public static async init(): Promise<CodeRepositoryResult> {
@@ -40,6 +41,10 @@ export default class InitUtil {
// Check if the repository type is GitHub and the GitHub token is provided
if (codeRepositoryResult.serviceRepositories.length === 0) {
logger.error(
"No services found in the repository. Please add services to the repository in OneUptime Dashboard.",
);
throw new BadDataException(
"No services found in the repository. Please add services to the repository in OneUptime Dashboard.",
);