Skip to content

Commit

Permalink
fix(workflows): error when running garden in a workflow script step
Browse files Browse the repository at this point in the history
This works around vercel/pkg#897 by patching
the `pkg` `prelude/bootstrap.js` script.

Fixes #2032
  • Loading branch information
edvald committed Jun 1, 2021
1 parent d512a43 commit acbfb63
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 16 deletions.
12 changes: 10 additions & 2 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
"minimist": "^1.2.5",
"mocha": "^8.1.1",
"mocha-logger": "^1.0.6",
"pkg": "4.4.9",
"patch-package": "^6.4.7",
"pkg": "4.5.1",
"postinstall-postinstall": "^2.1.0",
"prettier": "^2.1.0",
"split2": "^3.2.2",
"tslint": "^6.1.3",
Expand All @@ -58,6 +60,7 @@
"fix-format": "prettier --write \"{src,test}/**/*.ts\"",
"generate-docs": "node ./build/src/generate-docs.js",
"lint": "tslint -p .",
"postinstall": "patch-package",
"test": "mocha"
},
"pkg": {
Expand All @@ -67,5 +70,10 @@
"node_modules/@garden-io/**/*.js",
"node_modules/es-get-iterator/**/*.js"
]
},
"workspaces": {
"nohoist": [
"pkg"
]
}
}
}
13 changes: 13 additions & 0 deletions cli/patches/pkg+4.5.1.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/node_modules/pkg/prelude/bootstrap.js b/node_modules/pkg/prelude/bootstrap.js
index 0d19f1d..f7f5415 100644
--- a/node_modules/pkg/prelude/bootstrap.js
+++ b/node_modules/pkg/prelude/bootstrap.js
@@ -1400,7 +1400,7 @@ function payloadFileSync (pointer) {
}
var opts = args[pos];
if (!opts.env) opts.env = require('util')._extend({}, process.env);
- if (opts.env.PKG_EXECPATH === 'PKG_INVOKE_NODEJS') return;
+ if (opts.env.PKG_EXECPATH !== undefined) return;
opts.env.PKG_EXECPATH = EXECPATH;
}

