Automate tests for CI

This commit is contained in:
Dan Dascalescu 2014-12-14 16:09:53 -08:00
parent e77a8c2dd6
commit f2be1f9e8a
4 changed files with 46 additions and 62 deletions

View File

@ -13,7 +13,7 @@ Package.describe({
}); });
Package.onUse(function (api) { Package.onUse(function (api) {
api.versionsFrom('METEOR@0.9.2.1'); api.versionsFrom(['METEOR@0.9.2.1', 'METEOR@1.0']);
api.addFiles([ api.addFiles([
// we bundle all font files, but the client will request only one of them via the CSS @font-face rule // we bundle all font files, but the client will request only one of them via the CSS @font-face rule
'fonts/fontawesome-webfont.eot', // IE8 or older only understands EOT. IE9+ will read it too because it loads the first occurrence of `src` 'fonts/fontawesome-webfont.eot', // IE8 or older only understands EOT. IE9+ will read it too because it loads the first occurrence of `src`

View File

@ -1,61 +1,40 @@
# Publish package on Meteor's Atmosphere.js #!/bin/bash
# Publish package to Meteor's repository, Atmospherejs.com
# Make sure Meteor is installed, per https://www.meteor.com/install. The curl'ed script is totally safe; takes 2 minutes to read its source and check. # Make sure Meteor is installed, per https://www.meteor.com/install.
# The curl'ed script is totally safe; takes 2 minutes to read its source and check.
type meteor >/dev/null 2>&1 || { curl https://install.meteor.com/ | sh; } type meteor >/dev/null 2>&1 || { curl https://install.meteor.com/ | sh; }
# sanity check: make sure we're in the root directory of the checkout # sanity check: make sure we're in the root directory of the checkout
cd "$( dirname "$0" )/.." cd "$( dirname "$0" )/.."
# publish separately any package*.js files we have, e.g. package.js, package-compat.js ALL_EXIT_CODE=0
# test any package*.js packages we may have, e.g. package.js, package-compat.js
for PACKAGE_FILE in meteor/package*.js; do for PACKAGE_FILE in meteor/package*.js; do
# Meteor expects package.js to be in the root directory of the checkout, so copy there our package file under that name, temporarily # Meteor expects package.js to be in the root directory of the checkout, so copy there our package file under that name, temporarily
cp $PACKAGE_FILE ./package.js cp $PACKAGE_FILE ./package.js
# publish package, creating it if it's the first time we're publishing # publish package, creating it if it's the first time we're publishing
PACKAGE_NAME=$(grep -i name $PACKAGE_FILE | head -1 | cut -d "'" -f 2) PACKAGE_NAME=$(grep -i name package.js | head -1 | cut -d "'" -f 2)
ATMOSPHERE_NAME=${PACKAGE_NAME/://}
echo "Publishing $PACKAGE_NAME..." echo "Publishing $PACKAGE_NAME..."
# attempt to re-publish the package - the most common operation once the initial release has been made # Attempt to re-publish the package - the most common operation once the initial release has
POTENTIAL_ERROR=$( meteor publish 2>&1 ) # been made. If the package name was changed (rare), you'll have to pass the --create flag.
meteor publish "$@"; EXIT_CODE=$?
if [[ $POTENTIAL_ERROR =~ "There is no package named" ]]; then ALL_EXIT_CODE=$(( $ALL_EXIT_CODE + $EXIT_CODE ))
# actually this is the first time the package is created, so pass the special --create flag and congratulate the maintainer if (( $EXIT_CODE == 0 )); then
echo "Thank you for creating the official Meteor package for this library!" echo "Thanks for releasing a new version. You can see it at"
if meteor publish --create; then echo "https://atmospherejs.com/${PACKAGE_NAME/://}"
echo "Please post the following to https://github.com/raix/Meteor-community-discussions/issues/14:
--------------------------------------------- 8< --------------------------------------------------------
Happy to announce that I've published the official $PACKAGE_NAME to Atmosphere. Please star!
https://atmospherejs.com/$ATMOSPHERE_NAME
--------------------------------------------- >8 --------------------------------------------------------
"
else
echo "We got an error. Please post it at https://github.com/raix/Meteor-community-discussions/issues/14"
fi
else else
if (( $? > 0 )); then echo "We got an error. Please post it at https://github.com/raix/Meteor-community-discussions/issues/14"
# the error wasn't that the package didn't exist, so we need to ask for help
echo "We got an error. Please post it at https://github.com/raix/Meteor-community-discussions/issues/14:
--------------------------------------------- 8< --------------------------------------------------------
$POTENTIAL_ERROR
--------------------------------------------- >8 --------------------------------------------------------
"
else
echo "Thanks for releasing a new version of $PACKAGE_NAME! You can see it at
https://atmospherejs.com/$ATMOSPHERE_NAME"
fi
fi fi
# we copied the file as package.js, regardless of its original name # rm the temporary build files and package.js
rm package.js rm -rf ".build.$PACKAGE_NAME" versions.json package.js
# temporary build files
rm -rf ".build.$PACKAGE_NAME"
done done
exit $ALL_EXIT_CODE

View File

@ -1,36 +1,38 @@
#!/bin/sh
# Test Meteor package before publishing to Atmospherejs.com # Test Meteor package before publishing to Atmospherejs.com
# Make sure Meteor is installed, per https://www.meteor.com/install. The curl'ed script is totally safe; takes 2 minutes to read its source and check. # Make sure Meteor is installed, per https://www.meteor.com/install.
# The curl'ed script is totally safe; takes 2 minutes to read its source and check.
type meteor >/dev/null 2>&1 || { curl https://install.meteor.com/ | sh; } type meteor >/dev/null 2>&1 || { curl https://install.meteor.com/ | sh; }
# sanity check: make sure we're in the root directory of the checkout # sanity check: make sure we're in the root directory of the checkout
cd "$( dirname "$0" )/.." cd "$( dirname "$0" )/.."
# run tests and delete the temporary package.js even if Ctrl+C is pressed ALL_EXIT_CODE=0
int_trap() {
echo
printf "Tests interrupted. Hopefully you verified in the browser that tests pass?\n\n"
}
trap int_trap INT # test any package*.js packages we may have, e.g. package.js, package-standalone.js
# test any package*.js packages we may have, e.g. package.js, package-compat.js
for PACKAGE_FILE in meteor/package*.js; do for PACKAGE_FILE in meteor/package*.js; do
PACKAGE_NAME=$(grep -i name $PACKAGE_FILE | head -1 | cut -d "'" -f 2) # Meteor expects package.js in the root dir of the checkout, so copy there our package file under that name, temporarily
echo "Testing $PACKAGE_NAME..."
# Meteor expects package.js to be in the root directory of the checkout, so copy there our package file under that name, temporarily
cp $PACKAGE_FILE ./package.js cp $PACKAGE_FILE ./package.js
PACKAGE_NAME=$(grep -i name package.js | head -1 | cut -d "'" -f 2)
echo "### Testing $PACKAGE_NAME..."
# provide an invalid MONGO_URL so Meteor doesn't bog us down with an empty Mongo database # provide an invalid MONGO_URL so Meteor doesn't bog us down with an empty Mongo database
MONGO_URL=mongodb:// meteor test-packages ./ if [ $# -gt 0 ]; then
# interpret any parameter to mean we want an interactive test
MONGO_URL=mongodb:// meteor test-packages ./
else
# automated/CI test with phantomjs
spacejam --mongo-url mongodb:// test-packages ./
ALL_EXIT_CODES=$(( $ALL_EXIT_CODES + $? ))
fi
rm -rf ".build.$PACKAGE_NAME" # delete temporary build files and package.js
rm -rf ".build.local-test:$PACKAGE_NAME" rm -rf .build.* versions.json package.js
rm versions.json 2>/dev/null
rm package.js
done done
exit $ALL_EXIT_CODES

View File

@ -42,6 +42,9 @@
], ],
"dependencies": { "dependencies": {
}, },
"devDependencies": {
"spacejam": "^1.1.1"
},
"engines" : { "engines" : {
"node" : ">=0.10.3" "node" : ">=0.10.3"
} }