Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
H
heroku-buildpack-nodejs
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
heroku-buildpack-nodejs
Commits
e5071867
Unverified
Commit
e5071867
authored
Feb 02, 2018
by
Jeremy Morrell
Committed by
GitHub
Feb 02, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix CI env vars (#513)
Fixes #414 #504
parent
b687474e
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
106 additions
and
2 deletions
+106
-2
test-compile
bin/test-compile
+9
-1
nodejs.sh
ci-profile/nodejs.sh
+3
-0
environment.sh
lib/environment.sh
+7
-0
README.md
test/fixtures/ci-env-test/README.md
+1
-0
package.json
test/fixtures/ci-env-test/package.json
+16
-0
quick
test/quick
+29
-1
run
test/run
+41
-0
No files found.
bin/test-compile
View file @
e5071867
#!/usr/bin/env bash
NPM_CONFIG_PRODUCTION
=
false
NODE_ENV
=
test
"
$(
dirname
${
0
:-})
/compile"
"
$1
"
"
$2
"
"
$3
"
BP_DIR
=
$(
cd
$(
dirname
${
0
:-})
;
cd
..
;
pwd
)
source
$BP_DIR
/lib/environment.sh
export
NPM_CONFIG_PRODUCTION
=
${
NPM_CONFIG_PRODUCTION
:-
false
}
export
NODE_ENV
=
${
NODE_ENV
:-
test
}
"
$BP_DIR
/bin/compile"
"
$1
"
"
$2
"
"
$3
"
write_ci_profile
"
$BP_DIR
"
"
$1
"
ci-profile/nodejs.sh
0 → 100755
View file @
e5071867
export
PATH
=
"
$HOME
/.heroku/node/bin:
$HOME
/.heroku/yarn/bin:
$PATH
:
$HOME
/bin:
$HOME
/node_modules/.bin"
export
NODE_HOME
=
"
$HOME
/.heroku/node"
export
NODE_ENV
=
${
NODE_ENV
:-
test
}
lib/environment.sh
View file @
e5071867
...
...
@@ -64,6 +64,13 @@ write_profile() {
cp
$bp_dir
/profile/
*
$build_dir
/.profile.d/
}
write_ci_profile
()
{
local
bp_dir
=
"
$1
"
local
build_dir
=
"
$2
"
write_profile
"
$1
"
"
$2
"
cp
$bp_dir
/ci-profile/
*
$build_dir
/.profile.d/
}
write_export
()
{
local
bp_dir
=
"
$1
"
local
build_dir
=
"
$2
"
...
...
test/fixtures/ci-env-test/README.md
0 → 100644
View file @
e5071867
A fake README, to keep npm from polluting stderr.
\ No newline at end of file
test/fixtures/ci-env-test/package.json
0 → 100644
View file @
e5071867
{
"name"
:
"node-buildpack-test-app"
,
"version"
:
"0.0.1"
,
"repository"
:
{
"type"
:
"git"
,
"url"
:
"http://github.com/example/example.git"
},
"engines"
:
{
"node"
:
"8.x"
},
"scripts"
:
{
"heroku-prebuild"
:
"echo heroku-prebuild hook message"
,
"heroku-postbuild"
:
"echo heroku-postbuild hook message"
,
"test"
:
"echo NODE_ENV: $NODE_ENV"
}
}
test/quick
View file @
e5071867
#!/usr/bin/env bash
source
$(
pwd
)
/lib/environment.sh
mktmpdir
()
{
local dir
=
$(
mktemp
-t
testXXXXX
)
rm
-rf
$dir
...
...
@@ -21,5 +23,31 @@ compile() {
"
$bp_dir
/bin/compile"
"
$build_dir
"
"
$cache_dir
"
}
compileTest
()
{
local
fixture
=
$1
local
bp_dir
=
$(
mktmpdir
)
local
build_dir
=
$(
mktmpdir
)
local
cache_dir
=
$(
mktmpdir
)
local
env_dir
=
$(
mktmpdir
)
echo
"Compiling
$fixture
"
echo
"in
$build_dir
"
echo
"(caching in
$cache_dir
)"
cp
-a
$(
pwd
)
/
*
${
bp_dir
}
cp
-a
${
bp_dir
}
/test/fixtures/
$fixture
/.
${
build_dir
}
"
$bp_dir
/bin/test-compile"
"
$build_dir
"
"
$cache_dir
"
export
HOME
=
${
build_dir
}
export_env_dir
$env_dir
for
f
in
${
build_dir
}
/.profile.d/
*
;
do
source
$f
>
/dev/null 2> /dev/null
;
done
"
$bp_dir
/bin/test"
"
$build_dir
"
}
fixture
=
${
1
:-
'stable-node'
}
compile
"
$fixture
"
if
[[
"
$2
"
==
"test"
]]
;
then
compileTest
"
$fixture
"
else
compile
"
$fixture
"
fi
test/run
View file @
e5071867
...
...
@@ -724,6 +724,21 @@ testMultiExport() {
assertCapturedSuccess
}
testCIEnvVars
()
{
compileTest
"ci-env-test"
assertCaptured
"NODE_ENV: test"
assertCapturedSuccess
}
testCIEnvVarsOverride
()
{
env_dir
=
$(
mktmpdir
)
echo
"banana"
>
$env_dir
/NODE_ENV
compileTest
"ci-env-test"
"
$(
mktmpdir
)
"
$env_dir
assertCaptured
"NODE_ENV: banana"
assertCapturedSuccess
}
# Utils
...
...
@@ -731,6 +746,7 @@ pushd $(dirname 0) >/dev/null
popd
>
/dev/null
source
$(
pwd
)
/test/utils
source
$(
pwd
)
/lib/environment.sh
mktmpdir
()
{
dir
=
$(
mktemp
-t
testXXXXX
)
...
...
@@ -761,6 +777,31 @@ compile() {
capture
${
bp_dir
}
/bin/compile
${
compile_dir
}
${
2
:-$(
mktmpdir
)}
$3
}
compileTest
()
{
default_process_types_cleanup
local
bp_dir
=
$(
mktmpdir
)
local
compile_dir
=
$(
mktmpdir
)
local
cache_dir
=
${
2
:-$(
mktmpdir
)}
local
env_dir
=
$3
cp
-a
$(
pwd
)
/
*
${
bp_dir
}
cp
-a
${
bp_dir
}
/test/fixtures/
$1
/.
${
compile_dir
}
capture
${
bp_dir
}
/bin/test-compile
${
compile_dir
}
${
2
:-$(
mktmpdir
)}
$3
# On Heroku, $HOME is the /app dir, so we need to set it to
# the compile_dir here
export
HOME
=
${
compile_dir
}
# bin/test is not ran during build, rather during runtime, which means
# we need to set any environment variables set via the env_dir and run
# all of the .profile.d scripts
export_env_dir
$env_dir
for
f
in
${
compile_dir
}
/.profile.d/
*
;
do
source
$f
>
/dev/null 2> /dev/null
;
done
capture
${
bp_dir
}
/bin/test
${
compile_dir
}
}
compileDir
()
{
default_process_types_cleanup
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment