From 037f2d35d59080dc313608c565b55f37d2f42c7e Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Sat, 15 Oct 2022 15:41:14 -0500 Subject: [PATCH 1/6] Get the additional env vars from the user's local, not Docker As it is now, it depends on a checkout step. But there can be a custom checkout step, or a restore_workspace. --- src/config/Config.ts | 10 +++++++-- src/job/JobRunner.ts | 3 ++- src/process/ProcessFile.ts | 42 ++++++++++++++++++++++++++------------ src/script/addEnvVars.sh | 9 ++++---- 4 files changed, 43 insertions(+), 21 deletions(-) diff --git a/src/config/Config.ts b/src/config/Config.ts index 3767342a..2f93758f 100644 --- a/src/config/Config.ts +++ b/src/config/Config.ts @@ -12,6 +12,7 @@ import ProcessFile from 'process/ProcessFile'; import ReporterGateway from 'gateway/ReporterGateway'; import Spawn from 'common/Spawn'; import Types from 'common/Types'; +import getRepoPath from 'common/getRepoPath'; @injectable() export default class Config { @@ -55,7 +56,11 @@ export default class Config { this.childProcessGateway.cp, this.spawn.getOptions() ); - this.processFile.write(processedConfig, processFilePath); + this.processFile.write( + processedConfig, + processFilePath, + getRepoPath(configFilePath) + ); const dynamicConfigFilePath = getDynamicConfigPath(configFilePath); if (this.fsGateway.fs.existsSync(dynamicConfigFilePath)) { @@ -70,7 +75,8 @@ export default class Config { this.childProcessGateway.cp, this.spawn.getOptions() ), - dynamicConfigFilePath + dynamicConfigFilePath, + getRepoPath(configFilePath) ); } } catch (e) { diff --git a/src/job/JobRunner.ts b/src/job/JobRunner.ts index e269270e..151523fa 100644 --- a/src/job/JobRunner.ts +++ b/src/job/JobRunner.ts @@ -36,6 +36,7 @@ import { dockerExecRunningContainer, getRunningContainerFunction, } from 'script'; +import getRepoPath from 'common/getRepoPath'; @injectable() export default class JobRunner { @@ -87,7 +88,7 @@ export default class JobRunner { } const configFilePath = await this.configFile.getPath(context); - const repoPath = path.dirname(path.dirname(configFilePath)); + const repoPath = getRepoPath(configFilePath); const terminal = this.editorGateway.editor.window.createTerminal({ name: getTerminalName(jobName), message: `Running the CircleCI® job ${jobName}…`, diff --git a/src/process/ProcessFile.ts b/src/process/ProcessFile.ts index 4d9b55a9..82e48e5d 100644 --- a/src/process/ProcessFile.ts +++ b/src/process/ProcessFile.ts @@ -15,12 +15,20 @@ import { DYNAMIC_CONFIG_PATH_IN_CONTAINER, } from 'constant'; import { addEnvVars } from 'script'; +import ChildProcessGateway from 'gateway/ChildProcessGateway'; +import Spawn from 'common/Spawn'; @injectable() export default class ProcessFile { + @inject(Types.IChildProcessGateway) + childProcessGateway!: ChildProcessGateway; + @inject(Types.IFsGateway) fsGateway!: FsGateway; + @inject(Spawn) + spawn!: Spawn; + /** * Overwrites parts of the process.yml file. * @@ -28,9 +36,9 @@ export default class ProcessFile { * this copies the files inside the container to the volume shared with the local machine. * This way, they can persist between jobs. * Likewise, on attach_workspace, it copies from the volume. - * The processedConfig was already compiled by the CircleCI® CLI binary. + * The processedConfig was already compiled by the CircleCI CLI binary. */ - write(processedConfig: string, processFilePath: string) { + write(processedConfig: string, processFilePath: string, repoPath: string) { const config = getConfig(processedConfig); if (!config) { @@ -134,21 +142,13 @@ export default class ProcessFile { return step; }); - // If a 'checkout' step exists, insert env vars right after it. - if (newSteps?.includes('checkout')) { - newSteps?.splice( - newSteps?.indexOf('checkout') + 1, - 0, - this.getEnvVarStep() - ); - } - return { ...accumulator, [jobName]: { ...configJobs[jobName], steps: [ this.getEnsureVolumeIsWritableStep(), + this.getEnvVarStep(repoPath), ...(newSteps ?? []), ], }, @@ -225,11 +225,27 @@ export default class ProcessFile { }; } - private getEnvVarStep() { + private getEnvVarStep(repoPath: string) { + let command; + try { + const exportVars = this.childProcessGateway.cp + .execSync(addEnvVars, { + ...this.spawn.getOptions(repoPath), + timeout: 2000, + }) + .toString(); + + command = `echo '${exportVars}' >> $BASH_ENV`; + } catch (error) { + command = `There was an error setting the variables: ${ + (error as ErrorWithMessage).message + }`; + } + return { run: { name: 'Set more environment variables', - command: addEnvVars, + command, }, }; } diff --git a/src/script/addEnvVars.sh b/src/script/addEnvVars.sh index f1c9706f..08a7930b 100644 --- a/src/script/addEnvVars.sh +++ b/src/script/addEnvVars.sh @@ -1,8 +1,7 @@ #!/bin/sh # shellcheck disable=SC2016 -{ -echo 'export CIRCLE_SHA1=$(git rev-parse HEAD)' -echo 'export CIRCLE_BRANCH=$(git rev-parse --abbrev-ref HEAD)' -echo 'export CIRCLE_PROJECT_REPONAME=$(basename $(git remote get-url origin))' -} >> "$BASH_ENV" +echo "export CIRCLE_SHA1=$(git rev-parse HEAD)" +echo "export CIRCLE_BRANCH=$(git rev-parse --abbrev-ref HEAD)" +echo "export CIRCLE_PROJECT_REPONAME=$(basename "$(git remote get-url origin)")" +echo "export CIRCLE_REPOSITORY_URL=$(git remote get-url origin)" From 717239f35bdbc2c81fe836e3217ba8bf660e7426 Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Mon, 17 Oct 2022 00:09:31 -0500 Subject: [PATCH 2/6] Extract the env var method into a class that can be injected --- src/common/AppIoc.ts | 2 + src/common/Types.ts | 1 + src/process/ProcessFile.ts | 32 ++---------- src/process/test/ProcessFile.spec.ts | 4 +- src/test-tool/expected/dynamic-config.yml | 13 +++-- src/test-tool/expected/with-cache.yml | 62 ++++++++++++++++++++--- src/test-tool/helper/AppTestHarness.ts | 2 + 7 files changed, 73 insertions(+), 43 deletions(-) diff --git a/src/common/AppIoc.ts b/src/common/AppIoc.ts index 18ddfddd..43250d12 100644 --- a/src/common/AppIoc.ts +++ b/src/common/AppIoc.ts @@ -2,6 +2,7 @@ import 'reflect-metadata'; import BaseIoc from 'common/BaseIoc'; import ChildProcessGateway from 'gateway/ChildProcessGateway'; import EditorGateway from 'gateway/EditorGateway'; +import EnvVar from 'process/EnvVar'; import FsGateway from 'gateway/FsGateway'; import HttpGateway from 'gateway/HttpGateway'; import OsGateway from 'gateway/OsGateway'; @@ -16,6 +17,7 @@ iocContainer .to(ChildProcessGateway) .inSingletonScope(); iocContainer.bind(Types.IEditorGateway).to(EditorGateway).inSingletonScope(); +iocContainer.bind(Types.IEnvVar).to(EnvVar).inSingletonScope(); iocContainer.bind(Types.IFsGateway).to(FsGateway).inSingletonScope(); iocContainer.bind(Types.IHttpGateway).to(HttpGateway).inSingletonScope(); iocContainer.bind(Types.IOsGateway).to(OsGateway).inSingletonScope(); diff --git a/src/common/Types.ts b/src/common/Types.ts index 38d7de5f..e08f58a3 100644 --- a/src/common/Types.ts +++ b/src/common/Types.ts @@ -1,6 +1,7 @@ export default { IChildProcessGateway: Symbol.for('IChildProcessGateway'), IEditorGateway: Symbol.for('IEditorGateway'), + IEnvVar: Symbol.for('IEnvVar'), IFsGateway: Symbol.for('IFsGateway'), IHttpGateway: Symbol.for('IHttpGateway'), IOsGateway: Symbol.for('IOsGateway'), diff --git a/src/process/ProcessFile.ts b/src/process/ProcessFile.ts index 82e48e5d..202ef7d5 100644 --- a/src/process/ProcessFile.ts +++ b/src/process/ProcessFile.ts @@ -14,15 +14,18 @@ import { DYNAMIC_CONFIG_PARAMETERS_FILE_NAME, DYNAMIC_CONFIG_PATH_IN_CONTAINER, } from 'constant'; -import { addEnvVars } from 'script'; import ChildProcessGateway from 'gateway/ChildProcessGateway'; import Spawn from 'common/Spawn'; +import EnvVar from './EnvVar'; @injectable() export default class ProcessFile { @inject(Types.IChildProcessGateway) childProcessGateway!: ChildProcessGateway; + @inject(Types.IEnvVar) + envVar!: EnvVar; + @inject(Types.IFsGateway) fsGateway!: FsGateway; @@ -148,7 +151,7 @@ export default class ProcessFile { ...configJobs[jobName], steps: [ this.getEnsureVolumeIsWritableStep(), - this.getEnvVarStep(repoPath), + this.envVar.getStep(repoPath), ...(newSteps ?? []), ], }, @@ -224,29 +227,4 @@ export default class ProcessFile { }, }; } - - private getEnvVarStep(repoPath: string) { - let command; - try { - const exportVars = this.childProcessGateway.cp - .execSync(addEnvVars, { - ...this.spawn.getOptions(repoPath), - timeout: 2000, - }) - .toString(); - - command = `echo '${exportVars}' >> $BASH_ENV`; - } catch (error) { - command = `There was an error setting the variables: ${ - (error as ErrorWithMessage).message - }`; - } - - return { - run: { - name: 'Set more environment variables', - command, - }, - }; - } } diff --git a/src/process/test/ProcessFile.spec.ts b/src/process/test/ProcessFile.spec.ts index dd4560a2..9d820329 100644 --- a/src/process/test/ProcessFile.spec.ts +++ b/src/process/test/ProcessFile.spec.ts @@ -21,7 +21,7 @@ describe('ProcessFile', () => { const processFile = testHarness.container.get(ProcessFile); const writeFileSpy = jest.fn(); fsGateway.fs.writeFileSync = writeFileSpy; - processFile.write(withCacheFixture, '/foo/baz/'); + processFile.write(withCacheFixture, '/foo/baz/', '/your/repo/'); expect(writeFileSpy).toHaveBeenCalledTimes(1); expect(normalize(writeFileSpy.mock.lastCall[1])).toEqual( @@ -33,7 +33,7 @@ describe('ProcessFile', () => { const processFile = testHarness.container.get(ProcessFile); const writeFileSpy = jest.fn(); fsGateway.fs.writeFileSync = writeFileSpy; - processFile.write(dyanamicConfigFixture, '/foo/baz/'); + processFile.write(dyanamicConfigFixture, '/foo/baz/', '/your/repo/'); expect(writeFileSpy).toHaveBeenCalledTimes(1); expect(normalize(writeFileSpy.mock.lastCall[1])).toEqual( diff --git a/src/test-tool/expected/dynamic-config.yml b/src/test-tool/expected/dynamic-config.yml index 38a315e3..92c41794 100644 --- a/src/test-tool/expected/dynamic-config.yml +++ b/src/test-tool/expected/dynamic-config.yml @@ -11,15 +11,14 @@ jobs: then sudo chown $(whoami) /tmp/local-ci fi - - checkout - run: name: Set more environment variables - command: > - { - echo 'export CIRCLE_SHA1=$(git rev-parse HEAD)' - echo 'export CIRCLE_BRANCH=$(git rev-parse --abbrev-ref HEAD)' - echo 'export CIRCLE_PROJECT_REPONAME=$(basename $(git remote get-url origin))' - } >> "$BASH_ENV" + command: |- + echo "export CIRCLE_SHA1=037f2d35d59080dc313608c565b55f37d2f42c7e" + echo "export CIRCLE_BRANCH=develop" + echo "export CIRCLE_PROJECT_REPONAME=local-ci" + echo "export CIRCLE_REPOSITORY_URL=git@github.com:getlocalci/local-ci.git" + - checkout - run: name: Create config command: echo "Creating the dynamic config here" diff --git a/src/test-tool/expected/with-cache.yml b/src/test-tool/expected/with-cache.yml index f03c58a3..176deafb 100644 --- a/src/test-tool/expected/with-cache.yml +++ b/src/test-tool/expected/with-cache.yml @@ -14,15 +14,14 @@ jobs: then sudo chown $(whoami) /tmp/local-ci fi - - checkout - run: name: Set more environment variables - command: > - { - echo 'export CIRCLE_SHA1=$(git rev-parse HEAD)' - echo 'export CIRCLE_BRANCH=$(git rev-parse --abbrev-ref HEAD)' - echo 'export CIRCLE_PROJECT_REPONAME=$(basename $(git remote get-url origin))' - } >> "$BASH_ENV" + command: |- + echo "export CIRCLE_SHA1=037f2d35d59080dc313608c565b55f37d2f42c7e" + echo "export CIRCLE_BRANCH=develop" + echo "export CIRCLE_PROJECT_REPONAME=local-ci" + echo "export CIRCLE_REPOSITORY_URL=git@github.com:getlocalci/local-ci.git" + - checkout - run: name: Restore cache command: > @@ -91,6 +90,13 @@ jobs: then sudo chown $(whoami) /tmp/local-ci fi + - run: + name: Set more environment variables + command: |- + echo "export CIRCLE_SHA1=037f2d35d59080dc313608c565b55f37d2f42c7e" + echo "export CIRCLE_BRANCH=develop" + echo "export CIRCLE_PROJECT_REPONAME=local-ci" + echo "export CIRCLE_REPOSITORY_URL=git@github.com:getlocalci/local-ci.git" - run: name: Attach workspace command: |- @@ -130,6 +136,13 @@ jobs: then sudo chown $(whoami) /tmp/local-ci fi + - run: + name: Set more environment variables + command: |- + echo "export CIRCLE_SHA1=037f2d35d59080dc313608c565b55f37d2f42c7e" + echo "export CIRCLE_BRANCH=develop" + echo "export CIRCLE_PROJECT_REPONAME=local-ci" + echo "export CIRCLE_REPOSITORY_URL=git@github.com:getlocalci/local-ci.git" - run: name: Attach workspace command: |- @@ -155,6 +168,13 @@ jobs: then sudo chown $(whoami) /tmp/local-ci fi + - run: + name: Set more environment variables + command: |- + echo "export CIRCLE_SHA1=037f2d35d59080dc313608c565b55f37d2f42c7e" + echo "export CIRCLE_BRANCH=develop" + echo "export CIRCLE_PROJECT_REPONAME=local-ci" + echo "export CIRCLE_REPOSITORY_URL=git@github.com:getlocalci/local-ci.git" - run: name: Attach workspace command: |- @@ -180,6 +200,13 @@ jobs: then sudo chown $(whoami) /tmp/local-ci fi + - run: + name: Set more environment variables + command: |- + echo "export CIRCLE_SHA1=037f2d35d59080dc313608c565b55f37d2f42c7e" + echo "export CIRCLE_BRANCH=develop" + echo "export CIRCLE_PROJECT_REPONAME=local-ci" + echo "export CIRCLE_REPOSITORY_URL=git@github.com:getlocalci/local-ci.git" - run: name: Attach workspace command: |- @@ -232,6 +259,13 @@ jobs: then sudo chown $(whoami) /tmp/local-ci fi + - run: + name: Set more environment variables + command: |- + echo "export CIRCLE_SHA1=037f2d35d59080dc313608c565b55f37d2f42c7e" + echo "export CIRCLE_BRANCH=develop" + echo "export CIRCLE_PROJECT_REPONAME=local-ci" + echo "export CIRCLE_REPOSITORY_URL=git@github.com:getlocalci/local-ci.git" - run: name: Attach workspace command: |- @@ -260,6 +294,13 @@ jobs: then sudo chown $(whoami) /tmp/local-ci fi + - run: + name: Set more environment variables + command: |- + echo "export CIRCLE_SHA1=037f2d35d59080dc313608c565b55f37d2f42c7e" + echo "export CIRCLE_BRANCH=develop" + echo "export CIRCLE_PROJECT_REPONAME=local-ci" + echo "export CIRCLE_REPOSITORY_URL=git@github.com:getlocalci/local-ci.git" - run: name: Attach workspace command: |- @@ -285,6 +326,13 @@ jobs: then sudo chown $(whoami) /tmp/local-ci fi + - run: + name: Set more environment variables + command: |- + echo "export CIRCLE_SHA1=037f2d35d59080dc313608c565b55f37d2f42c7e" + echo "export CIRCLE_BRANCH=develop" + echo "export CIRCLE_PROJECT_REPONAME=local-ci" + echo "export CIRCLE_REPOSITORY_URL=git@github.com:getlocalci/local-ci.git" - run: name: Attach workspace command: |- diff --git a/src/test-tool/helper/AppTestHarness.ts b/src/test-tool/helper/AppTestHarness.ts index 53cf17e9..133812ab 100644 --- a/src/test-tool/helper/AppTestHarness.ts +++ b/src/test-tool/helper/AppTestHarness.ts @@ -8,6 +8,7 @@ import FakeHttpGateway from 'gateway/FakeHttpGateway'; import FakeOsGateway from 'gateway/FakeOsGateway'; import FakeProcessGateway from 'gateway/FakeProcessGateway'; import FakeReporterGateway from 'gateway/FakeReporterGateway'; +import FakeEnvVar from 'process/FakeEnvVar'; export default class AppTestHarness { container!: Container; @@ -25,6 +26,7 @@ export default class AppTestHarness { .bind(Types.IChildProcessGateway) .to(FakeChildProcessGateway) .inSingletonScope(); + this.container.bind(Types.IEnvVar).to(FakeEnvVar).inSingletonScope(); this.container .bind(Types.IEditorGateway) .to(FakeEditorGateway) From c35a9d804811fe40bce5eab7135baf8e7b8170c6 Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Mon, 17 Oct 2022 00:10:02 -0500 Subject: [PATCH 3/6] Add the EnvVar class I forgot to stage --- src/process/EnvVar.ts | 39 +++++++++++++++++++++++++++++++++++++++ src/process/FakeEnvVar.ts | 16 ++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 src/process/EnvVar.ts create mode 100644 src/process/FakeEnvVar.ts diff --git a/src/process/EnvVar.ts b/src/process/EnvVar.ts new file mode 100644 index 00000000..63c27c02 --- /dev/null +++ b/src/process/EnvVar.ts @@ -0,0 +1,39 @@ +import { injectable, inject } from 'inversify'; +import Types from 'common/Types'; +import { addEnvVars } from 'script'; +import ChildProcessGateway from 'gateway/ChildProcessGateway'; +import Spawn from 'common/Spawn'; + +@injectable() +export default class EnvVar { + @inject(Types.IChildProcessGateway) + childProcessGateway!: ChildProcessGateway; + + @inject(Spawn) + spawn!: Spawn; + + getStep(repoPath: string) { + let command; + try { + const exportVars = this.childProcessGateway.cp + .execSync(addEnvVars, { + ...this.spawn.getOptions(repoPath), + timeout: 2000, + }) + .toString(); + + command = `echo '${exportVars}' >> $BASH_ENV`; + } catch (error) { + command = `echo "There was an error setting the variables: ${ + (error as ErrorWithMessage).message + }"`; + } + + return { + run: { + name: 'Set more environment variables command', + command, + }, + }; + } +} diff --git a/src/process/FakeEnvVar.ts b/src/process/FakeEnvVar.ts new file mode 100644 index 00000000..f0b492f3 --- /dev/null +++ b/src/process/FakeEnvVar.ts @@ -0,0 +1,16 @@ +import { injectable } from 'inversify'; + +@injectable() +export default class FakeEnvVar { + getStep() { + return { + run: { + name: 'Set more environment variables', + command: `echo "export CIRCLE_SHA1=037f2d35d59080dc313608c565b55f37d2f42c7e" + echo "export CIRCLE_BRANCH=develop" + echo "export CIRCLE_PROJECT_REPONAME=local-ci" + echo "export CIRCLE_REPOSITORY_URL=git@github.com:getlocalci/local-ci.git"`, + }, + }; + } +} From c27579d8bce60e6d38ab03c5943905d4d9d8c08c Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Mon, 17 Oct 2022 00:28:55 -0500 Subject: [PATCH 4/6] Remove needless childProcessGateway property --- src/config/Config.ts | 2 +- src/job/Children.ts | 2 +- src/job/JobRunner.ts | 2 +- src/process/ProcessFile.ts | 4 ---- 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/config/Config.ts b/src/config/Config.ts index 2f93758f..32cc216d 100644 --- a/src/config/Config.ts +++ b/src/config/Config.ts @@ -8,11 +8,11 @@ import getDynamicConfigParametersPath from './getDynamicConfigParametersPath'; import getDynamicConfigPath from './getDynamicConfigPath'; import getProcessedConfig from './getProcessedConfig'; import getProcessFilePath from 'process/getProcessFilePath'; +import getRepoPath from 'common/getRepoPath'; import ProcessFile from 'process/ProcessFile'; import ReporterGateway from 'gateway/ReporterGateway'; import Spawn from 'common/Spawn'; import Types from 'common/Types'; -import getRepoPath from 'common/getRepoPath'; @injectable() export default class Config { diff --git a/src/job/Children.ts b/src/job/Children.ts index 8613f7fd..5a5fde9f 100644 --- a/src/job/Children.ts +++ b/src/job/Children.ts @@ -89,7 +89,7 @@ export default class Children { return [ ...this.getLogTreeItems( logs, - 'getJobName' in parentElement ? parentElement.getJobName() : '' + 'getJobName' in parentElement ? parentElement?.getJobName() : '' ), ...this.getJobTreeItems(children, logs, runningJob, jobDependencies), ]; diff --git a/src/job/JobRunner.ts b/src/job/JobRunner.ts index 151523fa..a03e5acb 100644 --- a/src/job/JobRunner.ts +++ b/src/job/JobRunner.ts @@ -17,6 +17,7 @@ import getImageFromJob from 'containerization/getImageFromJob'; import getLogFilePath from 'log/getLogFilePath'; import getLocalVolumePath from 'containerization/getLocalVolumePath'; import getProcessFilePath from 'process/getProcessFilePath'; +import getRepoPath from 'common/getRepoPath'; import getTerminalName from 'terminal/getTerminalName'; import JobFactory from 'job/JobFactory'; import JobListener from './JobListener'; @@ -36,7 +37,6 @@ import { dockerExecRunningContainer, getRunningContainerFunction, } from 'script'; -import getRepoPath from 'common/getRepoPath'; @injectable() export default class JobRunner { diff --git a/src/process/ProcessFile.ts b/src/process/ProcessFile.ts index 202ef7d5..4d65676e 100644 --- a/src/process/ProcessFile.ts +++ b/src/process/ProcessFile.ts @@ -14,15 +14,11 @@ import { DYNAMIC_CONFIG_PARAMETERS_FILE_NAME, DYNAMIC_CONFIG_PATH_IN_CONTAINER, } from 'constant'; -import ChildProcessGateway from 'gateway/ChildProcessGateway'; import Spawn from 'common/Spawn'; import EnvVar from './EnvVar'; @injectable() export default class ProcessFile { - @inject(Types.IChildProcessGateway) - childProcessGateway!: ChildProcessGateway; - @inject(Types.IEnvVar) envVar!: EnvVar; From 85eb1ed2cd3ab2d4c8610e89cfd48e150f563338 Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Mon, 17 Oct 2022 00:30:02 -0500 Subject: [PATCH 5/6] Remove needless spawn property --- src/process/ProcessFile.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/process/ProcessFile.ts b/src/process/ProcessFile.ts index 4d65676e..177e697b 100644 --- a/src/process/ProcessFile.ts +++ b/src/process/ProcessFile.ts @@ -14,7 +14,6 @@ import { DYNAMIC_CONFIG_PARAMETERS_FILE_NAME, DYNAMIC_CONFIG_PATH_IN_CONTAINER, } from 'constant'; -import Spawn from 'common/Spawn'; import EnvVar from './EnvVar'; @injectable() @@ -25,9 +24,6 @@ export default class ProcessFile { @inject(Types.IFsGateway) fsGateway!: FsGateway; - @inject(Spawn) - spawn!: Spawn; - /** * Overwrites parts of the process.yml file. * From 5aad98f9563ce828b805ae03fef6567801e15239 Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Mon, 17 Oct 2022 00:45:12 -0500 Subject: [PATCH 6/6] Update the unit test expected .yml files --- src/process/FakeEnvVar.ts | 4 +- src/test-tool/expected/dynamic-config.yml | 6 +-- src/test-tool/expected/with-cache.yml | 48 +++++++++++------------ 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/process/FakeEnvVar.ts b/src/process/FakeEnvVar.ts index f0b492f3..444e5504 100644 --- a/src/process/FakeEnvVar.ts +++ b/src/process/FakeEnvVar.ts @@ -6,10 +6,10 @@ export default class FakeEnvVar { return { run: { name: 'Set more environment variables', - command: `echo "export CIRCLE_SHA1=037f2d35d59080dc313608c565b55f37d2f42c7e" + command: `echo 'echo "export CIRCLE_SHA1=037f2d35d59080dc313608c565b55f37d2f42c7e" echo "export CIRCLE_BRANCH=develop" echo "export CIRCLE_PROJECT_REPONAME=local-ci" - echo "export CIRCLE_REPOSITORY_URL=git@github.com:getlocalci/local-ci.git"`, + echo "export CIRCLE_REPOSITORY_URL=git@github.com:getlocalci/local-ci.git"' >> $BASH_ENV`, }, }; } diff --git a/src/test-tool/expected/dynamic-config.yml b/src/test-tool/expected/dynamic-config.yml index 92c41794..f8da6b84 100644 --- a/src/test-tool/expected/dynamic-config.yml +++ b/src/test-tool/expected/dynamic-config.yml @@ -13,11 +13,11 @@ jobs: fi - run: name: Set more environment variables - command: |- - echo "export CIRCLE_SHA1=037f2d35d59080dc313608c565b55f37d2f42c7e" + command: >- + echo 'echo "export CIRCLE_SHA1=037f2d35d59080dc313608c565b55f37d2f42c7e" echo "export CIRCLE_BRANCH=develop" echo "export CIRCLE_PROJECT_REPONAME=local-ci" - echo "export CIRCLE_REPOSITORY_URL=git@github.com:getlocalci/local-ci.git" + echo "export CIRCLE_REPOSITORY_URL=git@github.com:getlocalci/local-ci.git"' >> $BASH_ENV - checkout - run: name: Create config diff --git a/src/test-tool/expected/with-cache.yml b/src/test-tool/expected/with-cache.yml index 176deafb..6b571496 100644 --- a/src/test-tool/expected/with-cache.yml +++ b/src/test-tool/expected/with-cache.yml @@ -16,11 +16,11 @@ jobs: fi - run: name: Set more environment variables - command: |- - echo "export CIRCLE_SHA1=037f2d35d59080dc313608c565b55f37d2f42c7e" + command: >- + echo 'echo "export CIRCLE_SHA1=037f2d35d59080dc313608c565b55f37d2f42c7e" echo "export CIRCLE_BRANCH=develop" echo "export CIRCLE_PROJECT_REPONAME=local-ci" - echo "export CIRCLE_REPOSITORY_URL=git@github.com:getlocalci/local-ci.git" + echo "export CIRCLE_REPOSITORY_URL=git@github.com:getlocalci/local-ci.git"' >> $BASH_ENV - checkout - run: name: Restore cache @@ -92,11 +92,11 @@ jobs: fi - run: name: Set more environment variables - command: |- - echo "export CIRCLE_SHA1=037f2d35d59080dc313608c565b55f37d2f42c7e" + command: >- + echo 'echo "export CIRCLE_SHA1=037f2d35d59080dc313608c565b55f37d2f42c7e" echo "export CIRCLE_BRANCH=develop" echo "export CIRCLE_PROJECT_REPONAME=local-ci" - echo "export CIRCLE_REPOSITORY_URL=git@github.com:getlocalci/local-ci.git" + echo "export CIRCLE_REPOSITORY_URL=git@github.com:getlocalci/local-ci.git"' >> $BASH_ENV - run: name: Attach workspace command: |- @@ -138,11 +138,11 @@ jobs: fi - run: name: Set more environment variables - command: |- - echo "export CIRCLE_SHA1=037f2d35d59080dc313608c565b55f37d2f42c7e" + command: >- + echo 'echo "export CIRCLE_SHA1=037f2d35d59080dc313608c565b55f37d2f42c7e" echo "export CIRCLE_BRANCH=develop" echo "export CIRCLE_PROJECT_REPONAME=local-ci" - echo "export CIRCLE_REPOSITORY_URL=git@github.com:getlocalci/local-ci.git" + echo "export CIRCLE_REPOSITORY_URL=git@github.com:getlocalci/local-ci.git"' >> $BASH_ENV - run: name: Attach workspace command: |- @@ -170,11 +170,11 @@ jobs: fi - run: name: Set more environment variables - command: |- - echo "export CIRCLE_SHA1=037f2d35d59080dc313608c565b55f37d2f42c7e" + command: >- + echo 'echo "export CIRCLE_SHA1=037f2d35d59080dc313608c565b55f37d2f42c7e" echo "export CIRCLE_BRANCH=develop" echo "export CIRCLE_PROJECT_REPONAME=local-ci" - echo "export CIRCLE_REPOSITORY_URL=git@github.com:getlocalci/local-ci.git" + echo "export CIRCLE_REPOSITORY_URL=git@github.com:getlocalci/local-ci.git"' >> $BASH_ENV - run: name: Attach workspace command: |- @@ -202,11 +202,11 @@ jobs: fi - run: name: Set more environment variables - command: |- - echo "export CIRCLE_SHA1=037f2d35d59080dc313608c565b55f37d2f42c7e" + command: >- + echo 'echo "export CIRCLE_SHA1=037f2d35d59080dc313608c565b55f37d2f42c7e" echo "export CIRCLE_BRANCH=develop" echo "export CIRCLE_PROJECT_REPONAME=local-ci" - echo "export CIRCLE_REPOSITORY_URL=git@github.com:getlocalci/local-ci.git" + echo "export CIRCLE_REPOSITORY_URL=git@github.com:getlocalci/local-ci.git"' >> $BASH_ENV - run: name: Attach workspace command: |- @@ -261,11 +261,11 @@ jobs: fi - run: name: Set more environment variables - command: |- - echo "export CIRCLE_SHA1=037f2d35d59080dc313608c565b55f37d2f42c7e" + command: >- + echo 'echo "export CIRCLE_SHA1=037f2d35d59080dc313608c565b55f37d2f42c7e" echo "export CIRCLE_BRANCH=develop" echo "export CIRCLE_PROJECT_REPONAME=local-ci" - echo "export CIRCLE_REPOSITORY_URL=git@github.com:getlocalci/local-ci.git" + echo "export CIRCLE_REPOSITORY_URL=git@github.com:getlocalci/local-ci.git"' >> $BASH_ENV - run: name: Attach workspace command: |- @@ -296,11 +296,11 @@ jobs: fi - run: name: Set more environment variables - command: |- - echo "export CIRCLE_SHA1=037f2d35d59080dc313608c565b55f37d2f42c7e" + command: >- + echo 'echo "export CIRCLE_SHA1=037f2d35d59080dc313608c565b55f37d2f42c7e" echo "export CIRCLE_BRANCH=develop" echo "export CIRCLE_PROJECT_REPONAME=local-ci" - echo "export CIRCLE_REPOSITORY_URL=git@github.com:getlocalci/local-ci.git" + echo "export CIRCLE_REPOSITORY_URL=git@github.com:getlocalci/local-ci.git"' >> $BASH_ENV - run: name: Attach workspace command: |- @@ -328,11 +328,11 @@ jobs: fi - run: name: Set more environment variables - command: |- - echo "export CIRCLE_SHA1=037f2d35d59080dc313608c565b55f37d2f42c7e" + command: >- + echo 'echo "export CIRCLE_SHA1=037f2d35d59080dc313608c565b55f37d2f42c7e" echo "export CIRCLE_BRANCH=develop" echo "export CIRCLE_PROJECT_REPONAME=local-ci" - echo "export CIRCLE_REPOSITORY_URL=git@github.com:getlocalci/local-ci.git" + echo "export CIRCLE_REPOSITORY_URL=git@github.com:getlocalci/local-ci.git"' >> $BASH_ENV - run: name: Attach workspace command: |-