2 changes: 1 addition & 1 deletion cli/src/build-pkg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ require("source-map-support").install()
const repoRoot = resolve(GARDEN_CLI_ROOT, "..")
const tmpDir = resolve(repoRoot, "tmp", "pkg")
const tmpStaticDir = resolve(tmpDir, "static")
const pkgPath = resolve(repoRoot, "node_modules", ".bin", "pkg")
const pkgPath = resolve(repoRoot, "cli", "node_modules", ".bin", "pkg")
const pkgFetchPath = resolve(repoRoot, "node_modules", ".bin", "pkg-fetch")
const distPath = resolve(repoRoot, "dist")
const sqliteBinFilename = "better_sqlite3.node"
Expand Down
5 changes: 5 additions & 0 deletions core/src/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,11 @@ export async function runScript({
script: string
envVars?: PrimitiveMap
}) {
envVars = envVars || {}

// Workaround for https://github.com/vercel/pkg/issues/897
envVars.PKG_EXECPATH = ""

// Run the script, capturing any errors
const proc = execa("bash", ["-s"], {
all: true,
Expand Down
4 changes: 2 additions & 2 deletions support/alpine-builder.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ ADD sdk /tmp/sdk
WORKDIR /tmp/cli

RUN apk add --no-cache python make gcc g++ --virtual .build-deps && \
yarn --production && \
yarn && \
# Fix for error in this particular package
rm -rf node_modules/es-get-iterator/test && \
apk del .build-deps
Expand All @@ -36,6 +36,6 @@ ADD static /garden/static

# Create the binary
RUN mkdir -p /garden \
&& ../pkg/node_modules/.bin/pkg --target node12-alpine-x64 . --output /garden/garden \
&& node_modules/.bin/pkg --target node12-alpine-x64 . --output /garden/garden \
&& cp node_modules/better-sqlite3/build/Release/better_sqlite3.node /garden \
&& /garden/garden version
99 changes: 88 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,12 @@
chalk "^2.0.0"
js-tokens "^4.0.0"

"@babel/parser@^7.1.0", "@babel/parser@^7.12.13", "@babel/parser@^7.12.17", "@babel/parser@^7.4.3", "@babel/parser@^7.7.0", "@babel/parser@^7.9.0", "@babel/parser@^7.9.4":
"@babel/[email protected]":
version "7.13.12"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.13.12.tgz#ba320059420774394d3b0c0233ba40e4250b81d1"
integrity sha512-4T7Pb244rxH24yR116LAuJ+adxXXnHhZaLJjegJVKSdoNCe4x1eDBaud5YIcQFcqzsaD5BHvJw5BQ0AZapdCRw==

"@babel/parser@^7.1.0", "@babel/parser@^7.12.13", "@babel/parser@^7.12.17", "@babel/parser@^7.4.3", "@babel/parser@^7.7.0", "@babel/parser@^7.9.0":
version "7.12.17"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.12.17.tgz#bc85d2d47db38094e5bb268fc761716e7d693848"
integrity sha512-r1yKkiUTYMQ8LiEI0UcQx5ETw5dpTLn9wijn9hk6KkTtOK95FndDN10M+8/s6k/Ymlbivw0Av9q4SlgF80PtHg==
Expand Down Expand Up @@ -1067,6 +1072,13 @@
core-js-pure "^3.0.0"
regenerator-runtime "^0.13.4"

"@babel/[email protected]":
version "7.13.10"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.13.10.tgz#47d42a57b6095f4468da440388fdbad8bebf0d7d"
integrity sha512-4QPkjJq6Ns3V/RgpEahRk+AGfL0eO6RHHtTWoNNr5mO49G6B5+X6d6THgWEAvTrznU5xYpbAlVKRYcsCgh/Akw==
dependencies:
regenerator-runtime "^0.13.4"

"@babel/[email protected]":
version "7.9.0"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.9.0.tgz#337eda67401f5b066a6f205a3113d4ac18ba495b"
Expand Down Expand Up @@ -3200,6 +3212,11 @@
"@types/emscripten" "^1.38.0"
tslib "^1.13.0"

"@yarnpkg/lockfile@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz#e77a97fbd345b76d83245edcd17d393b1b41fb31"
integrity sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ==

"@yarnpkg/parsers@^2.3.0":
version "2.3.0"
resolved "https://registry.yarnpkg.com/@yarnpkg/parsers/-/parsers-2.3.0.tgz#7b9564c6df02f4921d5cfe8287c4b648e93ea84b"
Expand Down Expand Up @@ -7956,6 +7973,13 @@ find-versions@^4.0.0:
dependencies:
semver-regex "^3.1.2"

find-yarn-workspace-root@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/find-yarn-workspace-root/-/find-yarn-workspace-root-2.0.0.tgz#f47fb8d239c900eb78179aa81b66673eac88f7bd"
integrity sha512-1IMnbjt4KzsQfnhnzNd8wUEgXZ44IzZaZmnLYx7D5FZlaHt2gW20Cri8Q+E/t5tIj4+epTBub+2Zxu/vNILzqQ==
dependencies:
micromatch "^4.0.2"

findup-sync@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/findup-sync/-/findup-sync-2.0.0.tgz#9326b1488c22d1a6088650a86901b2d9a90a2cbc"
Expand Down Expand Up @@ -8216,7 +8240,7 @@ fs-extra@^4.0.2:
jsonfile "^4.0.0"
universalify "^0.1.0"

fs-extra@^7.0.0:
fs-extra@^7.0.0, fs-extra@^7.0.1:
version "7.0.1"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-7.0.1.tgz#4f189c44aa123b895f722804f55ea23eadc348e9"
integrity sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==
Expand Down Expand Up @@ -11145,6 +11169,13 @@ kind-of@^6.0.0, kind-of@^6.0.2, kind-of@^6.0.3:
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd"
integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==

klaw-sync@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/klaw-sync/-/klaw-sync-6.0.0.tgz#1fd2cfd56ebb6250181114f0a581167099c2b28c"
integrity sha512-nIeuVSzdCCs6TDPTqI8w1Yre34sSq7AkZ4B3sfOBbI2CgVSB4Du4aLQijFU2+lhAFCwt9+42Hel6lQNIv6AntQ==
dependencies:
graceful-fs "^4.1.11"

klaw@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/klaw/-/klaw-3.0.0.tgz#b11bec9cf2492f06756d6e809ab73a2910259146"
Expand Down Expand Up @@ -13226,7 +13257,7 @@ only@~0.0.2:
resolved "https://registry.yarnpkg.com/only/-/only-0.0.2.tgz#2afde84d03e50b9a8edc444e30610a70295edfb4"
integrity sha1-Kv3oTQPlC5qO3EROMGEKcCle37Q=

open@^7.0.2, open@^7.0.4:
open@^7.0.2, open@^7.0.4, open@^7.4.2:
version "7.4.2"
resolved "https://registry.yarnpkg.com/open/-/open-7.4.2.tgz#b8147e26dcf3e426316c730089fd71edd29c2321"
integrity sha512-MVHddDVweXZF3awtlAS+6pgKLlm/JgxZ90+/NBurBoQctVOOB/zDdVjcyPzQ+0laDGbsWgrRkflI65sQeOgT9Q==
Expand Down Expand Up @@ -13652,6 +13683,25 @@ pascalcase@^0.1.1:
resolved "https://registry.yarnpkg.com/pascalcase/-/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14"
integrity sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=

patch-package@^6.4.7:
version "6.4.7"
resolved "https://registry.yarnpkg.com/patch-package/-/patch-package-6.4.7.tgz#2282d53c397909a0d9ef92dae3fdeb558382b148"
integrity sha512-S0vh/ZEafZ17hbhgqdnpunKDfzHQibQizx9g8yEf5dcVk3KOflOfdufRXQX8CSEkyOQwuM/bNz1GwKvFj54kaQ==
dependencies:
"@yarnpkg/lockfile" "^1.1.0"
chalk "^2.4.2"
cross-spawn "^6.0.5"
find-yarn-workspace-root "^2.0.0"
fs-extra "^7.0.1"
is-ci "^2.0.0"
klaw-sync "^6.0.0"
minimist "^1.2.0"
open "^7.4.2"
rimraf "^2.6.3"
semver "^5.6.0"
slash "^2.0.0"
tmp "^0.0.33"

[email protected]:
version "0.0.1"
resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-0.0.1.tgz#e6c4ddd7ed3aa27c68a20cc4e50e1a4ee83bbc4a"
Expand Down Expand Up @@ -13868,7 +13918,7 @@ pkg-dir@^5.0.0:
dependencies:
find-up "^5.0.0"

pkg-fetch@^2.6.9:
[email protected]:
version "2.6.9"
resolved "https://registry.yarnpkg.com/pkg-fetch/-/pkg-fetch-2.6.9.tgz#c18c5fa9604c57a3df3d9630afb64e176bc8732d"
integrity sha512-EnVR8LRILXBvaNP+wJOSY02c3+qDDfyEyR+aqAHLhcc9PBnbxFT9UZ1+If49goPQzQPn26TzF//fc6KXZ0aXEg==
Expand All @@ -13892,21 +13942,22 @@ [email protected], pkg-up@^3.1.0:
dependencies:
find-up "^3.0.0"

pkg@4.4.9:
version "4.4.9"
resolved "https://registry.yarnpkg.com/pkg/-/pkg-4.4.9.tgz#be04f8d03795772b7c4394724ae7252d7c2a4519"
integrity sha512-FK4GqHtcCY2PPPVaKViU0NyRzpo6gCS7tPKN5b7AkElqjAOCH1bsRKgohEnxThr6DWfTGByGqba2YHGR/BqbmA==
pkg@4.5.1:
version "4.5.1"
resolved "https://registry.yarnpkg.com/pkg/-/pkg-4.5.1.tgz#0f915110d726b17a7e66a76e5406ff9d393bccc8"
integrity sha512-UXKL88jGQ+FD4//PyrFeRcqurVQ3BVIfUNaEU9cXY24EJz08JyBj85qrGh0CFGvyzNb1jpwHOnns5Sw0M5H92Q==
dependencies:
"@babel/parser" "^7.9.4"
"@babel/runtime" "^7.9.2"
"@babel/parser" "7.13.12"
"@babel/runtime" "7.13.10"
chalk "^3.0.0"
escodegen "^1.14.1"
fs-extra "^8.1.0"
globby "^11.0.0"
into-stream "^5.1.1"
minimist "^1.2.5"
multistream "^2.1.1"
pkg-fetch "^2.6.9"
pkg-fetch "2.6.9"
prebuild-install "6.0.1"
progress "^2.0.3"
resolve "^1.15.1"
stream-meter "^1.0.4"
Expand Down Expand Up @@ -14646,6 +14697,32 @@ postcss@^7, postcss@^7.0.0, postcss@^7.0.1, postcss@^7.0.14, postcss@^7.0.17, po
source-map "^0.6.1"
supports-color "^6.1.0"

postinstall-postinstall@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/postinstall-postinstall/-/postinstall-postinstall-2.1.0.tgz#4f7f77441ef539d1512c40bd04c71b06a4704ca3"
integrity sha512-7hQX6ZlZXIoRiWNrbMQaLzUUfH+sSx39u8EJ9HYuDc1kLo9IXKWjM5RSquZN1ad5GnH8CGFM78fsAAQi3OKEEQ==

[email protected]:
version "6.0.1"
resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-6.0.1.tgz#5902172f7a40eb67305b96c2a695db32636ee26d"
integrity sha512-7GOJrLuow8yeiyv75rmvZyeMGzl8mdEX5gY69d6a6bHWmiPevwqFw+tQavhK0EYMaSg3/KD24cWqeQv1EWsqDQ==
dependencies:
detect-libc "^1.0.3"
expand-template "^2.0.3"
github-from-package "0.0.0"
minimist "^1.2.3"
mkdirp-classic "^0.5.3"
napi-build-utils "^1.0.1"
node-abi "^2.7.0"
noop-logger "^0.1.1"
npmlog "^4.0.1"
pump "^3.0.0"
rc "^1.2.7"
simple-get "^3.0.3"
tar-fs "^2.0.0"
tunnel-agent "^0.6.0"
which-pm-runs "^1.0.0"

prebuild-install@^5.3.3:
version "5.3.6"
resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-5.3.6.tgz#7c225568d864c71d89d07f8796042733a3f54291"
Expand Down

0 comments on commit acbfb63

Please sign in to comment.