+
Skip to content

Make a dynamic config error recoverable #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/classes/JobProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
ENTER_LICENSE_COMMAND,
GET_LICENSE_COMMAND,
JOB_TREE_VIEW_ID,
PROCESS_TRY_AGAIN_COMMAND,
TRIAL_STARTED_TIMESTAMP,
} from '../constants';

Expand Down Expand Up @@ -183,7 +184,7 @@ export default class JobProvider
return [
new Warning('Error processing the CircleCI config:'),
new vscode.TreeItem(this.getJobErrorMessage()),
new Command('Try Again', `${JOB_TREE_VIEW_ID}.refresh`),
new Command('Try Again', PROCESS_TRY_AGAIN_COMMAND),
];
default:
return [];
Expand Down
1 change: 1 addition & 0 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const LICENSE_ERROR = 'localCiLicenseKeyError';
export const GET_LICENSE_COMMAND = 'local-ci.license.get';
export const ENTER_LICENSE_COMMAND = 'local-ci.license.enter';
export const EXIT_JOB_COMMAND = 'local-ci.job.exit';
export const PROCESS_TRY_AGAIN_COMMAND = 'local-ci.process-error.try-again';

export const GET_RUNNING_CONTAINER_FUNCTION = `get_running_container() {
IMAGE=$1
Expand Down
13 changes: 13 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
HELP_URL,
HOST_TMP_DIRECTORY,
JOB_TREE_VIEW_ID,
PROCESS_TRY_AGAIN_COMMAND,
RUN_JOB_COMMAND,
SELECTED_CONFIG_PATH,
TELEMETRY_KEY,
Expand All @@ -30,6 +31,7 @@ import getCheckoutJobs from './utils/getCheckoutJobs';
import getConfig from './utils/getConfig';
import getConfigFilePath from './utils/getConfigFilePath';
import getDebuggingTerminalName from './utils/getDebuggingTerminalName';
import getDynamicConfigFilePath from './utils/getDynamicConfigFilePath';
import getFinalTerminalName from './utils/getFinalTerminalName';
import getRepoBasename from './utils/getRepoBasename';
import getStarterConfig from './utils/getStarterConfig';
Expand Down Expand Up @@ -79,6 +81,17 @@ export function activate(context: vscode.ExtensionContext): void {
vscode.commands.registerCommand(`${JOB_TREE_VIEW_ID}.refresh`, () =>
jobProvider.refresh()
),
vscode.commands.registerCommand(PROCESS_TRY_AGAIN_COMMAND, async () => {
// There might have been a problem with the dynamic config file, so remove it.
const dynamicConfig = getDynamicConfigFilePath(
await getConfigFilePath(context)
);
if (fs.existsSync(dynamicConfig)) {
fs.rmSync(dynamicConfig);
}

jobProvider.refresh();
}),
vscode.commands.registerCommand(`${JOB_TREE_VIEW_ID}.enterToken`, () => {
const terminal = vscode.window.createTerminal({
name: 'Enter CircleCI® API Token',
Expand Down
1 change: 1 addition & 0 deletions src/utils/runJob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export default async function runJob(
);

const helperMessagesProcess = showMainTerminalHelperMessages(
context,
jobProvider,
job,
doesJobCreateDynamicConfig(jobInConfig)
Expand Down
14 changes: 12 additions & 2 deletions src/utils/showMainTerminalHelperMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ import * as vscode from 'vscode';
import Job from '../classes/Job';
import JobProvider from '../classes/JobProvider';
import { GET_PICARD_CONTAINER_FUNCTION } from '../constants';
import getConfigFilePath from './getConfigFilePath';
import getConfigFromPath from './getConfigFromPath';
import getDynamicConfigFilePath from './getDynamicConfigFilePath';
import getSpawnOptions from './getSpawnOptions';

export default function showMainTerminalHelperMessages(
context: vscode.ExtensionContext,
jobProvider: JobProvider,
job: Job | undefined,
doesJobCreateDynamicConfig: boolean
Expand All @@ -25,7 +29,7 @@ export default function showMainTerminalHelperMessages(
getSpawnOptions()
);

process.stdout.on('data', (data) => {
process.stdout.on('data', async (data) => {
const output = data?.toString();
if (!output?.length) {
return;
Expand All @@ -38,8 +42,14 @@ export default function showMainTerminalHelperMessages(

if (doesJobCreateDynamicConfig) {
jobProvider.refresh();
const dynamicConfig = getConfigFromPath(
getDynamicConfigFilePath(await getConfigFilePath(context))
);

vscode.window.showInformationMessage(
'Success, you can now run the dynamic config jobs'
dynamicConfig?.jobs
? `Success! You can now run the dynamic config jobs.`
: `The step succeeded, but it didn't create any dynamic job`
);
} else {
jobProvider.refresh(job);
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载