From db6312a7ad27987292821f040b54366aaffd7f39 Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Wed, 15 Dec 2021 21:14:25 -0600 Subject: [PATCH 1/7] Remove the /tmp/local-ci directory on uninstall --- src/extension.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/extension.ts b/src/extension.ts index 7677b3fb..c9eb21b7 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1,3 +1,4 @@ +import * as fs from 'fs'; import * as vscode from 'vscode'; import TelemetryReporter from 'vscode-extension-telemetry'; import Delayer from './classes/Delayer'; @@ -13,6 +14,7 @@ import { GET_LICENSE_COMMAND, GET_LICENSE_KEY_URL, HELP_URL, + HOST_TMP_DIRECTORY, JOB_TREE_VIEW_ID, RUN_JOB_COMMAND, SELECTED_CONFIG_PATH, @@ -300,4 +302,5 @@ export function activate(context: vscode.ExtensionContext): void { export function deactivate(): void { reporter.sendTelemetryEvent('deactivate'); + fs.rmSync(HOST_TMP_DIRECTORY, { recursive: true, force: true }); } From ff9bed57c907d75ae1a9f6cbaa1742a3f93cfd4b Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Wed, 15 Dec 2021 23:37:01 -0600 Subject: [PATCH 2/7] Update the README.md for the restore_cache support --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 246981a2..d3bc3e35 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,14 @@ Get Bash access to the running job by clicking 'Local CI debugging': When the job exits, you'll still have Bash access to the job. +## Restore And Save Cache + +Run jobs faster when you cache dependencies. + +Local CI supports the [native](https://circleci.com/docs/2.0/caching/) `restore_cache` and `save_cache` values: + +![Editor with restore cache](https://user-images.githubusercontent.com/4063887/146306642-87ccc2c3-5e99-467e-ae41-70ecaef1bcc6.png) + ## Run The Whole Workflow You can even run jobs that depend on other jobs, because this persists the workspace between jobs: From 3b3db828359d12b93e04057f0777064c87cf611d Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Thu, 16 Dec 2021 00:19:35 -0600 Subject: [PATCH 3/7] Add a command to enter an API token This can be needed to clone certain Docker images. --- package.json | 28 +++++++++++++++++++--------- src/extension.ts | 21 ++++++++++++++++++--- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 6cd44d75..646a6f3a 100644 --- a/package.json +++ b/package.json @@ -57,46 +57,51 @@ "commands": [ { "command": "local-ci.job.run", - "title": "Run Local CI job", + "title": "Local CI: Run Job", "icon": "$(refresh)" }, { "command": "local-ci.job.exit", - "title": "Exit Job", + "title": "Local CI: Exit Job", "icon": "$(notebook-delete-cell)" }, { "command": "local-ci.job.rerun", - "title": "Rerun Job", + "title": "Local CI: Rerun Job", "icon": "$(extensions-refresh)" }, { "command": "local-ci.debug.repo", - "title": "Run Jobs Locally (Local CI)" + "title": "Local CI: Run Jobs Locally (Local CI)" + }, + { + "command": "localCiJobs.enterToken", + "title": "Local CI: Enter API Token", + "icon": "$(record-keys)" }, { "command": "localCiJobs.refresh", - "title": "Refresh Job List", + "title": "Local CI: Refresh Job List", "icon": "$(refresh)" }, { "command": "localCiJobs.help", - "title": "Help", + "title": "Local CI: Help", "icon": "$(question)" }, { "command": "localCiJobs.exitAllJobs", - "title": "Exit All Jobs", + "title": "Local CI: Exit All Jobs", "icon": "$(notebook-delete-cell)" }, { "command": "localCiJobs.selectRepo", - "title": "Select Repo ", + "title": "Local CI: Select Repo ", "icon": "$(debug-configure)" }, { "command": "localCiLicense.refresh", - "title": "Refresh License Information", + "title": "Local CI: Refresh License Information", "icon": "$(refresh)" } ], @@ -114,6 +119,11 @@ "when": "view == localCiJobs", "group": "navigation" }, + { + "command": "localCiJobs.enterToken", + "when": "view == localCiJobs", + "group": "navigation" + }, { "command": "localCiJobs.help", "when": "view == localCiJobs", diff --git a/src/extension.ts b/src/extension.ts index c9eb21b7..b6aad262 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1,6 +1,7 @@ import * as fs from 'fs'; import * as vscode from 'vscode'; import TelemetryReporter from 'vscode-extension-telemetry'; +import { getBinaryPath } from '../node/binary'; import Delayer from './classes/Delayer'; import Job from './classes/Job'; import JobProvider from './classes/JobProvider'; @@ -74,9 +75,23 @@ export function activate(context: vscode.ExtensionContext): void { vscode.commands.registerCommand(`${JOB_TREE_VIEW_ID}.refresh`, () => jobProvider.refresh() ), - vscode.commands.registerCommand(`${JOB_TREE_VIEW_ID}.help`, () => - vscode.env.openExternal(vscode.Uri.parse(HELP_URL)) - ), + vscode.commands.registerCommand(`${JOB_TREE_VIEW_ID}.enterToken`, () => { + const terminal = vscode.window.createTerminal({ + name: 'Store CircleCI® token', + message: `Please get a CircleCI® API token: https://circleci.com/docs/2.0/managing-api-tokens/ This will store the token on your local machine, Local CI won't do anything with that token other than run CircleCI jobs. If you'd rather store the token on your own, please follow these instructions to install the CircleCI CLI: https://circleci.com/docs/2.0/local-cli/ Then, run this Bash command: circleci setup. This token isn't necessary for all jobs, so you might not have to enter a token.`, + iconPath: vscode.Uri.joinPath( + context.extensionUri, + 'resources', + 'logo.svg' + ), + }); + terminal.show(); + terminal.sendText(`${getBinaryPath()} setup`); + }), + vscode.commands.registerCommand(`${JOB_TREE_VIEW_ID}.help`, () => { + reporter.sendTelemetryEvent('help'); + vscode.env.openExternal(vscode.Uri.parse(HELP_URL)); + }), vscode.commands.registerCommand(`${JOB_TREE_VIEW_ID}.exitAllJobs`, () => { reporter.sendTelemetryEvent('exitAllJobs'); jobProvider.refresh(); From ced5786824302f0bddd767fab5e2b5d53a8991c2 Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Thu, 16 Dec 2021 00:24:01 -0600 Subject: [PATCH 4/7] Reorder the commands in package.json --- package.json | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 646a6f3a..1fe99640 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,7 @@ }, { "command": "local-ci.debug.repo", - "title": "Local CI: Run Jobs Locally (Local CI)" + "title": "Local CI: Run Jobs Locally" }, { "command": "localCiJobs.enterToken", @@ -80,9 +80,9 @@ "icon": "$(record-keys)" }, { - "command": "localCiJobs.refresh", - "title": "Local CI: Refresh Job List", - "icon": "$(refresh)" + "command": "localCiJobs.exitAllJobs", + "title": "Local CI: Exit All Jobs", + "icon": "$(notebook-delete-cell)" }, { "command": "localCiJobs.help", @@ -90,9 +90,9 @@ "icon": "$(question)" }, { - "command": "localCiJobs.exitAllJobs", - "title": "Local CI: Exit All Jobs", - "icon": "$(notebook-delete-cell)" + "command": "localCiJobs.refresh", + "title": "Local CI: Refresh Job List", + "icon": "$(refresh)" }, { "command": "localCiJobs.selectRepo", @@ -115,12 +115,12 @@ "menus": { "view/title": [ { - "command": "localCiJobs.refresh", + "command": "localCiJobs.enterToken", "when": "view == localCiJobs", "group": "navigation" }, { - "command": "localCiJobs.enterToken", + "command": "localCiJobs.exitAllJobs", "when": "view == localCiJobs", "group": "navigation" }, @@ -130,7 +130,7 @@ "group": "navigation" }, { - "command": "localCiJobs.exitAllJobs", + "command": "localCiJobs.refresh", "when": "view == localCiJobs", "group": "navigation" }, From 9f14f55fe3afd043d4fa6bc4b3c94e7a405ebd59 Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Thu, 16 Dec 2021 00:28:19 -0600 Subject: [PATCH 5/7] Bump the version to 1.3.1 and add a CHANGELOG entry --- CHANGELOG.md | 5 +++++ package-lock.json | 4 ++-- package.json | 2 +- src/constants/index.ts | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c64b9773..0c2c01eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## 1.3.1 - 16 December 2021 + +### Added +- Allow entering a CircleCI® API token. [#57](https://github.com/getlocalci/local-ci/pull/57) + ## 1.3.0 - 15 December 2021 ### Added diff --git a/package-lock.json b/package-lock.json index 56241c58..406d122f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "local-ci", - "version": "1.3.0", + "version": "1.3.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "local-ci", - "version": "1.3.0", + "version": "1.3.1", "hasInstallScript": true, "license": "GPL-2.0-or-later", "os": [ diff --git a/package.json b/package.json index 1fe99640..074c0567 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "local-ci", "displayName": "Local CI", "description": "Debug CircleCI® workflows locally, with Bash access during and after. Free preview, then paid.", - "version": "1.3.0", + "version": "1.3.1", "publisher": "LocalCI", "contributors": [ "Ryan Kienstra" diff --git a/src/constants/index.ts b/src/constants/index.ts index b8b1bfbf..ea98f9ef 100644 --- a/src/constants/index.ts +++ b/src/constants/index.ts @@ -1,4 +1,4 @@ -export const EXTENSION_VERSION = '1.3.0'; +export const EXTENSION_VERSION = '1.3.1'; export const EXTENSION_ID = 'LocalCI.local-ci'; export const COMMITTED_IMAGE_NAMESPACE = 'local-ci'; export const SELECTED_CONFIG_PATH = 'local-ci.config.path'; From a6b8e3eb601ba22aba41a9b8e83ebea4dac693d5 Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Thu, 16 Dec 2021 00:30:58 -0600 Subject: [PATCH 6/7] Change the name of the terminal to be more clear --- src/extension.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/extension.ts b/src/extension.ts index b6aad262..f350d1e1 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -77,7 +77,7 @@ export function activate(context: vscode.ExtensionContext): void { ), vscode.commands.registerCommand(`${JOB_TREE_VIEW_ID}.enterToken`, () => { const terminal = vscode.window.createTerminal({ - name: 'Store CircleCI® token', + name: 'Enter CircleCI® API Token', message: `Please get a CircleCI® API token: https://circleci.com/docs/2.0/managing-api-tokens/ This will store the token on your local machine, Local CI won't do anything with that token other than run CircleCI jobs. If you'd rather store the token on your own, please follow these instructions to install the CircleCI CLI: https://circleci.com/docs/2.0/local-cli/ Then, run this Bash command: circleci setup. This token isn't necessary for all jobs, so you might not have to enter a token.`, iconPath: vscode.Uri.joinPath( context.extensionUri, From 31e540a42b36e25982fae8ff82e951f79a9042d8 Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Thu, 16 Dec 2021 00:32:34 -0600 Subject: [PATCH 7/7] Add a comment to be careful changing /tmp/local-ci --- src/constants/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constants/index.ts b/src/constants/index.ts index ea98f9ef..35d83b2c 100644 --- a/src/constants/index.ts +++ b/src/constants/index.ts @@ -49,7 +49,7 @@ export const HAS_EXTENDED_TRIAL = 'local-ci.license.trial-extended.survey'; export const TRIAL_STARTED_TIMESTAMP = 'local-ci.license.trial-started.timestamp'; export const CONTAINER_STORAGE_DIRECTORY = '/tmp/local-ci'; -export const HOST_TMP_DIRECTORY = '/tmp/local-ci'; // Also hard-coded in node/uninstall.js, change that if this changes. +export const HOST_TMP_DIRECTORY = '/tmp/local-ci'; // Also hard-coded in node/uninstall.js, change that if this changes. Be careful changing this, as there's an rm -rf for it. export const PROCESS_FILE_DIRECTORY = `${HOST_TMP_DIRECTORY}/process`; export const LOCAL_VOLUME_DIRECTORY = `${HOST_TMP_DIRECTORY}/volume`; export const RUN_JOB_COMMAND = 'local-ci.job.run';