From e927129d9e3c105c8e6e55e2b2cdd4ac4da4b984 Mon Sep 17 00:00:00 2001 From: Julien Poissonnier Date: Fri, 23 Aug 2024 17:32:43 +0200 Subject: [PATCH 1/8] Use fnm to switch between node version Pre-install the current nodejs LTS versions (18, 20, 22) and allow switching between them using `fnm`. The default remains at 18. Fixes https://github.com/pulumi/pulumi-docker-containers/issues/223 --- docker/pulumi/Dockerfile | 30 ++++++++++++----------- tests/containers_test.go | 29 +++++++++++++--------- tests/testdata/node-18/.node-version | 1 + tests/testdata/node-18/Pulumi.yaml | 10 ++++++++ tests/testdata/node-18/index.ts | 10 ++++++++ tests/testdata/node-18/package.json | 12 +++++++++ tests/testdata/node-18/tsconfig.json | 18 ++++++++++++++ tests/testdata/node-20/.node-version | 1 + tests/testdata/node-20/Pulumi.yaml | 10 ++++++++ tests/testdata/node-20/index.ts | 10 ++++++++ tests/testdata/node-20/package.json | 12 +++++++++ tests/testdata/node-20/tsconfig.json | 18 ++++++++++++++ tests/testdata/node-22.5.1/.node-version | 1 + tests/testdata/node-22.5.1/Pulumi.yaml | 10 ++++++++ tests/testdata/node-22.5.1/index.ts | 5 ++++ tests/testdata/node-22.5.1/package.json | 12 +++++++++ tests/testdata/node-22.5.1/tsconfig.json | 18 ++++++++++++++ tests/testdata/node-22/.node-version | 1 + tests/testdata/node-22/Pulumi.yaml | 10 ++++++++ tests/testdata/node-22/index.ts | 10 ++++++++ tests/testdata/node-22/package.json | 12 +++++++++ tests/testdata/node-22/tsconfig.json | 18 ++++++++++++++ tests/testdata/node-default/Pulumi.yaml | 10 ++++++++ tests/testdata/node-default/index.ts | 10 ++++++++ tests/testdata/node-default/package.json | 12 +++++++++ tests/testdata/node-default/tsconfig.json | 18 ++++++++++++++ 26 files changed, 282 insertions(+), 26 deletions(-) create mode 100644 tests/testdata/node-18/.node-version create mode 100644 tests/testdata/node-18/Pulumi.yaml create mode 100644 tests/testdata/node-18/index.ts create mode 100644 tests/testdata/node-18/package.json create mode 100644 tests/testdata/node-18/tsconfig.json create mode 100644 tests/testdata/node-20/.node-version create mode 100644 tests/testdata/node-20/Pulumi.yaml create mode 100644 tests/testdata/node-20/index.ts create mode 100644 tests/testdata/node-20/package.json create mode 100644 tests/testdata/node-20/tsconfig.json create mode 100644 tests/testdata/node-22.5.1/.node-version create mode 100644 tests/testdata/node-22.5.1/Pulumi.yaml create mode 100644 tests/testdata/node-22.5.1/index.ts create mode 100644 tests/testdata/node-22.5.1/package.json create mode 100644 tests/testdata/node-22.5.1/tsconfig.json create mode 100644 tests/testdata/node-22/.node-version create mode 100644 tests/testdata/node-22/Pulumi.yaml create mode 100644 tests/testdata/node-22/index.ts create mode 100644 tests/testdata/node-22/package.json create mode 100644 tests/testdata/node-22/tsconfig.json create mode 100644 tests/testdata/node-default/Pulumi.yaml create mode 100644 tests/testdata/node-default/index.ts create mode 100644 tests/testdata/node-default/package.json create mode 100644 tests/testdata/node-default/tsconfig.json diff --git a/docker/pulumi/Dockerfile b/docker/pulumi/Dockerfile index 92dcc949..2fb1e29b 100644 --- a/docker/pulumi/Dockerfile +++ b/docker/pulumi/Dockerfile @@ -66,19 +66,6 @@ RUN \ kubectl && \ rm -rf /var/lib/apt/lists/* -# Install nodejs and associated tools -RUN \ - # Add yarn repo - curl -fsSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \ - echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \ - # Add nodejs repo - curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \ - # Install packages - apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ - nodejs \ - yarn && \ - rm -rf /var/lib/apt/lists/* - # Install Go RUN curl -fsSLo /tmp/go.tgz https://golang.org/dl/go${GOLANG_VERSION}.linux-amd64.tar.gz && \ echo "${GOLANG_SHA256} /tmp/go.tgz" | sha256sum -c - && \ @@ -132,13 +119,28 @@ RUN ln -s /usr/local/share/pypoetry/bin/poetry /usr/local/bin/ # poetry will create virtual environments using the python version used by poetry itself. RUN poetry config virtualenvs.prefer-active-python true +# Install default nodejs versions and associated tools +RUN curl -fsSL https://fnm.vercel.app/install | bash -s -- --install-dir "/opt/fnm" --skip-shell && \ + ln -s /opt/fnm/fnm /usr/local/bin/fnm +ENV FNM_COREPACK_ENABLED="true" +ENV FNM_VERSION_FILE_STRATEGY="recursive" +ENV FNM_DIR=/opt/fnm +RUN fnm install 18 && \ + fnm install 20 && \ + fnm install 22 && \ + fnm alias 18 default +ENV PATH=/opt/fnm/aliases/default/bin:$PATH +RUN corepack install --global pnpm yarn + # Passing --build-arg PULUMI_VERSION=vX.Y.Z will use that version # of the SDK. Otherwise, we use whatever get.pulumi.com thinks is # the latest ARG PULUMI_VERSION # Install the Pulumi SDK, including the CLI and language runtimes. -RUN curl -fsSL https://get.pulumi.com/ | bash -s -- --version $PULUMI_VERSION && \ +# TODO: Should use $PULUMI_VERSION, not dev +# RUN curl -fsSL https://get.pulumi.com/ | bash -s -- --version $PULUMI_VERSION && \ +RUN curl -fsSL https://get.pulumi.com | bash -s -- --version dev && \ mv ~/.pulumi/bin/* /usr/bin # I think it's safe to say if we're using this mega image, we want pulumi diff --git a/tests/containers_test.go b/tests/containers_test.go index 15e01de9..c744640c 100644 --- a/tests/containers_test.go +++ b/tests/containers_test.go @@ -129,9 +129,9 @@ func TestPulumiTemplateTests(t *testing.T) { } } -func TestKitchenSinkPythonVersions(t *testing.T) { +func TestKitchenSinkLanguageVersions(t *testing.T) { if !isKitchenSink(t) { - t.Skip("Only running python version tests on kitchen sink") + t.Skip("Only language version tests on kitchen sink") } t.Parallel() @@ -140,6 +140,11 @@ func TestKitchenSinkPythonVersions(t *testing.T) { for _, dir := range dirs { dir := dir t.Run(dir.Name(), func(t *testing.T) { + if !strings.HasPrefix(dir.Name(), "node-") { + // We can't run the node tests in parallel because setting the node version is a + // global for the container + t.Parallel() + } p := filepath.Join("testdata", dir.Name()) copyTestData(t, p) integration.ProgramTest(t, &integration.ProgramTestOptions{ @@ -149,7 +154,11 @@ func TestKitchenSinkPythonVersions(t *testing.T) { PrepareProject: func(info *engine.Projinfo) error { cmd := exec.Command("pulumi", "install", "--use-language-version-tools") cmd.Dir = info.Root - return cmd.Run() + out, err := cmd.CombinedOutput() + if err != nil { + t.Logf("install failed: %s: %s", err, out) + } + return err }, }) }) @@ -283,26 +292,26 @@ func TestEnvironment(t *testing.T) { name: "node", expectedDebian: "/usr/local/bin/node", expectedUbi: "/usr/bin/node", - expectedKitchen: "/usr/bin/node", + expectedKitchen: "/opt/fnm/aliases/default/bin/node", }, { name: "npm", expectedDebian: "/usr/local/bin/npm", expectedUbi: "/usr/local/bin/npm", - expectedKitchen: "/usr/bin/npm", + expectedKitchen: "/opt/fnm/aliases/default/bin/npm", }, { name: "yarn", expectedDebian: "/usr/local/bin/yarn", expectedUbi: "/usr/local/bin/yarn", - expectedKitchen: "/usr/bin/yarn", + expectedKitchen: "/opt/fnm/aliases/default/bin/yarn", }, { name: "corepack", expectedDebian: "/usr/local/bin/corepack", expectedUbi: "/usr/bin/corepack", - expectedKitchen: "/usr/bin/corepack", + expectedKitchen: "/opt/fnm/aliases/default/bin/corepack", }, } { testCase := testCase @@ -328,7 +337,7 @@ func TestEnvironment(t *testing.T) { // Install scripts for various tools can sometimes modify PATH, usually by adding entries // to ~/.bashrc. This test ensures that we notice such modifications. expectedPaths := map[string]string{ - "pulumi": "/usr/local/share/pyenv/shims:/usr/local/share/pyenv/bin:/usr/share/dotnet:/pulumi/bin:/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", + "pulumi": "/opt/fnm/aliases/default/bin:/usr/local/share/pyenv/shims:/usr/local/share/pyenv/bin:/usr/share/dotnet:/pulumi/bin:/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "pulumi-debian-dotnet": "/root/.dotnet:/pulumi/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "pulumi-debian-go": "/pulumi/bin:/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "pulumi-debian-java": "/pulumi/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", @@ -344,10 +353,6 @@ func TestEnvironment(t *testing.T) { t.Run("PATH when running in bash", func(t *testing.T) { t.Parallel() expectedPath := expectedPaths[imageVariant] - // When running in bash, we pick up the PATH entry from the pulumi installation script. - if imageVariant == "pulumi" { - expectedPath += ":/root/.pulumi/bin" - } requireOutputWithBash(t, expectedPath, "printenv", "PATH") }) diff --git a/tests/testdata/node-18/.node-version b/tests/testdata/node-18/.node-version new file mode 100644 index 00000000..3c032078 --- /dev/null +++ b/tests/testdata/node-18/.node-version @@ -0,0 +1 @@ +18 diff --git a/tests/testdata/node-18/Pulumi.yaml b/tests/testdata/node-18/Pulumi.yaml new file mode 100644 index 00000000..c8fe4901 --- /dev/null +++ b/tests/testdata/node-18/Pulumi.yaml @@ -0,0 +1,10 @@ +name: node-default +runtime: + name: nodejs + options: + packagemanager: npm +description: A minimal TypeScript Pulumi program +config: + pulumi:tags: + value: + pulumi:template: typescript diff --git a/tests/testdata/node-18/index.ts b/tests/testdata/node-18/index.ts new file mode 100644 index 00000000..07f6ef81 --- /dev/null +++ b/tests/testdata/node-18/index.ts @@ -0,0 +1,10 @@ +import * as process from "node:process"; +import * as semver from "semver"; + +const version = semver.parse(process.version, { + loose: true +}); + +if (version?.major != 18) { + throw new Error(`Expected node version 18.x.x, got ${process.version}`); +} diff --git a/tests/testdata/node-18/package.json b/tests/testdata/node-18/package.json new file mode 100644 index 00000000..8b43296d --- /dev/null +++ b/tests/testdata/node-18/package.json @@ -0,0 +1,12 @@ +{ + "name": "node-default", + "main": "index.ts", + "devDependencies": { + "@types/node": "^18", + "typescript": "^5.0.0" + }, + "dependencies": { + "@pulumi/pulumi": "^3.113.0", + "semver": "^7.6.3" + } +} diff --git a/tests/testdata/node-18/tsconfig.json b/tests/testdata/node-18/tsconfig.json new file mode 100644 index 00000000..f960d517 --- /dev/null +++ b/tests/testdata/node-18/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "strict": true, + "outDir": "bin", + "target": "es2020", + "module": "commonjs", + "moduleResolution": "node", + "sourceMap": true, + "experimentalDecorators": true, + "pretty": true, + "noFallthroughCasesInSwitch": true, + "noImplicitReturns": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.ts" + ] +} diff --git a/tests/testdata/node-20/.node-version b/tests/testdata/node-20/.node-version new file mode 100644 index 00000000..209e3ef4 --- /dev/null +++ b/tests/testdata/node-20/.node-version @@ -0,0 +1 @@ +20 diff --git a/tests/testdata/node-20/Pulumi.yaml b/tests/testdata/node-20/Pulumi.yaml new file mode 100644 index 00000000..c8fe4901 --- /dev/null +++ b/tests/testdata/node-20/Pulumi.yaml @@ -0,0 +1,10 @@ +name: node-default +runtime: + name: nodejs + options: + packagemanager: npm +description: A minimal TypeScript Pulumi program +config: + pulumi:tags: + value: + pulumi:template: typescript diff --git a/tests/testdata/node-20/index.ts b/tests/testdata/node-20/index.ts new file mode 100644 index 00000000..086c985f --- /dev/null +++ b/tests/testdata/node-20/index.ts @@ -0,0 +1,10 @@ +import * as process from "node:process"; +import * as semver from "semver"; + +const version = semver.parse(process.version, { + loose: true +}); + +if (version?.major != 20) { + throw new Error(`Expected node version 20.x.x, got ${process.version}`); +} diff --git a/tests/testdata/node-20/package.json b/tests/testdata/node-20/package.json new file mode 100644 index 00000000..8b43296d --- /dev/null +++ b/tests/testdata/node-20/package.json @@ -0,0 +1,12 @@ +{ + "name": "node-default", + "main": "index.ts", + "devDependencies": { + "@types/node": "^18", + "typescript": "^5.0.0" + }, + "dependencies": { + "@pulumi/pulumi": "^3.113.0", + "semver": "^7.6.3" + } +} diff --git a/tests/testdata/node-20/tsconfig.json b/tests/testdata/node-20/tsconfig.json new file mode 100644 index 00000000..f960d517 --- /dev/null +++ b/tests/testdata/node-20/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "strict": true, + "outDir": "bin", + "target": "es2020", + "module": "commonjs", + "moduleResolution": "node", + "sourceMap": true, + "experimentalDecorators": true, + "pretty": true, + "noFallthroughCasesInSwitch": true, + "noImplicitReturns": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.ts" + ] +} diff --git a/tests/testdata/node-22.5.1/.node-version b/tests/testdata/node-22.5.1/.node-version new file mode 100644 index 00000000..1384ff6a --- /dev/null +++ b/tests/testdata/node-22.5.1/.node-version @@ -0,0 +1 @@ +22.5.1 diff --git a/tests/testdata/node-22.5.1/Pulumi.yaml b/tests/testdata/node-22.5.1/Pulumi.yaml new file mode 100644 index 00000000..c8fe4901 --- /dev/null +++ b/tests/testdata/node-22.5.1/Pulumi.yaml @@ -0,0 +1,10 @@ +name: node-default +runtime: + name: nodejs + options: + packagemanager: npm +description: A minimal TypeScript Pulumi program +config: + pulumi:tags: + value: + pulumi:template: typescript diff --git a/tests/testdata/node-22.5.1/index.ts b/tests/testdata/node-22.5.1/index.ts new file mode 100644 index 00000000..467494bf --- /dev/null +++ b/tests/testdata/node-22.5.1/index.ts @@ -0,0 +1,5 @@ +import * as process from "node:process"; + +if (process.version != "v22.5.1") { + throw new Error(`Expected node version 22.5.1 got ${process.version}`); +} diff --git a/tests/testdata/node-22.5.1/package.json b/tests/testdata/node-22.5.1/package.json new file mode 100644 index 00000000..8b43296d --- /dev/null +++ b/tests/testdata/node-22.5.1/package.json @@ -0,0 +1,12 @@ +{ + "name": "node-default", + "main": "index.ts", + "devDependencies": { + "@types/node": "^18", + "typescript": "^5.0.0" + }, + "dependencies": { + "@pulumi/pulumi": "^3.113.0", + "semver": "^7.6.3" + } +} diff --git a/tests/testdata/node-22.5.1/tsconfig.json b/tests/testdata/node-22.5.1/tsconfig.json new file mode 100644 index 00000000..f960d517 --- /dev/null +++ b/tests/testdata/node-22.5.1/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "strict": true, + "outDir": "bin", + "target": "es2020", + "module": "commonjs", + "moduleResolution": "node", + "sourceMap": true, + "experimentalDecorators": true, + "pretty": true, + "noFallthroughCasesInSwitch": true, + "noImplicitReturns": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.ts" + ] +} diff --git a/tests/testdata/node-22/.node-version b/tests/testdata/node-22/.node-version new file mode 100644 index 00000000..2bd5a0a9 --- /dev/null +++ b/tests/testdata/node-22/.node-version @@ -0,0 +1 @@ +22 diff --git a/tests/testdata/node-22/Pulumi.yaml b/tests/testdata/node-22/Pulumi.yaml new file mode 100644 index 00000000..c8fe4901 --- /dev/null +++ b/tests/testdata/node-22/Pulumi.yaml @@ -0,0 +1,10 @@ +name: node-default +runtime: + name: nodejs + options: + packagemanager: npm +description: A minimal TypeScript Pulumi program +config: + pulumi:tags: + value: + pulumi:template: typescript diff --git a/tests/testdata/node-22/index.ts b/tests/testdata/node-22/index.ts new file mode 100644 index 00000000..ccca95e5 --- /dev/null +++ b/tests/testdata/node-22/index.ts @@ -0,0 +1,10 @@ +import * as process from "node:process"; +import * as semver from "semver"; + +const version = semver.parse(process.version, { + loose: true +}); + +if (version?.major != 22) { + throw new Error(`Expected node version 22.x.x, got ${process.version}`); +} diff --git a/tests/testdata/node-22/package.json b/tests/testdata/node-22/package.json new file mode 100644 index 00000000..8b43296d --- /dev/null +++ b/tests/testdata/node-22/package.json @@ -0,0 +1,12 @@ +{ + "name": "node-default", + "main": "index.ts", + "devDependencies": { + "@types/node": "^18", + "typescript": "^5.0.0" + }, + "dependencies": { + "@pulumi/pulumi": "^3.113.0", + "semver": "^7.6.3" + } +} diff --git a/tests/testdata/node-22/tsconfig.json b/tests/testdata/node-22/tsconfig.json new file mode 100644 index 00000000..f960d517 --- /dev/null +++ b/tests/testdata/node-22/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "strict": true, + "outDir": "bin", + "target": "es2020", + "module": "commonjs", + "moduleResolution": "node", + "sourceMap": true, + "experimentalDecorators": true, + "pretty": true, + "noFallthroughCasesInSwitch": true, + "noImplicitReturns": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.ts" + ] +} diff --git a/tests/testdata/node-default/Pulumi.yaml b/tests/testdata/node-default/Pulumi.yaml new file mode 100644 index 00000000..c8fe4901 --- /dev/null +++ b/tests/testdata/node-default/Pulumi.yaml @@ -0,0 +1,10 @@ +name: node-default +runtime: + name: nodejs + options: + packagemanager: npm +description: A minimal TypeScript Pulumi program +config: + pulumi:tags: + value: + pulumi:template: typescript diff --git a/tests/testdata/node-default/index.ts b/tests/testdata/node-default/index.ts new file mode 100644 index 00000000..07f6ef81 --- /dev/null +++ b/tests/testdata/node-default/index.ts @@ -0,0 +1,10 @@ +import * as process from "node:process"; +import * as semver from "semver"; + +const version = semver.parse(process.version, { + loose: true +}); + +if (version?.major != 18) { + throw new Error(`Expected node version 18.x.x, got ${process.version}`); +} diff --git a/tests/testdata/node-default/package.json b/tests/testdata/node-default/package.json new file mode 100644 index 00000000..8b43296d --- /dev/null +++ b/tests/testdata/node-default/package.json @@ -0,0 +1,12 @@ +{ + "name": "node-default", + "main": "index.ts", + "devDependencies": { + "@types/node": "^18", + "typescript": "^5.0.0" + }, + "dependencies": { + "@pulumi/pulumi": "^3.113.0", + "semver": "^7.6.3" + } +} diff --git a/tests/testdata/node-default/tsconfig.json b/tests/testdata/node-default/tsconfig.json new file mode 100644 index 00000000..f960d517 --- /dev/null +++ b/tests/testdata/node-default/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "strict": true, + "outDir": "bin", + "target": "es2020", + "module": "commonjs", + "moduleResolution": "node", + "sourceMap": true, + "experimentalDecorators": true, + "pretty": true, + "noFallthroughCasesInSwitch": true, + "noImplicitReturns": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.ts" + ] +} From 778b6f5ee8d171241003724901be19378856a324 Mon Sep 17 00:00:00 2001 From: Julien Poissonnier Date: Wed, 28 Aug 2024 17:16:53 +0200 Subject: [PATCH 2/8] changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb18c34d..bc96903e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +- Include fnm and Nodejs 18, 20 and 22 in the kitchen sink image + ([#253](https://github.com/pulumi/pulumi-docker-containers/pull/253) + ## 3.131.0 - Add per-language versions of the `pulumi/pulumi-dotnet` image From 45c30ad81dbbec6631af39de189c53316905f0de Mon Sep 17 00:00:00 2001 From: Julien Poissonnier Date: Wed, 28 Aug 2024 18:13:47 +0200 Subject: [PATCH 3/8] fix tests --- tests/containers_test.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/containers_test.go b/tests/containers_test.go index c744640c..074e4063 100644 --- a/tests/containers_test.go +++ b/tests/containers_test.go @@ -140,14 +140,12 @@ func TestKitchenSinkLanguageVersions(t *testing.T) { for _, dir := range dirs { dir := dir t.Run(dir.Name(), func(t *testing.T) { - if !strings.HasPrefix(dir.Name(), "node-") { - // We can't run the node tests in parallel because setting the node version is a - // global for the container - t.Parallel() - } p := filepath.Join("testdata", dir.Name()) copyTestData(t, p) integration.ProgramTest(t, &integration.ProgramTestOptions{ + // We can't run the node tests in parallel because setting the node version is a + // global for the container. + NoParallel: strings.HasPrefix(dir.Name(), "node-"), Dir: p, Quick: true, SkipRefresh: true, From f5472ead3174a78c03d61694943f805e1ab06e94 Mon Sep 17 00:00:00 2001 From: Julien Poissonnier Date: Wed, 28 Aug 2024 18:21:41 +0200 Subject: [PATCH 4/8] move fnm to /usr/local/share/fnm --- docker/pulumi/Dockerfile | 10 +++++----- tests/containers_test.go | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docker/pulumi/Dockerfile b/docker/pulumi/Dockerfile index 2fb1e29b..5d5d65d0 100644 --- a/docker/pulumi/Dockerfile +++ b/docker/pulumi/Dockerfile @@ -120,16 +120,16 @@ RUN ln -s /usr/local/share/pypoetry/bin/poetry /usr/local/bin/ RUN poetry config virtualenvs.prefer-active-python true # Install default nodejs versions and associated tools -RUN curl -fsSL https://fnm.vercel.app/install | bash -s -- --install-dir "/opt/fnm" --skip-shell && \ - ln -s /opt/fnm/fnm /usr/local/bin/fnm +RUN curl -fsSL https://fnm.vercel.app/install | bash -s -- --install-dir "/usr/local/share/fnm" --skip-shell && \ + ln -s /usr/local/share/fnm/fnm /usr/local/bin/fnm ENV FNM_COREPACK_ENABLED="true" ENV FNM_VERSION_FILE_STRATEGY="recursive" -ENV FNM_DIR=/opt/fnm +ENV FNM_DIR=/usr/local/share/fnm RUN fnm install 18 && \ fnm install 20 && \ fnm install 22 && \ fnm alias 18 default -ENV PATH=/opt/fnm/aliases/default/bin:$PATH +ENV PATH=/usr/local/share/fnm/aliases/default/bin:$PATH RUN corepack install --global pnpm yarn # Passing --build-arg PULUMI_VERSION=vX.Y.Z will use that version @@ -140,7 +140,7 @@ ARG PULUMI_VERSION # Install the Pulumi SDK, including the CLI and language runtimes. # TODO: Should use $PULUMI_VERSION, not dev # RUN curl -fsSL https://get.pulumi.com/ | bash -s -- --version $PULUMI_VERSION && \ -RUN curl -fsSL https://get.pulumi.com | bash -s -- --version dev && \ +RUN curl -fsSL https://get.pulumi.com | sh -s -- --version dev && \ mv ~/.pulumi/bin/* /usr/bin # I think it's safe to say if we're using this mega image, we want pulumi diff --git a/tests/containers_test.go b/tests/containers_test.go index 074e4063..937f08e6 100644 --- a/tests/containers_test.go +++ b/tests/containers_test.go @@ -290,26 +290,26 @@ func TestEnvironment(t *testing.T) { name: "node", expectedDebian: "/usr/local/bin/node", expectedUbi: "/usr/bin/node", - expectedKitchen: "/opt/fnm/aliases/default/bin/node", + expectedKitchen: "/usr/local/share/fnm/aliases/default/bin/node", }, { name: "npm", expectedDebian: "/usr/local/bin/npm", expectedUbi: "/usr/local/bin/npm", - expectedKitchen: "/opt/fnm/aliases/default/bin/npm", + expectedKitchen: "/usr/local/share/fnm/aliases/default/bin/npm", }, { name: "yarn", expectedDebian: "/usr/local/bin/yarn", expectedUbi: "/usr/local/bin/yarn", - expectedKitchen: "/opt/fnm/aliases/default/bin/yarn", + expectedKitchen: "/usr/local/share/fnm/aliases/default/bin/yarn", }, { name: "corepack", expectedDebian: "/usr/local/bin/corepack", expectedUbi: "/usr/bin/corepack", - expectedKitchen: "/opt/fnm/aliases/default/bin/corepack", + expectedKitchen: "/usr/local/share/fnm/aliases/default/bin/corepack", }, } { testCase := testCase @@ -335,7 +335,7 @@ func TestEnvironment(t *testing.T) { // Install scripts for various tools can sometimes modify PATH, usually by adding entries // to ~/.bashrc. This test ensures that we notice such modifications. expectedPaths := map[string]string{ - "pulumi": "/opt/fnm/aliases/default/bin:/usr/local/share/pyenv/shims:/usr/local/share/pyenv/bin:/usr/share/dotnet:/pulumi/bin:/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", + "pulumi": "/usr/local/share/fnm/aliases/default/bin:/usr/local/share/pyenv/shims:/usr/local/share/pyenv/bin:/usr/share/dotnet:/pulumi/bin:/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "pulumi-debian-dotnet": "/root/.dotnet:/pulumi/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "pulumi-debian-go": "/pulumi/bin:/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "pulumi-debian-java": "/pulumi/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", From 63de3600736322bb79c8cbbb551719d2640157ea Mon Sep 17 00:00:00 2001 From: Julien Poissonnier Date: Thu, 29 Aug 2024 14:28:28 +0200 Subject: [PATCH 5/8] fix node-default test --- tests/containers_test.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/containers_test.go b/tests/containers_test.go index 937f08e6..d8607478 100644 --- a/tests/containers_test.go +++ b/tests/containers_test.go @@ -137,9 +137,36 @@ func TestKitchenSinkLanguageVersions(t *testing.T) { dirs, err := testdata.ReadDir("testdata") require.NoError(t, err) + + t.Run("node-default", func(t *testing.T) { + // We need to run the `node-default` test first, before the other tests which modify + // the container's default node version. + p := filepath.Join("testdata", "node-default") + copyTestData(t, p) + integration.ProgramTest(t, &integration.ProgramTestOptions{ + NoParallel: true, + Dir: p, + Quick: true, + SkipRefresh: true, + PrepareProject: func(info *engine.Projinfo) error { + cmd := exec.Command("pulumi", "install", "--use-language-version-tools") + cmd.Dir = info.Root + out, err := cmd.CombinedOutput() + if err != nil { + t.Logf("install failed: %s: %s", err, out) + } + return err + }, + }) + }) + for _, dir := range dirs { dir := dir t.Run(dir.Name(), func(t *testing.T) { + if dir.Name() == "node-default" { + // The `node-default` test is run first, so we skip it here. + t.Skip() + } p := filepath.Join("testdata", dir.Name()) copyTestData(t, p) integration.ProgramTest(t, &integration.ProgramTestOptions{ From f6788843a765d9422044b8b40c9dfe00477d8c66 Mon Sep 17 00:00:00 2001 From: Julien Poissonnier Date: Thu, 29 Aug 2024 17:15:21 +0200 Subject: [PATCH 6/8] =?UTF-8?q?don=E2=80=99t=20yarn=20link=20the=20SDK=20f?= =?UTF-8?q?or=20template=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/containers_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/containers_test.go b/tests/containers_test.go index d8607478..8fad70a7 100644 --- a/tests/containers_test.go +++ b/tests/containers_test.go @@ -122,6 +122,11 @@ func TestPulumiTemplateTests(t *testing.T) { example := base.With(integration.ProgramTestOptions{ Dir: e.RootPath, Config: test.config, + // `pulumi new` already runs `pulumi install for us, don't attempt to `yarn link` + // the SDK into the test. + PrepareProject: func(info *engine.Projinfo) error { + return nil + }, }) integration.ProgramTest(t, &example) From a059cdf7d72c22bbccdff4d9899e3e2923cb9438 Mon Sep 17 00:00:00 2001 From: Julien Poissonnier Date: Wed, 4 Sep 2024 21:53:01 +0200 Subject: [PATCH 7/8] use latest pu/pu release --- docker/pulumi/Dockerfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docker/pulumi/Dockerfile b/docker/pulumi/Dockerfile index 5d5d65d0..6a5419cc 100644 --- a/docker/pulumi/Dockerfile +++ b/docker/pulumi/Dockerfile @@ -138,9 +138,7 @@ RUN corepack install --global pnpm yarn ARG PULUMI_VERSION # Install the Pulumi SDK, including the CLI and language runtimes. -# TODO: Should use $PULUMI_VERSION, not dev -# RUN curl -fsSL https://get.pulumi.com/ | bash -s -- --version $PULUMI_VERSION && \ -RUN curl -fsSL https://get.pulumi.com | sh -s -- --version dev && \ +RUN curl -fsSL https://get.pulumi.com/ | bash -s -- --version $PULUMI_VERSION && \ mv ~/.pulumi/bin/* /usr/bin # I think it's safe to say if we're using this mega image, we want pulumi From 253b79a3ae7a6936c161b180378a37fc43a69dbc Mon Sep 17 00:00:00 2001 From: Julien Poissonnier Date: Fri, 6 Sep 2024 12:29:03 +0200 Subject: [PATCH 8/8] re-add bash path --- tests/containers_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/containers_test.go b/tests/containers_test.go index 8fad70a7..0e72a51d 100644 --- a/tests/containers_test.go +++ b/tests/containers_test.go @@ -383,6 +383,10 @@ func TestEnvironment(t *testing.T) { t.Run("PATH when running in bash", func(t *testing.T) { t.Parallel() expectedPath := expectedPaths[imageVariant] + // When running in bash, we pick up the PATH entry from the pulumi installation script. + if imageVariant == "pulumi" { + expectedPath += ":/root/.pulumi/bin" + } requireOutputWithBash(t, expectedPath, "printenv", "PATH") })