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
6fd9b8f3
Commit
6fd9b8f3
authored
Jul 22, 2015
by
Hunter Loftis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test and implementation to invalidate cache on runtime signature changes
parent
7a40a987
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
79 additions
and
33 deletions
+79
-33
CHANGELOG.md
CHANGELOG.md
+6
-2
compile
bin/compile
+6
-6
cache.sh
lib/cache.sh
+5
-12
README.md
test/fixtures/node-0.12.6/README.md
+1
-0
package.json
test/fixtures/node-0.12.6/package.json
+14
-0
README.md
test/fixtures/node-0.12.7/README.md
+1
-0
package.json
test/fixtures/node-0.12.7/package.json
+14
-0
run
test/run
+32
-13
No files found.
CHANGELOG.md
View file @
6fd9b8f3
## Upcoming
-
Fix runtime signature cache invalidation
## v77
-
Skip npm bootstrapping with iojs
...
...
@@ -15,8 +19,8 @@
## v73 (24/4/2015)
-
Patch for caching to d
isable cache restoration if node_modules already exists (eg from being git submoduled or checked into git)
-
D
isable cache restoration if node_modules already exists (eg from being git submoduled or checked into git)
## v72 (23/4/2015)
*
Accept
s
`cacheDirectories`
array in package.json to override default
`node_modules`
caching
*
Accept
`cacheDirectories`
array in package.json to override default
`node_modules`
caching
bin/compile
View file @
6fd9b8f3
...
...
@@ -89,13 +89,9 @@ header "Installing binaries"
install_bins | indent
restore_cache
()
{
local
cache_status
=
$(
get_cache_status
)
local
cache_status
=
"
$(
get_cache_status
)
"
if
[
"
$cache_status
"
==
"disabled"
]
;
then
echo
"Skipping (cache disabled)"
elif
[
"
$cache_status
"
==
"invalidated"
]
;
then
echo
"Skipping (cache invalidated)"
else
if
[
"
$cache_status
"
==
"valid"
]
;
then
local
cache_directories
=
$(
get_cache_directories
)
if
[
"
$cache_directories
"
==
""
]
;
then
echo
"Loading 1 from cacheDirectories (default):"
...
...
@@ -104,6 +100,8 @@ restore_cache() {
echo
"Loading
$(
echo
$cache_directories
|
wc
-w
| xargs
)
from cacheDirectories (package.json):"
restore_cache_directories
"
$BUILD_DIR
"
"
$CACHE_DIR
"
$cache_directories
fi
else
echo
"Skipping cache (
$cache_status
)"
fi
}
...
...
@@ -124,6 +122,7 @@ build_dependencies | indent
cache_build
()
{
local
cache_directories
=
$(
get_cache_directories
)
echo
"Clearing previous node cache"
clear_cache
if
[
"
$cache_directories
"
==
""
]
;
then
...
...
@@ -133,6 +132,7 @@ cache_build() {
echo
"Saving
$(
echo
$cache_directories
|
wc
-w
| xargs
)
cacheDirectories (package.json):"
save_cache_directories
"
$BUILD_DIR
"
"
$CACHE_DIR
"
$cache_directories
fi
save_signature
}
header
"Caching build"
...
...
lib/cache.sh
View file @
6fd9b8f3
...
...
@@ -5,7 +5,7 @@ create_signature() {
}
save_signature
()
{
echo
"
$(
get
_signature
)
"
>
$CACHE_DIR
/node/signature
echo
"
$(
create
_signature
)
"
>
$CACHE_DIR
/node/signature
}
load_signature
()
{
...
...
@@ -16,19 +16,11 @@ load_signature() {
fi
}
signature_changed
()
{
if
!
[
"
$(
create_signature
)
"
==
"
$(
load_signature
)
"
]
;
then
return
1
else
return
0
fi
}
get_cache_status
()
{
if
!
${
NODE_MODULES_CACHE
:-
true
}
;
then
echo
"disabled"
elif
signature_changed
;
then
echo
"
invalidated
"
echo
"disabled
by config
"
elif
[
"
$(
create_signature
)
"
!=
"
$(
load_signature
)
"
]
;
then
echo
"
new runtime signature
"
else
echo
"valid"
fi
...
...
@@ -66,6 +58,7 @@ restore_cache_directories() {
clear_cache
()
{
rm
-rf
$CACHE_DIR
/node
mkdir
-p
$CACHE_DIR
/node
}
save_cache_directories
()
{
...
...
test/fixtures/node-0.12.6/README.md
0 → 100644
View file @
6fd9b8f3
A fake README, to keep npm from polluting stderr.
\ No newline at end of file
test/fixtures/node-0.12.6/package.json
0 → 100644
View file @
6fd9b8f3
{
"name"
:
"node-buildpack-test-app"
,
"version"
:
"0.0.1"
,
"description"
:
"node buildpack integration test app"
,
"repository"
:
{
"type"
:
"git"
,
"url"
:
"http://github.com/example/example.git"
},
"dependencies"
:
{
},
"engines"
:
{
"node"
:
"0.12.6"
}
}
test/fixtures/node-0.12.7/README.md
0 → 100644
View file @
6fd9b8f3
A fake README, to keep npm from polluting stderr.
\ No newline at end of file
test/fixtures/node-0.12.7/package.json
0 → 100644
View file @
6fd9b8f3
{
"name"
:
"node-buildpack-test-app"
,
"version"
:
"0.0.1"
,
"description"
:
"node buildpack integration test app"
,
"repository"
:
{
"type"
:
"git"
,
"url"
:
"http://github.com/example/example.git"
},
"dependencies"
:
{
},
"engines"
:
{
"node"
:
"0.12.7"
}
}
test/run
View file @
6fd9b8f3
#!/usr/bin/env bash
# See README.md for info on running these tests.
testBuildWithCache
()
{
cache
=
$(
mktmpdir
)
compile
"stable-node"
$cache
assertCaptured
"Skipping cache (new runtime"
assertEquals
"1"
"
$(
ls
-1
$cache
/node |
grep
node_modules |
wc
-l
|
tr
-d
' '
)
"
assertCapturedSuccess
compile
"stable-node"
$cache
assertNotCaptured
"- node_modules (not cached - skipping)"
assertCapturedSuccess
rm
-rf
"
$cache
/node/node_modules"
compile
"stable-node"
$cache
assertCaptured
"- node_modules (not cached - skipping)"
assertCapturedSuccess
}
testSignatureInvalidation
()
{
cache
=
$(
mktmpdir
)
env_dir
=
$(
mktmpdir
)
compile
"node-0.12.6"
$cache
assertCaptured
"Downloading and installing node 0.12.6"
assertCapturedSuccess
compile
"node-0.12.7"
$cache
assertCaptured
"Downloading and installing node 0.12.7"
assertCaptured
"Skipping cache (new runtime"
assertCapturedSuccess
}
testModulesCheckedIn
()
{
cache
=
$(
mktmpdir
)
compile
"modules-checked-in"
$cache
...
...
@@ -205,19 +237,6 @@ testNodeModulesCached() {
assertCapturedSuccess
}
testBuildWithCache
()
{
cache
=
$(
mktmpdir
)
compile
"stable-node"
$cache
assertCaptured
"- node_modules (not cached - skipping)"
assertEquals
"1"
"
$(
ls
-1
$cache
/node |
grep
node_modules |
wc
-l
|
tr
-d
' '
)
"
assertCapturedSuccess
compile
"stable-node"
$cache
assertNotCaptured
"- node_modules (not cached - skipping)"
assertCapturedSuccess
}
testBuildWithUserCacheDirectories
()
{
cache
=
$(
mktmpdir
)
...
...
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