From 8ff6b0ced5b588101bce38b63b86d8f02101f77a Mon Sep 17 00:00:00 2001 From: Josh Spicer Date: Tue, 30 Aug 2022 15:24:02 +0000 Subject: [PATCH 1/5] capture issue in tests --- .../.devcontainer.json | 2 +- .../.devcontainer/devcontainer.json | 2 +- src/test/container-features/e2e.test.ts | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/container-features/configs/dockerfile-with-v2-local-features-no-dev-container-folder/.devcontainer.json b/src/test/container-features/configs/dockerfile-with-v2-local-features-no-dev-container-folder/.devcontainer.json index 0427989cc..cb70c75f7 100644 --- a/src/test/container-features/configs/dockerfile-with-v2-local-features-no-dev-container-folder/.devcontainer.json +++ b/src/test/container-features/configs/dockerfile-with-v2-local-features-no-dev-container-folder/.devcontainer.json @@ -4,7 +4,7 @@ }, "features": { "./local-features/localFeatureA": { - "greeting": "buongiorno" + "greeting": "Hello there" }, "./local-features/localFeatureB": { "favorite": "gold" diff --git a/src/test/container-features/configs/dockerfile-with-v2-local-features-with-dev-container-folder/.devcontainer/devcontainer.json b/src/test/container-features/configs/dockerfile-with-v2-local-features-with-dev-container-folder/.devcontainer/devcontainer.json index 0427989cc..cb70c75f7 100644 --- a/src/test/container-features/configs/dockerfile-with-v2-local-features-with-dev-container-folder/.devcontainer/devcontainer.json +++ b/src/test/container-features/configs/dockerfile-with-v2-local-features-with-dev-container-folder/.devcontainer/devcontainer.json @@ -4,7 +4,7 @@ }, "features": { "./local-features/localFeatureA": { - "greeting": "buongiorno" + "greeting": "Hello there" }, "./local-features/localFeatureB": { "favorite": "gold" diff --git a/src/test/container-features/e2e.test.ts b/src/test/container-features/e2e.test.ts index c2cfc6793..1df579cee 100644 --- a/src/test/container-features/e2e.test.ts +++ b/src/test/container-features/e2e.test.ts @@ -171,7 +171,7 @@ describe('Dev Container Features E2E (local-path)', function () { const response = JSON.parse(res.stdout); console.log(res.stderr); assert.equal(response.outcome, 'success'); - assert.match(res.stderr, /buongiorno, root!/); + assert.match(res.stderr, /Hello there, root!/); }); it('should read configuration with features', async () => { @@ -201,7 +201,7 @@ describe('Dev Container Features E2E (local-path)', function () { const response = JSON.parse(res.stdout); console.log(res.stderr); assert.equal(response.outcome, 'success'); - assert.match(res.stderr, /buongiorno, root!/); + assert.match(res.stderr, /Hello there, root!/); }); it('should read configuration with features with customizations', async () => { From 790a4eb065141000ed83812b471f3d0afae74fa8 Mon Sep 17 00:00:00 2001 From: Josh Spicer Date: Tue, 30 Aug 2022 15:48:48 +0000 Subject: [PATCH 2/5] fixes https://github.com/devcontainers/cli/issues/148 and updates test --- src/spec-configuration/containerFeaturesConfiguration.ts | 2 +- src/spec-node/containerFeatures.ts | 4 ++-- .../.devcontainer.json | 3 ++- .../local-features/localFeatureA/install.sh | 3 ++- src/test/container-features/e2e.test.ts | 4 ++-- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/spec-configuration/containerFeaturesConfiguration.ts b/src/spec-configuration/containerFeaturesConfiguration.ts index b2a00b13f..95a9f0fb5 100644 --- a/src/spec-configuration/containerFeaturesConfiguration.ts +++ b/src/spec-configuration/containerFeaturesConfiguration.ts @@ -244,7 +244,7 @@ export function getFeatureLayers(featuresConfig: FeaturesConfig) { result += ` RUN cd /tmp/build-features/${feature.consecutiveId} \\ -&& export $(cat devcontainer-features.env | xargs) \\ +&& . ./devcontainer-features.env \\ && chmod +x ./install.sh \\ && ./install.sh diff --git a/src/spec-node/containerFeatures.ts b/src/spec-node/containerFeatures.ts index 90625d3d6..b86e4ec7d 100644 --- a/src/spec-node/containerFeatures.ts +++ b/src/spec-node/containerFeatures.ts @@ -346,10 +346,10 @@ function getFeatureEnvVariables(f: Feature) { } else { if (values) { variables.push(...Object.keys(values) - .map(name => `${getSafeId(name)}="${values[name]}"`)); + .map(name => `export ${getSafeId(name)}="${values[name]}"`)); } if (f.buildArg) { - variables.push(`${f.buildArg}=${getFeatureMainValue(f)}`); + variables.push(`export ${f.buildArg}=${getFeatureMainValue(f)}`); } return variables; } diff --git a/src/test/container-features/configs/dockerfile-with-v2-local-features-no-dev-container-folder/.devcontainer.json b/src/test/container-features/configs/dockerfile-with-v2-local-features-no-dev-container-folder/.devcontainer.json index cb70c75f7..96cbc26a9 100644 --- a/src/test/container-features/configs/dockerfile-with-v2-local-features-no-dev-container-folder/.devcontainer.json +++ b/src/test/container-features/configs/dockerfile-with-v2-local-features-no-dev-container-folder/.devcontainer.json @@ -4,7 +4,8 @@ }, "features": { "./local-features/localFeatureA": { - "greeting": "Hello there" + "greeting": "Hello there", + "punctuation": "!!!!" }, "./local-features/localFeatureB": { "favorite": "gold" diff --git a/src/test/container-features/configs/dockerfile-with-v2-local-features-no-dev-container-folder/local-features/localFeatureA/install.sh b/src/test/container-features/configs/dockerfile-with-v2-local-features-no-dev-container-folder/local-features/localFeatureA/install.sh index 9088fe5a2..95d670a48 100644 --- a/src/test/container-features/configs/dockerfile-with-v2-local-features-no-dev-container-folder/local-features/localFeatureA/install.sh +++ b/src/test/container-features/configs/dockerfile-with-v2-local-features-no-dev-container-folder/local-features/localFeatureA/install.sh @@ -3,6 +3,7 @@ echo "Activating feature 'localFeatureA'" GREETING=${GREETING:-undefined} +PUNCTUATION=${PUNCTUATION:-?????} echo "The provided greeting is: $GREETING" tee /usr/hello.sh > /dev/null \ @@ -10,7 +11,7 @@ tee /usr/hello.sh > /dev/null \ #!/bin/bash RED='\033[0;91m' NC='\033[0m' # No Color -echo -e -n "\${RED}${GREETING}, \$(whoami)!" +echo -e -n "\${RED}${GREETING}, \$(whoami)${PUNCTUATION}" echo -e -n "\${NC}" EOF diff --git a/src/test/container-features/e2e.test.ts b/src/test/container-features/e2e.test.ts index 1df579cee..958502510 100644 --- a/src/test/container-features/e2e.test.ts +++ b/src/test/container-features/e2e.test.ts @@ -171,7 +171,7 @@ describe('Dev Container Features E2E (local-path)', function () { const response = JSON.parse(res.stdout); console.log(res.stderr); assert.equal(response.outcome, 'success'); - assert.match(res.stderr, /Hello there, root!/); + assert.match(res.stderr, /Hello there, root!!!!/); }); it('should read configuration with features', async () => { @@ -201,7 +201,7 @@ describe('Dev Container Features E2E (local-path)', function () { const response = JSON.parse(res.stdout); console.log(res.stderr); assert.equal(response.outcome, 'success'); - assert.match(res.stderr, /Hello there, root!/); + assert.match(res.stderr, /Hello there, root!!!!/); }); it('should read configuration with features with customizations', async () => { From 15d222a51bb629c081f6d99c159a39dd9a338838 Mon Sep 17 00:00:00 2001 From: Josh Spicer Date: Tue, 30 Aug 2022 15:52:26 +0000 Subject: [PATCH 3/5] update similar test --- .../.devcontainer/devcontainer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/container-features/configs/dockerfile-with-v2-local-features-with-dev-container-folder/.devcontainer/devcontainer.json b/src/test/container-features/configs/dockerfile-with-v2-local-features-with-dev-container-folder/.devcontainer/devcontainer.json index cb70c75f7..96cbc26a9 100644 --- a/src/test/container-features/configs/dockerfile-with-v2-local-features-with-dev-container-folder/.devcontainer/devcontainer.json +++ b/src/test/container-features/configs/dockerfile-with-v2-local-features-with-dev-container-folder/.devcontainer/devcontainer.json @@ -4,7 +4,8 @@ }, "features": { "./local-features/localFeatureA": { - "greeting": "Hello there" + "greeting": "Hello there", + "punctuation": "!!!!" }, "./local-features/localFeatureB": { "favorite": "gold" From 05be4f4d374147c5ce866c1b8749a305afc26d70 Mon Sep 17 00:00:00 2001 From: Josh Spicer Date: Tue, 30 Aug 2022 17:17:15 +0000 Subject: [PATCH 4/5] update install script --- .../local-features/localFeatureA/install.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/container-features/configs/dockerfile-with-v2-local-features-with-dev-container-folder/local-features/localFeatureA/install.sh b/src/test/container-features/configs/dockerfile-with-v2-local-features-with-dev-container-folder/local-features/localFeatureA/install.sh index 9088fe5a2..95d670a48 100644 --- a/src/test/container-features/configs/dockerfile-with-v2-local-features-with-dev-container-folder/local-features/localFeatureA/install.sh +++ b/src/test/container-features/configs/dockerfile-with-v2-local-features-with-dev-container-folder/local-features/localFeatureA/install.sh @@ -3,6 +3,7 @@ echo "Activating feature 'localFeatureA'" GREETING=${GREETING:-undefined} +PUNCTUATION=${PUNCTUATION:-?????} echo "The provided greeting is: $GREETING" tee /usr/hello.sh > /dev/null \ @@ -10,7 +11,7 @@ tee /usr/hello.sh > /dev/null \ #!/bin/bash RED='\033[0;91m' NC='\033[0m' # No Color -echo -e -n "\${RED}${GREETING}, \$(whoami)!" +echo -e -n "\${RED}${GREETING}, \$(whoami)${PUNCTUATION}" echo -e -n "\${NC}" EOF From 70db80248bd995f1c2960c90ff4586cd8dba6e32 Mon Sep 17 00:00:00 2001 From: Josh Spicer Date: Tue, 30 Aug 2022 20:37:28 +0000 Subject: [PATCH 5/5] set -a --- src/spec-configuration/containerFeaturesConfiguration.ts | 2 ++ src/spec-node/containerFeatures.ts | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/spec-configuration/containerFeaturesConfiguration.ts b/src/spec-configuration/containerFeaturesConfiguration.ts index 95a9f0fb5..1f2a019c1 100644 --- a/src/spec-configuration/containerFeaturesConfiguration.ts +++ b/src/spec-configuration/containerFeaturesConfiguration.ts @@ -244,7 +244,9 @@ export function getFeatureLayers(featuresConfig: FeaturesConfig) { result += ` RUN cd /tmp/build-features/${feature.consecutiveId} \\ +&& set -a \\ && . ./devcontainer-features.env \\ +&& set +a \\ && chmod +x ./install.sh \\ && ./install.sh diff --git a/src/spec-node/containerFeatures.ts b/src/spec-node/containerFeatures.ts index b86e4ec7d..90625d3d6 100644 --- a/src/spec-node/containerFeatures.ts +++ b/src/spec-node/containerFeatures.ts @@ -346,10 +346,10 @@ function getFeatureEnvVariables(f: Feature) { } else { if (values) { variables.push(...Object.keys(values) - .map(name => `export ${getSafeId(name)}="${values[name]}"`)); + .map(name => `${getSafeId(name)}="${values[name]}"`)); } if (f.buildArg) { - variables.push(`export ${f.buildArg}=${getFeatureMainValue(f)}`); + variables.push(`${f.buildArg}=${getFeatureMainValue(f)}`); } return variables; }