Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bootstrap
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
bootstrap
Commits
718a6c5d
Commit
718a6c5d
authored
Apr 03, 2014
by
Chris Rebert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move some caching info+logic out of .travis.yml; fixes #13136
parent
1759569d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
35 deletions
+77
-35
.travis.yml
.travis.yml
+4
-4
test-infra/S3Cachefile.json
test-infra/S3Cachefile.json
+12
-0
test-infra/s3_cache.py
test-infra/s3_cache.py
+60
-31
test-infra/uncached-npm-install.sh
test-infra/uncached-npm-install.sh
+1
-0
No files found.
.travis.yml
View file @
718a6c5d
...
@@ -8,11 +8,11 @@ before_install:
...
@@ -8,11 +8,11 @@ before_install:
-
if [ "$TWBS_TEST" = validate-html ]; then echo "ruby=$(basename $GEMDIR) jekyll=$JEKYLL_VERSION" > pseudo_Gemfile.lock; fi
-
if [ "$TWBS_TEST" = validate-html ]; then echo "ruby=$(basename $GEMDIR) jekyll=$JEKYLL_VERSION" > pseudo_Gemfile.lock; fi
install
:
install
:
-
time npm install -g grunt-cli
-
time npm install -g grunt-cli
-
./test-infra/s3_cache.py download
'npm packages' test-infra/npm-shrinkwrap.canonical.json ./node_modules || time ./test-infra/uncached-npm-install.sh
-
./test-infra/s3_cache.py download
npm-modules
-
if [ "$TWBS_TEST" = validate-html ]; then ./test-infra/s3_cache.py download rubygems
pseudo_Gemfile.lock $GEMDIR || time gem install -N jekyll -v $JEKYLL_VERSION
; fi
-
if [ "$TWBS_TEST" = validate-html ]; then ./test-infra/s3_cache.py download rubygems; fi
after_script
:
after_script
:
-
if [ "$TWBS_TEST" = core ]; then ./test-infra/s3_cache.py upload
'npm packages' test-infra/npm-shrinkwrap.canonical.json ./node_
modules; fi
-
if [ "$TWBS_TEST" = core ]; then ./test-infra/s3_cache.py upload
npm-
modules; fi
-
if [ "$TWBS_TEST" = validate-html ]; then ./test-infra/s3_cache.py upload rubygems
pseudo_Gemfile.lock $GEMDIR
; fi
-
if [ "$TWBS_TEST" = validate-html ]; then ./test-infra/s3_cache.py upload rubygems; fi
env
:
env
:
global
:
global
:
-
JEKYLL_VERSION
:
1.5.0
-
JEKYLL_VERSION
:
1.5.0
...
...
test-infra/S3Cachefile.json
0 → 100644
View file @
718a6c5d
{
"npm-modules"
:
{
"key"
:
"./npm-shrinkwrap.canonical.json"
,
"cache"
:
"../node_modules"
,
"generate"
:
"./uncached-npm-install.sh"
},
"rubygems"
:
{
"key"
:
"../pseudo_Gemfile.lock"
,
"cache"
:
"$GEMDIR"
,
"generate"
:
"gem install -N jekyll -v $JEKYLL_VERSION"
}
}
test-infra/s3_cache.py
View file @
718a6c5d
...
@@ -2,10 +2,11 @@
...
@@ -2,10 +2,11 @@
from
__future__
import
absolute_import
,
unicode_literals
,
print_function
,
division
from
__future__
import
absolute_import
,
unicode_literals
,
print_function
,
division
from
sys
import
argv
from
sys
import
argv
from
os
import
environ
,
stat
,
remove
as
_delete_file
from
os
import
environ
,
stat
,
chdir
,
remove
as
_delete_file
from
os.path
import
isfile
,
dirname
,
basename
,
abspath
from
os.path
import
isfile
,
dirname
,
basename
,
abspath
,
realpath
,
expandvars
from
hashlib
import
sha256
from
hashlib
import
sha256
from
subprocess
import
check_call
as
run
from
subprocess
import
check_call
as
run
from
json
import
load
from
contextlib
import
contextmanager
from
contextlib
import
contextmanager
from
datetime
import
datetime
from
datetime
import
datetime
...
@@ -14,12 +15,9 @@ from boto.s3.key import Key
...
@@ -14,12 +15,9 @@ from boto.s3.key import Key
from
boto.exception
import
S3ResponseError
from
boto.exception
import
S3ResponseError
CONFIG_FILE
=
'./S3Cachefile.json'
NEED_TO_UPLOAD_MARKER
=
'.need-to-upload'
NEED_TO_UPLOAD_MARKER
=
'.need-to-upload'
BYTES_PER_MB
=
1024
*
1024
BYTES_PER_MB
=
1024
*
1024
try
:
BUCKET_NAME
=
environ
[
'TWBS_S3_BUCKET'
]
except
KeyError
:
raise
SystemExit
(
"TWBS_S3_BUCKET environment variable not set!"
)
@
contextmanager
@
contextmanager
...
@@ -71,24 +69,24 @@ def _extract_tarball(directory):
...
@@ -71,24 +69,24 @@ def _extract_tarball(directory):
def
download
(
directory
):
def
download
(
directory
):
_delete_file_quietly
(
NEED_TO_UPLOAD_MARKER
)
_delete_file_quietly
(
NEED_TO_UPLOAD_MARKER
)
try
:
try
:
print
(
"Downloading {} tarball from S3..."
.
format
(
friendly
_name
))
print
(
"Downloading {} tarball from S3..."
.
format
(
cache
_name
))
with
timer
():
with
timer
():
key
.
get_contents_to_filename
(
_tarball_filename_for
(
directory
))
key
.
get_contents_to_filename
(
_tarball_filename_for
(
directory
))
except
S3ResponseError
as
err
:
except
S3ResponseError
as
err
:
open
(
NEED_TO_UPLOAD_MARKER
,
'a'
)
.
close
()
open
(
NEED_TO_UPLOAD_MARKER
,
'a'
)
.
close
()
print
(
err
)
print
(
err
)
raise
SystemExit
(
"Cached {} download failed!"
.
format
(
friendly
_name
))
raise
SystemExit
(
"Cached {} download failed!"
.
format
(
cache
_name
))
print
(
"Downloaded {}."
.
format
(
_tarball_size
(
directory
)))
print
(
"Downloaded {}."
.
format
(
_tarball_size
(
directory
)))
_extract_tarball
(
directory
)
_extract_tarball
(
directory
)
print
(
"{} successfully installed from cache."
.
format
(
friendly
_name
))
print
(
"{} successfully installed from cache."
.
format
(
cache
_name
))
def
upload
(
directory
):
def
upload
(
directory
):
_create_tarball
(
directory
)
_create_tarball
(
directory
)
print
(
"Uploading {} tarball to S3... ({})"
.
format
(
friendly
_name
,
_tarball_size
(
directory
)))
print
(
"Uploading {} tarball to S3... ({})"
.
format
(
cache
_name
,
_tarball_size
(
directory
)))
with
timer
():
with
timer
():
key
.
set_contents_from_filename
(
_tarball_filename_for
(
directory
))
key
.
set_contents_from_filename
(
_tarball_filename_for
(
directory
))
print
(
"{} cache successfully updated."
.
format
(
friendly
_name
))
print
(
"{} cache successfully updated."
.
format
(
cache
_name
))
_delete_file_quietly
(
NEED_TO_UPLOAD_MARKER
)
_delete_file_quietly
(
NEED_TO_UPLOAD_MARKER
)
...
@@ -97,26 +95,57 @@ if __name__ == '__main__':
...
@@ -97,26 +95,57 @@ if __name__ == '__main__':
# AWS_ACCESS_KEY_ID -- AWS Access Key ID
# AWS_ACCESS_KEY_ID -- AWS Access Key ID
# AWS_SECRET_ACCESS_KEY -- AWS Secret Access Key
# AWS_SECRET_ACCESS_KEY -- AWS Secret Access Key
argv
.
pop
(
0
)
argv
.
pop
(
0
)
if
len
(
argv
)
!=
4
:
if
len
(
argv
)
!=
2
:
raise
SystemExit
(
"USAGE: s3_cache.py <download | upload> <friendly name> <dependencies file> <directory>"
)
raise
SystemExit
(
"USAGE: s3_cache.py <download | upload> <cache name>"
)
mode
,
friendly_name
,
dependencies_file
,
directory
=
argv
mode
,
cache_name
=
argv
script_dir
=
dirname
(
realpath
(
__file__
))
conn
=
S3Connection
()
chdir
(
script_dir
)
bucket
=
conn
.
lookup
(
BUCKET_NAME
)
try
:
if
bucket
is
None
:
with
open
(
CONFIG_FILE
,
'rt'
)
as
config_file
:
raise
SystemExit
(
"Could not access bucket!"
)
config
=
load
(
config_file
)
except
(
IOError
,
OSError
,
ValueError
)
as
config_err
:
dependencies_file_hash
=
_sha256_of_file
(
dependencies_file
)
print
(
config_err
)
raise
SystemExit
(
"Error when trying to load config from JSON file!"
)
key
=
Key
(
bucket
,
dependencies_file_hash
)
try
:
key
.
storage_class
=
'REDUCED_REDUNDANCY'
cache_info
=
config
[
cache_name
]
key_file
=
expandvars
(
cache_info
[
"key"
])
fallback_cmd
=
cache_info
[
"generate"
]
directory
=
expandvars
(
cache_info
[
"cache"
])
except
(
TypeError
,
KeyError
)
as
load_err
:
print
(
load_err
)
raise
SystemExit
(
"Config for cache named {!r} is missing or malformed!"
.
format
(
cache_name
))
if
mode
==
'download'
:
try
:
download
(
directory
)
try
:
elif
mode
==
'upload'
:
BUCKET_NAME
=
environ
[
'TWBS_S3_BUCKET'
]
if
isfile
(
NEED_TO_UPLOAD_MARKER
):
# FIXME
except
KeyError
:
upload
(
directory
)
raise
SystemExit
(
"TWBS_S3_BUCKET environment variable not set!"
)
conn
=
S3Connection
()
bucket
=
conn
.
lookup
(
BUCKET_NAME
)
if
bucket
is
None
:
raise
SystemExit
(
"Could not access bucket!"
)
key_file_hash
=
_sha256_of_file
(
key_file
)
key
=
Key
(
bucket
,
key_file_hash
)
key
.
storage_class
=
'REDUCED_REDUNDANCY'
if
mode
==
'download'
:
download
(
directory
)
elif
mode
==
'upload'
:
if
isfile
(
NEED_TO_UPLOAD_MARKER
):
# FIXME
upload
(
directory
)
else
:
print
(
"No need to upload anything."
)
else
:
else
:
print
(
"No need to upload anything."
)
raise
SystemExit
(
"Unrecognized mode {!r}"
.
format
(
mode
))
else
:
except
BaseException
as
exc
:
raise
SystemExit
(
"Unrecognized mode {!r}"
.
format
(
mode
))
if
mode
!=
'download'
:
raise
print
(
"Error!:"
,
exc
)
print
(
"Unable to download from cache."
)
print
(
"Running fallback command to generate cache directory {!r}: {}"
.
format
(
directory
,
fallback_cmd
))
with
timer
():
run
(
fallback_cmd
,
shell
=
True
)
test-infra/uncached-npm-install.sh
View file @
718a6c5d
#!/bin/bash
#!/bin/bash
set
-e
set
-e
cd
..
# /bootstrap/
cp
test-infra/npm-shrinkwrap.canonical.json npm-shrinkwrap.json
cp
test-infra/npm-shrinkwrap.canonical.json npm-shrinkwrap.json
npm
install
npm
install
rm
npm-shrinkwrap.json
rm
npm-shrinkwrap.json
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